GithubHelp home page GithubHelp logo

isabella232 / appsflyer-cocos2dx-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from appsflyersdk/appsflyer-cocos2dx-plugin

0.0 0.0 0.0 23.35 MB

AppsFlyer Cocos2dX plugin

CMake 1.78% C++ 54.12% C 5.47% Objective-C 22.04% Objective-C++ 15.73% Makefile 0.40% Java 0.45%

appsflyer-cocos2dx-plugin's Introduction

Cocos2dX AppsFlyer plugin for Android and iOS.


In order for us to provide optimal support, we would kindly ask you to submit any issues to [email protected]

When submitting an issue please specify your AppsFlyer sign-up (account) email , your app ID , production steps, logs, code snippets and any additional relevant information.


Table of content

1. Set your Dev_Key and enable AppsFlyer to detect installations, sessions (app opens) and updates.

This is the minimum requirement to start measuring your app installs and is already implemented in this plugin. You MUST modify this call and provide: -devKey - Your application devKey provided by AppsFlyer. -appId - (For iOS only) Your iTunes Application ID.

Add the following lines into applicationDidFinishLaunching and to applicationWillEnterForeground method to be able to initialize measuring with your own AppsFlyer dev key:

#include "AppsFlyer/AppsFlyerX.h"

bool AppDelegate::applicationDidFinishLaunching() {
  AppsFlyerX::setAppsFlyerDevKey("YOUR_DEV_KEY");

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AppsFlyerX::setAppleAppID("942960987");
#endif
  
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    AppsFlyerX::start();
#endif
}

void AppDelegate::applicationWillEnterForeground() {
   //..
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    AppsFlyerX::start();
#endif
}

Also notify AppsFlyer SDK about background event:

void AppDelegate::applicationDidEnterBackground() {

    //...
    AppsFlyerX::didEnterBackground();
}

## API Methods


if true AppsFlyer SDK will run in debug mode

Example:

AppsFlyerX::setIsDebug(true);

if true AppsFlyer SDK will enter to pending mode, no activity Be sure to set stop(false) to release the SDK from stop measuring events

Example:

AppsFlyerX::stop(false); // or false

Use to prevent sharing data with some (one or more) networks/integrated partners.

parameter type description
eventName std::vector<std::string> list of partners

Example:

  std::vector<std::string> partners;
  partners.push_back("facebook_int");
  partners.push_back("googleadwords_int");
  AppsFlyerX::sharingFilter(partners);

Use to prevent sharing data with all networks/integrated partners.

Example:

AppsFlyerX::sharingFilterForAllPartners();

  • These in-app events help you track how loyal users discover your app, and attribute them to specific campaigns/media-sources. Please take the time define the event/s you want to measure to allow you to track ROI (Return on Investment) and LTV (Lifetime Value).
  • The logEvent method allows you to send in-app events to AppsFlyer analytics. This method allows you to add events dynamically by adding them directly to the application code.
parameter type description
eventName string custom event name, is presented in your dashboard. See the Event list HERE
eventValues cocos2d::ValueMap event details

Example:

//basic implementation
AppsFlyerX::logEvent(AFEventPurchase, {{ "key1", cocos2d::Value("value1")},
                                         { "key2", cocos2d::Value("value2")}});

//rich in-app-event implementation:
AppsFlyerX::logEvent(AFEventPurchase, {
                        { AFEventParamContentId, Value({Value("12344"), Value("98844"), Value("39944")})},
                        { AFEventParamCurrency, Value({Value(20), Value(11), Value(61)})},
                        { AFEventParamPrice, Value({Value(25), Value(50), Value(10)})},
                        { AFEventParamContentType, Value("ELECTRONIC")},
                        { AFEventParamCurrency, Value("USD")},
                        {AFEventParamRevenue, cocos2d::Value("10.67")}
                });

More info about rich in-app-events you can find HERE

AppsFlyer allows you to access the user attribution data in real-time directly at SDK level. It enables you to customize the landing page a user sees on the very first app open after a fresh app install.

To access AppsFlyer's conversion data from the Android SDK implement the ConversionDataListener callback:

Examples:

static void onConversionDataReceived(cocos2d::ValueMap installData) {}

static void onConversionDataRequestFailure(cocos2d::ValueMap map) {
/*has signature {
                 {"status": "failure"},
                 {"data", "errorMessage"}
                 }*/
}

static void onAppOpenAttribution(cocos2d::ValueMap map) {}

static void onAppOpenAttributionFailure(cocos2d::ValueMap map) {
/*has signature {
                 {"status": "failure"},
                 {"data", "errorMessage"}
                 }*/
}

AppsFlyerX::setOnConversionDataReceived(onConversionDataReceived);
AppsFlyerX::setOnConversionDataRequestFailure(onConversionDataRequestFailure);
AppsFlyerX::setOnAppOpenAttribution(onAppOpenAttribution);
AppsFlyerX::setOnAppOpenAttributionFailure(onAppOpenAttributionFailure);

AppsFlyer enables you to report one or more of the device’s associated email addresses. You must collect the email addresses and report it to AppsFlyer according to your required encryption method. The following encryption methods are available: SHA1, MD5, SHA256 and plain.

parameter type Default description
userEmails std::vector<std::string> --- list of emails
type EmailCryptTypeX --- crypt type: None, sha1, sha256, md5

Examples:

AppsFlyerX::setUserEmails({"[email protected]"}, XEmailCryptTypeSHA256);

Setting your own Custom ID enables you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs. This ID is available in AppsFlyer CSV reports along with postbacks APIs for cross-referencing with you internal IDs.

Note: The ID must be set during the first launch of the app at the SDK initialization. The best practice is to call this API during the deviceready event, where possible.

parameter type description
customerUserId const std::string&

Example:

AppsFlyerX::customerUserId("<USER_ID>");

parameter type Default description
currencyId const std::string& USD ISO 4217 Currency Codes

Examples:

AppsFlyerX::setCurrencyCode("<CURRENCY_ID>");

parameter type Default description
timeoutInterval double See additional info HERE

parameter type Default description
flag bool false disables AdvertiserIdentifier

Examples:

AppsFlyerX::disableAdvertiserIdentifier(true);

parameter type Default description
flag bool false enables/disables device name tracking

Examples:

AppsFlyerX::setShouldCollectDeviceName(true);

parameter type Default description
appInviteOneLinkID std::string& Before calling start in your app, set the OneLink which is invoked according to the OneLink ID. See additional info HERE

Examples:

AppsFlyerX::setAppInviteOneLink("8eOw");

parameter type Default description
flag bool false AppsFlyer provides you a method to opt-out specific users from AppsFlyer analytics. This method complies with the latest privacy requirements and complies with Facebook data and privacy policies. Default is false. Warning Opting out users SEVERELY hurts your attribution information. Use this option ONLY on regions which legally bind you from collecting your users' information.

Examples:

AppsFlyerX::anonymizeUser(true);

parameter type Default description
flag bool false enables/disables collect ASA

Examples:

AppsFlyerX::disableCollectASA(true);

parameter type Default description
flag bool false enables Receipt Validation Sandbox

Examples:

AppsFlyerX::setUseReceiptValidationSandbox(true);

parameter type Default description
flag bool false enables Uninstall Sandbox mode

Examples:

AppsFlyerX::setUseUninstallSandbox(true);

parameter type Default description
publicKey const std::string&
signature const std::string&
purchaseData const std::string&
price const std::string&
currency const std::string&
additionalParameters cocos2d::ValueMap

Examples:

ValueMap test_map;
test_map["key1"] = "value1";
std::string base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3dkBTr2pD2YSqSK2ewlEWwH9Llu0iA4PkwgVOyNRxOsHfrOlqi0Cm51qdNS0aqh/SMZkuQTAroqH3pAr9gVFOiejKRw+ymTaL5wB9+5n1mAbdeO2tv2FDsbawDvp7u6fIBejYt7Dtmih+kcu707fEO58HZWqgzx9qSHmrkMZr6yvHCtAhdBLwSBBjyhPHy7RAwKA+PE+HYVV2UNb5urqIZ9eI1dAv3RHX/xxHVHRJcjnTyMAqBmfFM+o31tp8/1CxGIazVN8HpVk8Qi2uqSS5HdKUu6VnIK8VuAHQbXQn4bG6GXx5Tp0SX1fKrejo7hupNUCgOlqsYHFYxsRkEOi0QIDAQAB";
std::string signature = "OaIdwQOcmrJrMKUx+URVy1I6aeKYiYzflkk1zIKVSs+dDv691neCbR+jlDDzVi3jfSkfirxQISxo7Pe1uzoYbpq9wBk/pMgVjjSbpvCojhA4d/Mwsf4mtAH2LJcVNjhMQdSWvGJlzva3OSt+KQ+9/pRJ15aYT2gFn3SpGSPxNxJmHPIOlM1Lr74MejVu9rnbcSjCB/oI0W4O58p9UWSt5MgmlpqlrK5YqTi1a1VnttY9r1IXFeltwZvmPbcWcYwRHFvemwYGX86huSOFBOYRfaYo9f+DinpoUoXKQEo0JrvKD2/dzFkbUTto1d2OPo1ddaYllgsb2UEV5wwFZFnemg==";
std::string purchaseData = "{\"orderId\":\"\",\"packageName\":\"com.appsflyer.testapp\",\"productId\":\"consumable\",\"purchaseTime\":1497531638107,\"purchaseState\":0,\"developerPayload\":\"2497525891514-5765886608164763986\",\"purchaseToken\":\"pfkalmpnnimamdllmincaida.AO-J1OymunlPCkDQZTf8bPcesoB0n1_ND3WFynoU91-v_R1Px46m3Q-DdRKNlxMVsP2pCTKpo1et1w1IpNVXQ8-zNpRo6a2nXP7a5fQWiDv2asL1dwJPCV8NghDHbstO084IlKo6xcgy\"}";
    
AppsFlyerX::validateAndLogInAppPurchase(base64EncodedPublicKey, 
                                          signature, 
                        "3.00",
                      "ILS",
                      test_map);

parameter type Default description
productIdentifier const std::string&
price const std::string&
currency const std::string&
tranactionId const std::string&
params cocos2d::ValueMap
successBlock std::function<void(cocos2d::ValueMap)>
failureBlock std::function<void(cocos2d::ValueMap)>

Examples:

ValueMap test_map;
test_map["key1"] = "value1";
std::string productIdentifier = "com.mycomp.inapppurchase.cons";
std::string tr_id = "1000000256672208";
  
AppsFlyerX::validateAndLogInAppPurchase(productIdentifier, 
                                          "1.99",
                                          "USD",
                                          tr_id
                      test_map, 
                      successBlock,
                      failureBlock);

Examples:

std::string appsflyerId = AppsFlyerX::getAppsFlyerUID();

  • void AppsFlyerX::handleOpenURL(const std::string& url, const std::string& sourceApplication)
  • void AppsFlyerX::handleOpenURL(std::string url, std::string sourceApplication, void* annotation)
  • void AppsFlyerX::handleOpenURL(std::string url, cocos2d::ValueMap options)

Examples:

TBD

Examples:

AppsFlyerX::registerUninstall("<TOKEN>");

For more Info see the DOCs

You can use the registerUninstall(void* deviceToken, unsigned long length) API.

or

As alternative way use directly native API: Open your Xcode project and locate the file AppController.mm under the iOS folder inside your project. Add the following code snippet under didFinishLaunchingWithOptions :

#import "AppsFlyerLib.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//...
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                    UIUserNotificationTypeBadge |
                                                    UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                             categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];
//..
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {    
    [[AppsFlyerLib shared] registerUninstall:deviceToken];
}

and method implementation:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {    
    [[AppsFlyerLib shared] registerUninstall:deviceToken];
}

parameter type Default description
host std::string& host name that should override appsflyer.com
Examples:
AppsFlyerX::setHost("mynewhost.com");

parameter type Default description
minTimeBetweenSessions unsigned long host name that should override appsflyer.com
Examples:
AppsFlyerX::setMinTimeBetweenSessions(9);

Allows to pass GCM/FCM Tokens that where collected by third party plugins to the AppsFlyer server. Can be used for Uninstall measuring.

parameter type description
token String GCM/FCM Token

In ver. >4.2.5 deeplinking metadata (scheme/host) is sent automatically TBD

TBD

Migration Guide to v6

Integration guide Migration guide In v6 of AppsFlyer SDK there are some api breaking changes:

Before v6 v6
trackAppLaunch start
trackEvent logEvent
trackLocation logLocation
stopTracking stop
validateAndTrackInAppPurchase validateAndLogInAppPurchase
setDeviceTrackingDisabled anonymizeUser

iOS

on iOS you need to implement IDFA request pop up and add AppTrackTransparency framework in order for the plugin to work

appsflyer-cocos2dx-plugin's People

Contributors

af-fess avatar af-margot avatar maxklebappsflyer avatar andr-ggn avatar benjaminaf avatar shaharaf avatar wesfieldj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.