#AnalyticX A C++ wrapper of Flurry for Cocos2d-X. Supports Android and iOS.
#Changelog
- Added reflection to AnalyticXStringUtil
- Updated Flurry iOS SDK to version 4.0.0
#Environment cocos2d-2.0-rc0a-x-0.1.0 or higher is recommended. Lower versions are not tested. Due to the underlying difference in the CCDictionary implementation, there may be compatibility issues when running on lower versions.
#Flurry SDK Version
- Android: v2.2.5
- iOS: v3.0.9
#Example Project
- iOS: ./AnalyticX.xcodeproj
- Android: ./AnalyticX/proj.android/
You need to change the build script (such as build_native.sh for Mac OSX) according to your own environment before compiling.
#Add to Your Own Project - iOS
- Add FlurryAnalytics.h and libFlurryAnalytics.a to your Xcode project
- Add AnalyticX.h and AnalyticX.mm to your Xcode project
- Add AnalyticXStringUtil.h and AnalyticXStringUtil.mm to your Xcode project
#Add to Your Own Project - Android
-
Add com.diwublog.AnalyticX the package and its AnalyticXBridge.java to your Eclipse project
-
Add FlurryAgent.jar as an external jar to your Eclipse project
-
Drop AnalyticX.h and AnalyticX.cpp to your Classes folder
-
Drop AnalyticXStringUtilAndroid and AnalyticXStringUtilAndroid.cpp to your Classes folder
-
Add AnalyticX.cpp and AnalyticXStringUtilAndroid.cpp to your jni's Android.mk
-
In the java implementation of your main activity (which should have been created by the Cocos2d-X script), import com.diwublog.AnalyticX.AnalyticXBridge
-
At the beginning of onCreate(Bundle savedInstanceState), right after super.onCreate(savedInstanceState), add one line:
AnalyticXBridge.sessionContext = this.getApplicationContext();
-
In the project manifest, add one line:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
#Add to Your Own Project - Hybrid
-
Follow the iOS and Android set up steps separately
-
iOS and Android will share the same AnalyticX.h header file
-
Use Separate Flurry Api Keys for Android and iOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) AnalyticX::flurryStartSession("YOUR_FLURRY_API_KEY_FOR_IPHONE_BUILD"); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) AnalyticX::flurryStartSession("YOUR_FLURRY_API_KEY_FOR_ANDROID_BUILD"); #endif
#APIs Supported on both Android and iOS static void flurrySetAppVersion(const char * version); static const char * flurryGetFlurryAgentVersion(); static void flurrySetDebugLogEnabled(bool value); static void flurrySetSessionContinueSeconds(int seconds);//The param is in second. Will be converted to millisecond internally. static void flurrySetSecureTransportEnabled(bool value);
static void flurryStartSession(const char * apiKey);
static void flurryLogEvent(const char * eventName);
static void flurryLogEventWithParameters(const char * eventName, cocos2d::CCDictionary * parameters);
static void flurryLogEventTimed(const char * eventName, bool timed);
static void flurryLogEventWithParametersTimed(const char * eventName, cocos2d::CCDictionary * parameters, bool timed);
static void flurryEndTimedEventWithParameters(const char * eventName, cocos2d::CCDictionary * parameters);
static void flurryLogPageView();
static void flurrySetUserID(const char * userID);
static void flurrySetAge(int age);
static void flurrySetGender(const char * gender);//"m" for male, "f" for female
#APIs Supported only on iOS When running on an Android device, these APIs will have no effect. They are safe and won't crash.
static void flurrySetShowErrorInLogEnabled(bool value);
static void flurrySetLatitudeLongitudeHorizontalAccuracyVerticalAccuracy(double latitude, double longitude, float horizontalAccuracy, float verticalAccuracy);
static void flurrySetSessionReportsOnCloseEnabled(bool sendSessionReportsOnClose);
static void flurrySetSessionReportsOnPauseEnabled(bool setSessionReportsOnPauseEnabled);
static void flurrySetEventLoggingEnabled(bool value);
#APIs Supported only on Android When running on an iOS device, these APIs will have no effect. They are safe and won't crash.
static void flurryEndSession();
static void flurrySetReportLocation(bool reportLocation);
#Email: diwufet@gmail.com #You're welcome to contribute. ;-)
#Contributors
- Di Wu
- Anton Turko
- François Dupayrat