From a51fc78ac1055d24fe68d8d091fedd148302c1e5 Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Wed, 21 Oct 2020 10:42:29 +0800 Subject: [PATCH] TalkingDataSDK --- Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs | 75 ++ Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs.meta | 11 Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm | 148 +++++ Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h | 221 ++++++++ Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a | 0 Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs.meta | 11 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts.meta | 8 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs | 192 +++++++ Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar.meta | 32 + Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs.meta | 11 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs.meta | 11 Assets/Scripts/GameAnalytics_SDK.meta | 8 Assets/GameAnalytics_SDK_Unity-master.meta | 8 Assets/GameAnalytics_SDK_Unity-master/Plugins/Android.meta | 8 Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs | 20 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs.meta | 11 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs | 300 +++++++++++ Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h.meta | 27 + Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS.meta | 8 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs | 75 ++ Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs.meta | 11 Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar | 0 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs.meta | 11 Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml.meta | 7 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs | 194 +++++++ Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm.meta | 37 + Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml | 35 + Assets/GameAnalytics_SDK_Unity-master/Plugins.meta | 8 Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs | 55 ++ Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a.meta | 27 + 30 files changed, 1,570 insertions(+), 0 deletions(-) diff --git a/Assets/GameAnalytics_SDK_Unity-master.meta b/Assets/GameAnalytics_SDK_Unity-master.meta new file mode 100644 index 0000000..65b05e7 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de25701b8d5d6b944bee2215ef0980ce +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins.meta new file mode 100644 index 0000000..b6df7be --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e7af4c4551cf36b4fa032c5a562e8e37 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android.meta new file mode 100644 index 0000000..87c3c94 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82456dd283a56264d92902ae50e06456 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml new file mode 100644 index 0000000..299c8af --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest + xmlns:android="http://schemas.android.com/apk/res/android" + package="com.unity3d.player" + android:installLocation="preferExternal" + android:versionCode="1" + android:versionName="1.0"> + <uses-permission android:name="android.permission.INTERNET"/> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> + <uses-permission android:name="android.permission.READ_PHONE_STATE"/> + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> + <supports-screens + android:smallScreens="true" + android:normalScreens="true" + android:largeScreens="true" + android:xlargeScreens="true" + android:anyDensity="true"/> + <application + android:icon="@drawable/app_icon" + android:label="@string/app_name" + android:debuggable="true"> + <activity + android:name="com.unity3d.player.UnityPlayerActivity" + android:label="@string/app_name" + android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + <meta-data android:name="android.app.lib_name" android:value="unity"/> + <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false"/> + </activity> + </application> +</manifest> diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml.meta new file mode 100644 index 0000000..841d2fa --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/AndroidManifest.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e3bc83592a8aef948b12ab9dcb107545 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar new file mode 100644 index 0000000..77b7846 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar Binary files differ diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar.meta new file mode 100644 index 0000000..edd4e4c --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/Android/SaaS_GameAnalytics_Android_SDK_V4.0.58.jar.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: add9cd1b03eb89c4c99bf8647a921ba9 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS.meta new file mode 100644 index 0000000..8f3356c --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b356fcd9d935a2842bea213816d11314 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h new file mode 100644 index 0000000..3e06e04 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h @@ -0,0 +1,221 @@ +// +// TalkingDataGA.h +// TalkingDataGA +// +// Created by Biao Hou on 11-11-14. +// Copyright (c) 2011年 tendcloud. All rights reserved. +// + +#import <Foundation/Foundation.h> + + +// 账户类型 +typedef enum { + kAccountAnonymous = 0, // 匿名账户 + kAccountRegistered = 1, // 显性注册账户 + kAccountSinaWeibo = 2, // 新浪微博 + kAccountQQ = 3, // QQ账户 + kAccountTencentWeibo = 4, // 腾讯微博 + kAccountND91 = 5, // 91账户 + kAccountTypeWeiXin = 6, // 微信 + kAccountType1 = 11, // 预留1 + kAccountType2 = 12, // 预留2 + kAccountType3 = 13, // 预留3 + kAccountType4 = 14, // 预留4 + kAccountType5 = 15, // 预留5 + kAccountType6 = 16, // 预留6 + kAccountType7 = 17, // 预留7 + kAccountType8 = 18, // 预留8 + kAccountType9 = 19, // 预留9 + kAccountType10 = 20 // 预留10 +} TDGAAccountType; + +// 性别 +typedef enum { + kGenderUnknown = 0, // 未知 + kGenderMale = 1, // 男 + kGenderFemale = 2 // 女 +} TDGAGender; + + + + + +@interface TalkingDataGA: NSObject + +/** + * @method getDeviceId 获取设备id + */ ++ (NSString *)getDeviceId; + +/** + * @method setVerboseLogDisabled 设置不显示日志 如发布时不需显示日志,应当最先调用该方法 + */ ++ (void)setVerboseLogDisabled; + +/** + * @method backgroundSessionEnabled + * 开启后台使用时长统计,需在SDK初始化之前调用。 + */ ++ (void)backgroundSessionEnabled; + +/** + * @method onStart 初始化统计实例 请在application:didFinishLaunchingWithOptions:方法里调用 + * @param appId appId 类型:NSString 应用的唯一标识,统计后台注册得到 + * @param channelId 渠道名(可选) 类型:NSString 如“app store” + */ ++ (void)onStart:(NSString *)appId withChannelId:(NSString *)channelId; + +/** + * @method onEvent 自定义事件 + * @param eventId 事件ID 类型:NSString + * @param eventData 事件参数 类型:键值对(key只支持NSString, value支持NSString和NSNumber) + */ ++ (void)onEvent:(NSString *)eventId eventData:(NSDictionary *)eventData; + +/** + * @method setLatitude 设置经纬度 + * @param latitude 纬度 类型:double + * @param longitude 经度 类型:double + */ ++ (void)setLatitude:(double)latitude longitude:(double)longitude; + + +@end + + + + + +@interface TDGAAccount : NSObject + +/** + * @method setAccount 设置账户 + * @param accountId 账户ID 类型:NSString + */ ++ (TDGAAccount *)setAccount:(NSString *)accountId; + +/** + * @method setAccountName 设置账户名称 + * @param accountName 账户名称 类型:NSString + */ +- (void)setAccountName:(NSString *)accountName; + +/** + * @method setAccountType 设置账户类型 + * @param accountType 账户类型 类型TDGAAccountType + */ +- (void)setAccountType:(TDGAAccountType)accountType; + +/** + * @method setLevel 设置账户等级 + * @param level 升级之后的等级 类型:int + */ +- (void)setLevel:(int)level; + +/** + * @method setGender 设置性别 + * @param gender 性别 类型:TDGAGender + */ +- (void)setGender:(TDGAGender)gender; + +/** + * @method setAge 设置年龄 + * @param age 年龄 类型:int + */ +- (void)setAge:(int)age; + +/** + * @method setGameServer 设置区服 + * @param gameServer 区服 类型:NSString + */ +- (void)setGameServer:(NSString *)gameServer; + +@end + + + + + +@interface TDGAMission : NSObject + +/** + * @method onBegin 开始一项任务 + * @param missionId 任务名称 类型:NSString + */ ++ (void)onBegin:(NSString *)missionId; + +/** + * @method onCompleted 完成一项任务 + * @param missionId 任务名称 类型:NSString + */ ++ (void)onCompleted:(NSString *)missionId; + +/** + * @method onFailed 一项任务失败 + * @param missionId 任务名称 类型:NSString + * @param cause 失败原因 类型:NSString + */ ++ (void)onFailed:(NSString *)missionId failedCause:(NSString *)cause; + +@end + + + + + +@interface TDGAVirtualCurrency : NSObject + +/** + * @method onChargeRequst 虚拟币充值请求 + * @param orderId 订单id 类型:NSString + * @param iapId 充值包id 类型:NSString + * @param currencyAmount 现金金额 类型:double + * @param currencyType 币种 类型:NSString + * @param virtualCurrencyAmount 虚拟币金额 类型:double + * @param paymentType 支付类型 类型:NSString + */ ++ (void)onChargeRequst:(NSString *)orderId + iapId:(NSString *)iapId + currencyAmount:(double)currencyAmount + currencyType:(NSString *)currencyType + virtualCurrencyAmount:(double)virtualCurrencyAmount + paymentType:(NSString *)paymentType; + +/** + * @method onChargeRequst 虚拟币充值请求 + * @param orderId 订单id 类型:NSString + */ ++ (void)onChargeSuccess:(NSString *)orderId; + +/** + * @method onReward 虚拟币赠送 + * @param virtualCurrencyAmount 虚拟币金额 类型:double + * @param reason 赠送虚拟币的原因 类型:NSString + */ ++ (void)onReward:(double)virtualCurrencyAmount reason:(NSString *)reason; + +@end + + + + + +@interface TDGAItem : NSObject + +/** + * @method onPurchase 虚拟物品购买 + * @param item 道具 类型:NSString + * @param number 道具个数 类型:int + * @param price 道具单价 类型:double + */ ++ (void)onPurchase:(NSString *)item itemNumber:(int)number priceInVirtualCurrency:(double)price; + +/** + * @method onPurchase 虚拟物品消耗 + * @param item 道具 类型:NSString + * @param number 道具个数 类型:int + */ ++ (void)onUse:(NSString *)item itemNumber:(int)number; + +@end diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h.meta new file mode 100644 index 0000000..270cf0f --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 03dcd950819986f40819faff06cef7d4 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm new file mode 100644 index 0000000..f7a5e76 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm @@ -0,0 +1,148 @@ +#import "TalkingDataGA.h" + +//#define TDGA_CUSTOM // 自定义事件 +//#define TDGA_PUSH // 推送营销 + +// Converts C style string to NSString +static NSString *TDGACreateNSString(const char *string) { + return string ? [NSString stringWithUTF8String:string] : nil; +} + +static char *tdgaDeviceId = NULL; +static TDGAAccount *tdgaAccount = nil; + +extern "C" { +#pragma GCC diagnostic ignored "-Wmissing-prototypes" + +const char *TDGAGetDeviceId() { + if (!tdgaDeviceId) { + NSString *deviceId = [TalkingDataGA getDeviceId]; + tdgaDeviceId = (char *)calloc(deviceId.length + 1, sizeof(char)); + strcpy(tdgaDeviceId, deviceId.UTF8String); + } + return tdgaDeviceId; +} + +void TDGASetVerboseLogDisabled() { + [TalkingDataGA setVerboseLogDisabled]; +} + +void TDGABackgroundSessionEnabled() { + [TalkingDataGA backgroundSessionEnabled]; +} + +void TDGAOnStart(const char *appId, const char *channelId) { + if ([TalkingDataGA respondsToSelector:@selector(setFrameworkTag:)]) { + [TalkingDataGA performSelector:@selector(setFrameworkTag:) withObject:@2]; + } + [TalkingDataGA onStart:TDGACreateNSString(appId) withChannelId:TDGACreateNSString(channelId)]; +} + +void TDGASetLocation(double latitude, double longitude) { + [TalkingDataGA setLatitude:latitude longitude:longitude]; +} + +void TDGASetAccount(const char *accountId) { + tdgaAccount = [TDGAAccount setAccount:TDGACreateNSString(accountId)]; +} + +void TDGASetAccountName(const char *accountName) { + if (nil != tdgaAccount) { + [tdgaAccount setAccountName:TDGACreateNSString(accountName)]; + } +} + +void TDGASetAccountType(int accountType) { + if (nil != tdgaAccount) { + [tdgaAccount setAccountType:(TDGAAccountType)accountType]; + } +} + +void TDGASetLevel(int level) { + if (nil != tdgaAccount) { + [tdgaAccount setLevel:level]; + } +} + +void TDGASetGender(int gender) { + if (nil != tdgaAccount) { + [tdgaAccount setGender:(TDGAGender)gender]; + } +} + +void TDGASetAge(int age) { + if (nil != tdgaAccount) { + [tdgaAccount setAge:age]; + } +} + +void TDGASetGameServer(const char *gameServer) { + if (nil != tdgaAccount) { + [tdgaAccount setGameServer:TDGACreateNSString(gameServer)]; + } +} + +void TDGAOnBegin(const char *missionId) { + [TDGAMission onBegin:TDGACreateNSString(missionId)]; +} + +void TDGAOnCompleted(const char *missionId) { + [TDGAMission onCompleted:TDGACreateNSString(missionId)]; +} + +void TDGAOnFailed(const char *missionId, const char *failedCause) { + [TDGAMission onFailed:TDGACreateNSString(missionId) failedCause:TDGACreateNSString(failedCause)]; +} + +void TDGAOnChargeRequst(const char *orderId, const char *iapId, double currencyAmount, const char *currencyType, double virtualCurrencyAmount, const char *paymentType) { + [TDGAVirtualCurrency onChargeRequst:TDGACreateNSString(orderId) + iapId:TDGACreateNSString(iapId) + currencyAmount:currencyAmount + currencyType:TDGACreateNSString(currencyType) + virtualCurrencyAmount:virtualCurrencyAmount + paymentType:TDGACreateNSString(paymentType)]; +} + +void TDGAOnChargSuccess(const char *orderId) { + [TDGAVirtualCurrency onChargeSuccess:TDGACreateNSString(orderId)]; +} + +void TDGAOnReward(double virtualCurrencyAmount, const char *reason) { + [TDGAVirtualCurrency onReward:virtualCurrencyAmount reason:TDGACreateNSString(reason)]; +} + +void TDGAOnPurchase(const char *item, int itemNumber, double priceInVirtualCurrency) { + [TDGAItem onPurchase:TDGACreateNSString(item) itemNumber:itemNumber priceInVirtualCurrency:priceInVirtualCurrency]; +} + +void TDGAOnUse(const char *item, int itemNumber) { + [TDGAItem onUse:TDGACreateNSString(item) itemNumber:itemNumber]; +} + +#ifdef TDGA_CUSTOM +void TDGAOnEvent(const char *eventId, const char *parameters) { + NSString *parameterStr = TDGACreateNSString(parameters); + NSDictionary *parameterDic = nil; + if (parameterStr) { + NSData *parameterData = [parameterStr dataUsingEncoding:NSUTF8StringEncoding]; + parameterDic = [NSJSONSerialization JSONObjectWithData:parameterData options:0 error:nil]; + } + [TalkingDataGA onEvent:TDGACreateNSString(eventId) eventData:parameterDic]; +} +#endif + +#ifdef TDGA_PUSH +void TDGASetDeviceToken(const void *deviceToken, int length) { + NSData *tokenData = [NSData dataWithBytes:deviceToken length:length]; + [TalkingDataGA setDeviceToken:tokenData]; +} + +void TDGAHandlePushMessage(const char *message) { + NSString *val = TDGACreateNSString(message); + NSDictionary *dic = [NSDictionary dictionaryWithObject:val forKey:@"sign"]; + [TalkingDataGA handleTDGAPushMessage:dic]; +} +#endif + +#pragma GCC diagnostic warning "-Wmissing-prototypes" +} diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm.meta new file mode 100644 index 0000000..2a24e15 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/TalkingDataGA.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: c56d719ffb60a5a499e55d8afa2cb174 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a new file mode 100644 index 0000000..e3ce2c3 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a Binary files differ diff --git a/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a.meta b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a.meta new file mode 100644 index 0000000..527050c --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/Plugins/iOS/libTalkingDataGA.a.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: fbb6b7a979503004892cf0546a5e4697 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts.meta b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts.meta new file mode 100644 index 0000000..f9c7f52 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30875c9bc5364144c9c4be6f607d5c54 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs new file mode 100644 index 0000000..8e5e307 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs @@ -0,0 +1,192 @@ +using UnityEngine; +#if UNITY_IPHONE +using System.Runtime.InteropServices; +#endif + + +public enum AccountType +{ + ANONYMOUS = 0, + REGISTERED = 1, + SINA_WEIBO = 2, + QQ = 3, + QQ_WEIBO = 4, + ND91 = 5, + WEIXIN = 6, + TYPE1 = 11, + TYPE2 = 12, + TYPE3 = 13, + TYPE4 = 14, + TYPE5 = 15, + TYPE6 = 16, + TYPE7 = 17, + TYPE8 = 18, + TYPE9 = 19, + TYPE10 = 20 +} + +public enum Gender +{ + UNKNOW = 0, + MALE = 1, + FEMALE = 2 +} + + +public class TDGAAccount +{ + private static TDGAAccount account; + +#if UNITY_ANDROID + private static readonly string ACCOUNT_CLASS = "com.tendcloud.tenddata.TDGAAccount"; + private static AndroidJavaClass accountClass; + private AndroidJavaObject mAccount; +#endif + +#if UNITY_IPHONE + [DllImport("__Internal")] + private static extern void TDGASetAccount(string accountId); + + [DllImport("__Internal")] + private static extern void TDGASetAccountName(string accountName); + + [DllImport("__Internal")] + private static extern void TDGASetAccountType(int accountType); + + [DllImport("__Internal")] + private static extern void TDGASetLevel(int level); + + [DllImport("__Internal")] + private static extern void TDGASetGender(int gender); + + [DllImport("__Internal")] + private static extern void TDGASetAge(int age); + + [DllImport("__Internal")] + private static extern void TDGASetGameServer(string gameServer); +#endif + + public static TDGAAccount SetAccount(string accountId) + { + if (account == null) + { + account = new TDGAAccount(); + } + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (accountClass == null) + { + accountClass = new AndroidJavaClass(ACCOUNT_CLASS); + } + account.mAccount = accountClass.CallStatic<AndroidJavaObject>("setAccount", accountId); +#endif +#if UNITY_IPHONE + TDGASetAccount(accountId); +#endif + } + return account; + } + + public void SetAccountName(string accountName) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (mAccount != null) + { + mAccount.Call("setAccountName", accountName); + } +#endif +#if UNITY_IPHONE + TDGASetAccountName(accountName); +#endif + } + } + + public void SetAccountType(AccountType type) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (mAccount != null) + { + AndroidJavaClass enumClass = new AndroidJavaClass("com.tendcloud.tenddata.TDGAAccount$AccountType"); + AndroidJavaObject obj = enumClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString()); + mAccount.Call("setAccountType", obj); + enumClass.Dispose(); + } +#endif +#if UNITY_IPHONE + TDGASetAccountType((int)type); +#endif + } + } + + public void SetLevel(int level) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (mAccount != null) + { + mAccount.Call("setLevel", level); + } +#endif +#if UNITY_IPHONE + TDGASetLevel(level); +#endif + } + } + + public void SetAge(int age) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (mAccount != null) + { + mAccount.Call("setAge", age); + } +#endif +#if UNITY_IPHONE + TDGASetAge(age); +#endif + } + } + + public void SetGender(Gender type) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (mAccount != null) + { + AndroidJavaClass enumClass = new AndroidJavaClass("com.tendcloud.tenddata.TDGAAccount$Gender"); + AndroidJavaObject obj = enumClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString()); + mAccount.Call("setGender", obj); + enumClass.Dispose(); + } +#endif +#if UNITY_IPHONE + TDGASetGender((int)type); +#endif + } + } + + public void SetGameServer(string gameServer) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (mAccount != null) + { + mAccount.Call("setGameServer", gameServer); + } +#endif +#if UNITY_IPHONE + TDGASetGameServer(gameServer); +#endif + } + } +} diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs.meta b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs.meta new file mode 100644 index 0000000..47778c5 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAAccount.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f5938320f28c6c1449a4da4305805dc8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs new file mode 100644 index 0000000..e711697 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs @@ -0,0 +1,194 @@ +using UnityEngine; +using System.Collections.Generic; + +public class TDGADemoScript : MonoBehaviour +{ + private const int top = 100; + private const int left = 80; + private const int height = 50; + private readonly int width = Screen.width - (left * 2); + private const int step = 60; + private string deviceId; + private string oaid; + private TDGAAccount account; + private int index = 1; + private int level = 1; + + private void OnGUI() + { + int i = 0; + GUI.Box(new Rect(10, 10, Screen.width - 20, Screen.height - 20), "Demo Menu"); + + GUI.Label(new Rect(left, top + (step * i++), width, height), deviceId); + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "getDeviceId")) + { + deviceId = TalkingDataGA.GetDeviceId(); + } + + GUI.Label(new Rect(left, top + (step * i++), width, height), oaid); + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "getOAID")) + { + oaid = TalkingDataGA.GetOAID(); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "SetLocation")) + { + TalkingDataGA.SetLocation(39.94, 116.43); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Create Account")) + { + account = TDGAAccount.SetAccount("User" + index++); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Account Name")) + { + if (account != null) + { + account.SetAccountName("name"); + } + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Account Type")) + { + if (account != null) + { + account.SetAccountType(AccountType.WEIXIN); + } + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Level")) + { + if (account != null) + { + account.SetLevel(level++); + } + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Gender")) + { + if (account != null) + { + account.SetGender(Gender.MALE); + } + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Age")) + { + if (account != null) + { + account.SetAge(21); + } + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Set Game Server")) + { + if (account != null) + { + account.SetGameServer("server1"); + } + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Mission Begin")) + { + TDGAMission.OnBegin("miss001"); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Mission Completed")) + { + TDGAMission.OnCompleted("miss001"); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Mission Failed")) + { + TDGAMission.OnFailed("miss001", "failed"); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Charge Request")) + { + TDGAVirtualCurrency.OnChargeRequest("order01", "iap", 10, "CNY", 10, "UnionPay"); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Charge Success")) + { + TDGAVirtualCurrency.OnChargeSuccess("order01"); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Reward")) + { + TDGAVirtualCurrency.OnReward(100, "reason"); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Item Purchase")) + { + TDGAItem.OnPurchase("itemid001", 10, 10); + } + + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Item Use")) + { + TDGAItem.OnUse("itemid001", 1); + } + +#if TDGA_CUSTOM + if (GUI.Button(new Rect(left, top + (step * i++), width, height), "Custome Event")) + { + Dictionary<string, object> dic = new Dictionary<string, object> + { + { "StringValue", "Pi" }, + { "NumberValue", 3.14 } + }; + TalkingDataGA.OnEvent("action_id", dic); + } +#endif + } + + private void Start() + { + Debug.Log("Start"); + //TalkingDataGA.SetVerboseLogDisabled(); + TalkingDataGA.BackgroundSessionEnabled(); + TalkingDataGA.OnStart("your_app_id", "your_channel_id"); + account = TDGAAccount.SetAccount("User" + index++); +#if TDGA_PUSH +#if UNITY_IPHONE + UnityEngine.iOS.NotificationServices.RegisterForNotifications( + UnityEngine.iOS.NotificationType.Alert | + UnityEngine.iOS.NotificationType.Badge | + UnityEngine.iOS.NotificationType.Sound); +#endif +#endif + } + + private void Update() + { + if (Input.GetKey(KeyCode.Escape)) + { + Application.Quit(); + } +#if TDGA_PUSH + TalkingDataGA.SetDeviceToken(); + TalkingDataGA.HandlePushMessage(); +#endif + } + + private void OnDestroy() + { + Debug.Log("onDestroy"); + TalkingDataGA.OnEnd(); + } + + private void Awake() + { + Debug.Log("Awake"); + } + + private void OnEnable() + { + Debug.Log("OnEnable"); + } + + private void OnDisable() + { + Debug.Log("OnDisable"); + } +} diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs.meta b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs.meta new file mode 100644 index 0000000..e3c503c --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGADemoScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7f8ff66103660e04096defa0bf88ae0b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs new file mode 100644 index 0000000..9e409b1 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs @@ -0,0 +1,55 @@ +using UnityEngine; +#if UNITY_IPHONE +using System.Runtime.InteropServices; +#endif + + +public static class TDGAItem +{ +#if UNITY_ANDROID + private static readonly string ITEM_CLASS = "com.tendcloud.tenddata.TDGAItem"; + private static AndroidJavaClass itemClass; +#endif + +#if UNITY_IPHONE + [DllImport("__Internal")] + private static extern void TDGAOnPurchase(string item, int itemNumber, double priceInVirtualCurrency); + + [DllImport("__Internal")] + private static extern void TDGAOnUse(string item, int itemNumber); +#endif + + public static void OnPurchase(string item, int itemNumber, double priceInVirtualCurrency) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (itemClass == null) + { + itemClass = new AndroidJavaClass(ITEM_CLASS); + } + itemClass.CallStatic("onPurchase", item, itemNumber, priceInVirtualCurrency); +#endif +#if UNITY_IPHONE + TDGAOnPurchase(item, itemNumber, priceInVirtualCurrency); +#endif + } + } + + public static void OnUse(string item, int itemNumber) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (itemClass == null) + { + itemClass = new AndroidJavaClass(ITEM_CLASS); + } + itemClass.CallStatic("onUse", item, itemNumber); +#endif +#if UNITY_IPHONE + TDGAOnUse(item, itemNumber); +#endif + } + } +} diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs.meta b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs.meta new file mode 100644 index 0000000..497c8a6 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAItem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6feaa464da53aeb4e9755aa3835fa1bb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs new file mode 100644 index 0000000..e581cba --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs @@ -0,0 +1,75 @@ +using UnityEngine; +#if UNITY_IPHONE +using System.Runtime.InteropServices; +#endif + + +public static class TDGAMission +{ +#if UNITY_ANDROID + private static readonly string MISSION_CLASS = "com.tendcloud.tenddata.TDGAMission"; + private static AndroidJavaClass missionClass; +#endif + +#if UNITY_IPHONE + [DllImport("__Internal")] + private static extern void TDGAOnBegin(string missionId); + + [DllImport("__Internal")] + private static extern void TDGAOnCompleted(string missionId); + + [DllImport("__Internal")] + private static extern void TDGAOnFailed(string missionId, string failedCause); +#endif + + public static void OnBegin(string missionId) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (missionClass == null) + { + missionClass = new AndroidJavaClass(MISSION_CLASS); + } + missionClass.CallStatic("onBegin", missionId); +#endif +#if UNITY_IPHONE + TDGAOnBegin(missionId); +#endif + } + } + + public static void OnCompleted(string missionId) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (missionClass == null) + { + missionClass = new AndroidJavaClass(MISSION_CLASS); + } + missionClass.CallStatic("onCompleted", missionId); +#endif +#if UNITY_IPHONE + TDGAOnCompleted(missionId); +#endif + } + } + + public static void OnFailed(string missionId, string failedCause) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (missionClass == null) + { + missionClass = new AndroidJavaClass(MISSION_CLASS); + } + missionClass.CallStatic("onFailed", missionId, failedCause); +#endif +#if UNITY_IPHONE + TDGAOnFailed(missionId, failedCause); +#endif + } + } +} diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs.meta b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs.meta new file mode 100644 index 0000000..f958b9c --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAMission.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ab4657863462fb498c66c0c75a76abb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs new file mode 100644 index 0000000..661c64f --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs @@ -0,0 +1,75 @@ +using UnityEngine; +#if UNITY_IPHONE +using System.Runtime.InteropServices; +#endif + + +public static class TDGAVirtualCurrency +{ +#if UNITY_ANDROID + private static readonly string VIRTUAL_CURRENCY_CLASS = "com.tendcloud.tenddata.TDGAVirtualCurrency"; + private static AndroidJavaClass virtualCurrencyClass; +#endif + +#if UNITY_IPHONE + [DllImport("__Internal")] + private static extern void TDGAOnChargeRequst(string orderId, string iapId, double currencyAmount, string currencyType, double virtualCurrencyAmount, string paymentType); + + [DllImport("__Internal")] + private static extern void TDGAOnChargSuccess(string orderId); + + [DllImport("__Internal")] + private static extern void TDGAOnReward(double virtualCurrencyAmount, string reason); +#endif + + public static void OnChargeRequest(string orderId, string iapId, double currencyAmount, string currencyType, double virtualCurrencyAmount, string paymentType) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (virtualCurrencyClass == null) + { + virtualCurrencyClass = new AndroidJavaClass(VIRTUAL_CURRENCY_CLASS); + } + virtualCurrencyClass.CallStatic("onChargeRequest", orderId, iapId, currencyAmount, currencyType, virtualCurrencyAmount, paymentType); +#endif +#if UNITY_IPHONE + TDGAOnChargeRequst(orderId, iapId, currencyAmount, currencyType, virtualCurrencyAmount, paymentType); +#endif + } + } + + public static void OnChargeSuccess(string orderId) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (virtualCurrencyClass == null) + { + virtualCurrencyClass = new AndroidJavaClass(VIRTUAL_CURRENCY_CLASS); + } + virtualCurrencyClass.CallStatic("onChargeSuccess", orderId); +#endif +#if UNITY_IPHONE + TDGAOnChargSuccess(orderId); +#endif + } + } + + public static void OnReward(double virtualCurrencyAmount, string reason) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (virtualCurrencyClass == null) + { + virtualCurrencyClass = new AndroidJavaClass(VIRTUAL_CURRENCY_CLASS); + } + virtualCurrencyClass.CallStatic("onReward", virtualCurrencyAmount, reason); +#endif +#if UNITY_IPHONE + TDGAOnReward(virtualCurrencyAmount, reason); +#endif + } + } +} diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs.meta b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs.meta new file mode 100644 index 0000000..8f7115b --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TDGAVirtualCurrency.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9913481a77e21104ca128daed6e97a1c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs new file mode 100644 index 0000000..9deac53 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs @@ -0,0 +1,300 @@ +using UnityEngine; +using System.Collections.Generic; +#if UNITY_ANDROID +using System; +#endif +#if UNITY_IPHONE +using System.Runtime.InteropServices; +using System.Collections; +#endif + + +public static class TalkingDataGA +{ +#if UNITY_ANDROID + private static readonly string GAME_ANALYTICS_CLASS = "com.tendcloud.tenddata.TalkingDataGA"; + private static AndroidJavaClass gameAnalyticsClass; + private static AndroidJavaClass unityPlayerClass; +#endif + +#if UNITY_IPHONE + [DllImport("__Internal")] + private static extern string TDGAGetDeviceId(); + + [DllImport("__Internal")] + private static extern void TDGASetVerboseLogDisabled(); + + [DllImport("__Internal")] + private static extern void TDGABackgroundSessionEnabled(); + + [DllImport("__Internal")] + private static extern void TDGAOnStart(string appId, string channelId); + + [DllImport("__Internal")] + private static extern void TDGASetLocation(double latitude, double longitude); + +#if TDGA_CUSTOM + [DllImport("__Internal")] + private static extern void TDGAOnEvent(string eventId, string parameters); +#endif + +#if TDGA_PUSH + [DllImport("__Internal")] + private static extern void TDGASetDeviceToken(byte[] deviceToken, int length); + + [DllImport("__Internal")] + private static extern void TDGAHandlePushMessage(string message); + + private static bool hasTokenBeenObtained = false; +#endif +#endif + +#if UNITY_ANDROID + private static AndroidJavaObject GetCurrentActivity() + { + if (unityPlayerClass == null) + { + unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + } + AndroidJavaObject activity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"); + return activity; + } +#endif + + private static string deviceId = null; + public static string GetDeviceId() + { + if (deviceId == null && Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (gameAnalyticsClass == null) + { + gameAnalyticsClass = new AndroidJavaClass(GAME_ANALYTICS_CLASS); + } + deviceId = gameAnalyticsClass.CallStatic<string>("getDeviceId", GetCurrentActivity()); +#endif +#if UNITY_IPHONE + deviceId = TDGAGetDeviceId(); +#endif + } + return deviceId; + } + + private static string oaid = null; + public static string GetOAID() + { + if (oaid == null && Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (gameAnalyticsClass == null) + { + gameAnalyticsClass = new AndroidJavaClass(GAME_ANALYTICS_CLASS); + } + oaid = gameAnalyticsClass.CallStatic<string>("getOAID", GetCurrentActivity()); +#endif + } + return oaid; + } + + public static void SetVerboseLogDisabled() + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (gameAnalyticsClass == null) + { + gameAnalyticsClass = new AndroidJavaClass(GAME_ANALYTICS_CLASS); + } + gameAnalyticsClass.CallStatic("setVerboseLogDisabled"); +#endif +#if UNITY_IPHONE + TDGASetVerboseLogDisabled(); +#endif + } + } + + public static void BackgroundSessionEnabled() + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_IPHONE + TDGABackgroundSessionEnabled(); +#endif + } + } + + public static void OnStart(string appId, string channelId) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { + Debug.Log("TalkingData Game Analytics Unity SDK."); +#if UNITY_ANDROID + using (AndroidJavaClass dz = new AndroidJavaClass("com.tendcloud.tenddata.game.dz")) + { + dz.SetStatic("a", 2); + } + if (gameAnalyticsClass == null) + { + gameAnalyticsClass = new AndroidJavaClass(GAME_ANALYTICS_CLASS); + } + AndroidJavaObject activity = GetCurrentActivity(); + gameAnalyticsClass.CallStatic("init", activity, appId, channelId); + gameAnalyticsClass.CallStatic("onResume", activity); +#endif +#if UNITY_IPHONE + TDGAOnStart(appId, channelId); +#endif + } + } + + public static void OnEnd() + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (gameAnalyticsClass != null) + { + gameAnalyticsClass.CallStatic("onPause", GetCurrentActivity()); + gameAnalyticsClass = null; + unityPlayerClass = null; + } +#endif + } + } + + public static void OnKill() + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (gameAnalyticsClass != null) + { + gameAnalyticsClass.CallStatic("onKill", GetCurrentActivity()); + gameAnalyticsClass = null; + unityPlayerClass = null; + } +#endif + } + } + + public static void SetLocation(double latitude, double longitude) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_IPHONE + TDGASetLocation(latitude, longitude); +#endif + } + } + +#if TDGA_CUSTOM + public static void OnEvent(string actionId, Dictionary<string, object> parameters) + { + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { +#if UNITY_ANDROID + if (gameAnalyticsClass != null) + { + if (parameters != null && parameters.Count > 0) + { + int count = parameters.Count; + AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap", count); + IntPtr method_Put = AndroidJNIHelper.GetMethodID(map.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + object[] args = new object[2]; + foreach (KeyValuePair<string, object> kvp in parameters) + { + args[0] = new AndroidJavaObject("java.lang.String", kvp.Key); + args[1] = typeof(string).IsInstanceOfType(kvp.Value) + ? new AndroidJavaObject("java.lang.String", kvp.Value) + : new AndroidJavaObject("java.lang.Double", "" + kvp.Value); + AndroidJNI.CallObjectMethod(map.GetRawObject(), method_Put, AndroidJNIHelper.CreateJNIArgArray(args)); + } + gameAnalyticsClass.CallStatic("onEvent", actionId, map); + map.Dispose(); + } + else + { + gameAnalyticsClass.CallStatic("onEvent", actionId, null); + } + } +#endif +#if UNITY_IPHONE + if (parameters != null && parameters.Count > 0) + { + string parameterStr = "{"; + foreach (KeyValuePair<string, object> kvp in parameters) + { + if (kvp.Value is string) + { + parameterStr += "\"" + kvp.Key + "\":\"" + kvp.Value + "\","; + } + else + { + try + { + double tmp = System.Convert.ToDouble(kvp.Value); + parameterStr += "\"" + kvp.Key + "\":" + tmp + ","; + } + catch (System.Exception) + { + } + } + } + parameterStr = parameterStr.TrimEnd(','); + parameterStr += "}"; + TDGAOnEvent(actionId, parameterStr); + } + else + { + TDGAOnEvent(actionId, null); + } +#endif + } + } +#endif + +#if TDGA_PUSH + public static void SetDeviceToken() + { +#if UNITY_IPHONE + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { + if (!hasTokenBeenObtained) + { + byte[] deviceToken = UnityEngine.iOS.NotificationServices.deviceToken; + if (deviceToken != null) + { + TDGASetDeviceToken(deviceToken, deviceToken.Length); + hasTokenBeenObtained = true; + } + } + } +#endif + } + + public static void HandlePushMessage() + { +#if UNITY_IPHONE + if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) + { + UnityEngine.iOS.RemoteNotification[] notifications = UnityEngine.iOS.NotificationServices.remoteNotifications; + if (notifications != null) + { + UnityEngine.iOS.NotificationServices.ClearRemoteNotifications(); + foreach (UnityEngine.iOS.RemoteNotification rn in notifications) + { + foreach (DictionaryEntry de in rn.userInfo) + { + if (de.Key.ToString().Equals("sign")) + { + string sign = de.Value.ToString(); + TDGAHandlePushMessage(sign); + } + } + } + } + } +#endif + } +#endif +} diff --git a/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs.meta b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs.meta new file mode 100644 index 0000000..8020594 --- /dev/null +++ b/Assets/GameAnalytics_SDK_Unity-master/TalkingDataScripts/TalkingDataGA.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86741d8a310c22043acd2efb90d305d1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameAnalytics_SDK.meta b/Assets/Scripts/GameAnalytics_SDK.meta new file mode 100644 index 0000000..1ab0572 --- /dev/null +++ b/Assets/Scripts/GameAnalytics_SDK.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de0eb25ec3cdf904097ce9ea3d1cddf0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs b/Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs new file mode 100644 index 0000000..a539c37 --- /dev/null +++ b/Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class GameAnalytics_SDK_Main : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + Debug.Log("Unity SDK init begin "); + TalkingDataGA.OnStart("B220F5C737384030947B202F19E32086", "TalkingData"); + Debug.Log("Unity SDK init completed "); + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs.meta b/Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs.meta new file mode 100644 index 0000000..a3c900f --- /dev/null +++ b/Assets/Scripts/GameAnalytics_SDK/GameAnalytics_SDK_Main.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aa7e26b9ba9db53469e7e713ad9dc7e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- Gitblit v1.9.1