How can i add gameanalytics to my IOS build?

How can i add gameanalytics to my IOS build?
0

#1

TLDR
How can i implement Gameanalytics and facebook sdk so it works on ios?.

Long version:

My plan is to use Cocos creator so i can create games for Facebook Instant games, IOS and android.
The problem is most my clients ask for Gameanalytics and facebook sdk for testing retention and stuff.
Usually i was working with unity because the sdk is the same for IOS and android.
For cocos there is just this
https://gameanalytics.com/docs/item/cocos2d-sdk
but it says cocos creator html5


#2

Did you find a solution?


#3

Nop, i did not


#4

Thats kind of blocker for me, I can’t use CC to develop games. Publisher needs FB and GA SDK’s, mandatory. What should I do? What you will do?


#5

Actually it is very easy, I added FB and GA to our game for Voodoo publisher. You can follow GA Instruction and add it over xcode. It will take only 15 minutes, really :+1:

https://gameanalytics.com/docs/item/ios-sdk


#6

Yes that is how you add the library. But if the library is added on xcode and called using c-objetive, how do you make the event calls (game start and game end) from the js/typescript code if the lib is c-objective?


#7
  • Just open the xcode and your build project

…/build/frameworks/runtime-src/pro.ios_mac/PROJECT_NAME.xcodeproj

  • Add (drag & drop) the GA framrwork file to Frameworks folder which is located left side

  • Open “/ios/AppController.mm” file and call the GA library

import <GameAnalytics/GameAnalytics.h>

  • Add another code AppController.mm file for initiliaze the GA

[GameAnalytics setEnabledInfoLog:YES];
[GameAnalytics configureBuild:@“YOUR_BUILD_ID”];
[GameAnalytics initializeWithGameKey:@“YOUR_KEY” gameSecret:@“YOUR_SECRET”];

Actually you don’t need to call custom event in GA. You should only initialize GA and it will start to track your game. If you need custom event, you have to write object-c class/function into xcode and call it from javascript. (Javascript & Object-C reflection)

http://docs.cocos.com/creator/1.9/manual/en/advanced-topics/oc-reflection.html


#8

Thank you for this. It is really helpful. But if you work for voodoo you are required to record * GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "Begin) and th end with the score, that is why i asked, but i guess that oc-reflection should work


#9

@Andres_IC himm okay,
oc-reflection will be work for you. I’m already using for Applovin and some native functions (like vibration, etc.)


#10

Hey friends!

I’ve managed to run “Gameanalytics JS SDK” on Cocos Creator for all platforms (not just for HTML5). Tested on Android and Win32.

gameanalytics.zip (23.6 KB)

This is the modified version of “GameAnalytics.node.js” in JS SDK.

Normally it requires window.navigator for several functions but we don’t have in Cocos Creator.
I’ve defined them with regular data:

navigator.appName = …
navigator.appVersion = …
navigator.userAgent = …
navigator.vendor = …
navigator.platform = …

replaced “localStorage” with “cc.sys.localStorage” and several fixes.

Usage:

//Require at the beginning of your component script
require("gameanalytics"); // defines window.ga for global usage

// then you can use like this:
ga.GameAnalytics.setEnabledInfoLog(true);
ga.GameAnalytics.initialize("...", "...");
ga.GameAnalytics.addProgressionEvent(ga.EGAProgressionStatus.Start, "World01", "Level01","Section01");
...
// you can check any time if it initialized correctly 
if (  ga.GameAnalytics.isSdkReady(true, false) ){
     // do whatever you want
}
...
// For example you can put these lines into onLoad function of your component:
// Game goes background
cc.game.on(cc.game.EVENT_HIDE, function () {
    ga.GameAnalytics.endSessionImmediate(); // End session
}.bind(this));

// Game comes foreground
cc.game.on(cc.game.EVENT_SHOW, function () {
    ga.GameAnalytics.startSession(); // Start session
}.bind(this))

Let me know what do you think?


#11

This should be integrated or pinned


#12

how can i used it with typescript?


#13

I don’t have any experience on typescript.