69 lines
1.5 KiB
C#
69 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using GameAnalyticsSDK;
|
|
|
|
|
|
public class AnalyticsInit : MonoBehaviour , IGameAnalyticsATTListener{
|
|
|
|
private bool _attDone = false;
|
|
|
|
public static readonly string TENJIN_API_KEY = "VCRGBQMHMGYPM2B5ITDHLSVIFTS8JQSW";
|
|
|
|
private void Awake() {
|
|
|
|
}
|
|
|
|
void Start () {
|
|
if(Application.platform == RuntimePlatform.IPhonePlayer){
|
|
GameAnalytics.RequestTrackingAuthorization(this);
|
|
}else{
|
|
InitAnalytics();
|
|
}
|
|
}
|
|
|
|
void Update(){
|
|
if(_attDone){
|
|
_attDone = false;
|
|
InitAnalytics();
|
|
}
|
|
|
|
}
|
|
|
|
void OnApplicationPause (bool pauseStatus){
|
|
if(pauseStatus){
|
|
//do nothing
|
|
}else{
|
|
TenjinConnect();
|
|
}
|
|
}
|
|
|
|
private void InitAnalytics(){
|
|
GameAnalytics.Initialize();
|
|
TenjinConnect();
|
|
}
|
|
|
|
private void TenjinConnect(){
|
|
#if !UNITY_EDITOR
|
|
BaseTenjin instance = Tenjin.getInstance(TENJIN_API_KEY);
|
|
instance.Connect();
|
|
#endif
|
|
}
|
|
|
|
//-- GameAnalytics --//
|
|
public void GameAnalyticsATTListenerNotDetermined(){
|
|
_attDone = true;
|
|
}
|
|
public void GameAnalyticsATTListenerRestricted(){
|
|
_attDone = true;
|
|
}
|
|
public void GameAnalyticsATTListenerDenied(){
|
|
_attDone = true;
|
|
}
|
|
public void GameAnalyticsATTListenerAuthorized(){
|
|
_attDone = true;
|
|
}
|
|
|
|
|
|
|
|
} |