How can i add gameanalytics to my IOS build?

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

Did you find a solution?

Nop, i did not

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?

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

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?

  • 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

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

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

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?

This should be integrated or pinned

how can i used it with typescript?

I don’t have any experience on typescript.

I made game with cocos creator. And I want to build for IOS. So I bring game project on mac cocos creator engine and compile on simulator. And then Error occurred:
Simulator: Received signal 11 SEGV_MAPERR 0000000002f0
Why I should get it?
After it, I Build that. But I can do nothing.
I try build project in Xcode and then it can’t play on my iPad.
How do it?
I look forward your reply.
Thank you.