public void OnFTApplicationPause(bool pauseStatus) { Debug.Log("OnApplicationPause = " + pauseStatus); isOnFTApplicationPause = true; if (!checkAvailable()) { return; } #if UNITY_IOS if (pauseStatus) { fGetUserInAppWithWay("out"); } else { fGetUserInAppWithWay("in"); } #elif UNITY_ANDROID if (pauseStatus) { FTDAndroid.onPause(); } else { FTDAndroid.onResume(); } #else Debug.Log(errorMsgPlatform); #endif }
/** * 设置Http回调 * */ public void setHttpCallback(FtHttpCallback ftHttpCallback) { Debug.Log("setHttpCallback success."); if (!checkAvailable()) { return; } #if UNITY_IOS // No action, iOS SDK is subscribed to iOS lifecycle notifications. #elif UNITY_ANDROID FTDAndroid.setHttpCallback(new FTDHttpCallback(ftHttpCallback)); #else Debug.Log(errorMsgPlatform); #endif }
/** * 道具使用事件 * * @param propid 道具ID > ham1 * @param propname 道具名称 > "锤子" * @param propnum 使用数量 > 1 * @param customParams */ public void trackPropUse(String propid, String propname, int propnum, Dictionary <String, String> customParams) { Debug.Log("trackPropUse . >>>>>" + "propid=" + propid + " || propname=" + propname + " || propnum=" + propnum + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fPropsToUse(propid, propname, propnum + "", dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.trackPropUse(propid, propname, propnum, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 完成关卡事件 * * @param isSuccess 是否成功 * @param level 关卡>12 * @param customParams 自定义参数,根据需要传入,不需要传null即可 */ public void trackLevelDone(bool isSuccess, String level, Dictionary <String, String> customParams) { Debug.Log("trackLevelDone . >>>>>" + "isSuccess=" + isSuccess + " || level=" + level + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fCompleteLevel(isSuccess + "", level, dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.trackLevelDone(isSuccess, level, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 登录关卡事件 * * @param level 关卡数>12 * @param way 登入/登出 > in/out * @param intime 登入时间(登出时为本次登入时间)>1541561218 * @param outtime 登出时间>1541561230 * @param customParams 自定义参数,根据需要传入,不需要传null即可 */ public void trackLevelIn(String level, String way, long intime, long outtime, Dictionary <String, String> customParams) { Debug.Log("trackLevelIn . >>>>>" + "level=" + level + " || way=" + way + " || intime=" + intime + " || outtime=" + outtime + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fLoginLevels(level, way, intime + "", outtime + "", dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.trackLevelIn(level, way, intime, outtime, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 广告点击事件上报 * * @param ad_app 内推:运营配置链接里app.appsflyer.com/和?之间的字符 * <p> * 第三方广告平台:0000000000 * @param ad_media_source 内推:运营配置链接里的参数pid * <p> * 第三方广告平台:广告平台名称,例如:Facebook/Vungle/Unity * @param ad_campaign 内推:运营配置链接里的参数c * <p> * 第三方广告平台:placementid * @param ad_channel 内推:运营配置链接里的参数af_channel * <p> * 第三方广告平台: 空值 * @param ad 内推:运营配置链接里的参数af_ad * <p> * 第三方广告平台:广告类型vedio/interstitial * @param customParams */ public void adClickEvent(String ad_app, String ad_media_source, String ad_campaign, String ad_channel, String ad, Dictionary <String, String> customParams) { Debug.Log("adClickEvent . >>>>>" + "ad_app=" + ad_app + "ad_media_source=" + ad_media_source + "ad_campaign=" + ad_campaign + "ad_channel=" + ad_channel + "ad=" + ad + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fGetUserADClick(ad_app, ad_media_source, ad_campaign, ad_channel, ad, dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.adClickEvent(ad_app, ad_media_source, ad_campaign, ad_channel, ad, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 自定义事件 * @param eventName 自定义事件名称 * @param eventId 自定义事件id * @param params 自定义事件参数 */ public void logCustomEvent(String eventName, String eventId, Dictionary <String, String> customParams) { Debug.Log("logCustomEvent . >>>>>" + "eventName=" + eventName + " || eventId=" + eventId + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fGetCustomEvent(eventName, eventId, dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.logCustomEvent(eventName, eventId, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 上报支付事件 * @param channel 支付渠道(注意这里并不是传广告渠道,而是支付渠道,比如google支付就可以是“google”,自己定义) * @param itemid 商品id * @param itemName 商品id * @param usdPrice 必须是美分价格,否则无法计算数据,必传数据 * @param price 支付金额(必须以“分”为单位) * @param currency 币种 * @param customParams 自定义参数,根据需要传入 */ public void logEventPurchase(String channel, String itemid, String itemName, int usdPrice, int price, String currency, Dictionary <String, String> customParams) { Debug.Log("logEventPurchase . >>>>>" + "channel=" + channel + " || itemid=" + itemid + " || itemName=" + itemName + " || usdPrice=" + usdPrice + " || price=" + price + " || currency=" + currency + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fTrackRevenueSuccese(itemid, itemName, usdPrice + "", price + "", currency, channel, dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.logEventPurchase(channel, itemid, itemName, usdPrice, price, currency, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 上报注册事件 * * @param registChannel 注册渠道 * @param name 注册用户名 * @param customParams 自定义参数,根据需要传入,不需要传null即可 */ public void logEventRegist(String registChannel, String name, Dictionary <String, String> customParams) { Debug.Log("logEventRegist . >>>>>" + "registChannel=" + registChannel + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fRegisteredSuccese(registChannel, name, dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.logEventRegist(registChannel, name, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 上报登录事件 * * @param loginChannel 登录渠道 * @param name 登录名称 * @param way 登入/登出 > in/out * @param intime 登入时间(登出时为本次登入时间)>1541561218 * @param outtime 登出时间>1541561230 * @param customParams 自定义参数,根据需要传入,不需要传null即可 */ public void logEventLogin(String loginChannel, String name, String way, long intime, long outtime, Dictionary <String, String> customParams) { Debug.Log("logEventLogin . >>>>>" + "loginChannel=" + loginChannel + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fLoginedSuccese(loginChannel, name, way, intime + "", outtime + "", dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.logEventLogin(loginChannel, name, way, intime, outtime, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 上报渠道SDK归因 * @param coversionData 渠道回调返回的归因 */ public void sendAttributeData(String channel, String jsonAttr) { Debug.Log("sendAttributeData . >>>>>" + "channel=" + channel + " || json=" + jsonAttr); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fGetAttributionReturnFromChannel(jsonAttr, channel); #elif UNITY_ANDROID FTDAndroid.sendAttributeData(channel, jsonAttr); #else Debug.Log(errorMsgPlatform); #endif }
/** * 设置归因回调 * */ public void setOnAttributeListener(FtOnattributeChangedListener changedListener) { Debug.Log("setOnAttributeListener success."); if (!checkAvailable()) { return; } FTDSdk.changedListener = changedListener; #if UNITY_IOS // No action, iOS SDK is subscribed to iOS lifecycle notifications. #elif UNITY_ANDROID FTDAndroid.setOnAttributeListener(new FTDAttributeCallback(changedListener)); #else Debug.Log(errorMsgPlatform); #endif }
/** * 完成加载事件上报 * * @param isSuccess 是否成功 * @param customParams 自定义参数,根据需要传入,不需要传null即可 */ public void trackEventLoading(bool isSuccess, Dictionary <String, String> customParams) { Debug.Log("trackEventLoading . >>>>>" + "isSuccess=" + isSuccess + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fFinishedLoading(isSuccess + "", dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.trackEventLoading(isSuccess, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 完成新手引导 * @param isSuccess 是否成功 * @param customParams 自定义参数,根据需要传入,不需要传null即可 */ public void logEventCompletedTutorial(bool isSuccess, Dictionary <String, String> customParams) { Debug.Log("logEventCompletedTutorial . >>>>>" + "isSuccess=" + isSuccess + " || customParams=" + dic2json(customParams)); checkOnlineMethod(); if (!checkAvailable()) { return; } #if UNITY_IOS fNewbieGuideSuccese(isSuccess + "", dic2json(customParams)); #elif UNITY_ANDROID FTDAndroid.logEventCompletedTutorial(isSuccess, customParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 初始化android api * */ public static void initAndroid(string appId, string appKey, string signWay) { Debug.Log("initAndroid."); if (IsEditor()) { return; } #if UNITY_ANDROID if (!checkInitParams(appId, appKey, signWay)) { return; } AndroidJavaObject currentActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject>("currentActivity"); FTDAndroid.ftdSdkInit(currentActivity, appId, appKey, signWay); isInit = true; #endif }
/** * 设置在线时长事件in/out 附加参数,有则更新,无则追加,暂不可删除 * * @param onlineTimeParams */ public void setOnlineTimeParams(Dictionary <String, String> onlineTimeParams) { if (onlineTimeParams == null) { return; } Debug.Log("onlineTimeParams . >>>>>" + "onlineTimeParams=" + dic2json(onlineTimeParams)); if (!checkAvailable()) { return; } #if UNITY_IOS fGetUserWithUserAttributes(dic2json(onlineTimeParams)); #elif UNITY_ANDROID FTDAndroid.setOnlineTimeParams(onlineTimeParams); #else Debug.Log(errorMsgPlatform); #endif }
/** * 设置tag接口,此TAG是标识在设备层级的tag,设置即会在tag数组中追加tag。新设置tag不会覆盖旧tag,且不可删除。 * 一旦设置每次数据上报都会通过通传参数发送给SDK服务器,服务器可根据tag对数据进行归类计算等。 * * @param tags */ public void setTags(String[] tags) { if (tags == null || tags.Length < 1) { return; } Debug.Log("setTags . >>>>>" + "tags=" + "[\"" + string.Join("\",\"", tags) + "\"]"); if (!checkAvailable()) { return; } #if UNITY_IOS string tagStr = "[\"" + string.Join("\",\"", tags) + "\"]"; fGetUserWithTags(tagStr); #elif UNITY_ANDROID FTDAndroid.setTags(tags); #else Debug.Log(errorMsgPlatform); #endif }