예제 #1
0
    public static void SendUserEvent()
    {
        GA_Submit.CategoryType category = GA_Submit.CategoryType.GA_User;

        string os = "";

        string[] osSplit = SystemInfo.operatingSystem.Split(' ');
        if (osSplit.Length > 0)
        {
            os = osSplit[0];
        }

                #if UNITY_IPHONE
        bool idfa = CheckIDFA();
                #endif

        List <GA_Submit.Item> queue      = new List <GA_Submit.Item>();
        Hashtable             parameters = new Hashtable()
        {
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Platform], GA_GenericInfo.GetSystem() },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Device], SystemInfo.deviceModel },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Os], os },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.OsVersion], SystemInfo.operatingSystem },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Sdk], "GA Unity SDK " + GA_Settings.VERSION },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.InstallPublisher], "UnityVersion:" + UnityEditorInternal.InternalEditorUtility.GetFullUnityVersion() },
                        #if UNITY_IPHONE
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.InstallSite], "IDFA:" + idfa.ToString() },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.InstallCampaign], "iAD:" + EditorPrefs.GetBool("GA_IAD" + "-" + Application.dataPath, GA_Settings.IAD_DEFAULT) },
                        #endif
                        #if UNITY_IPHONE || UNITY_ANDROID
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.InstallAdgroup], "Chartboost:" + EditorPrefs.GetBool("GA_CB" + "-" + Application.dataPath, GA_Settings.CB_DEFAULT) },
                        #endif
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.UserID], _userID },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.SessionID], _sessionID },
            { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Build], GA_Settings.VERSION }
        };
        queue.Add(new GA_Submit.Item()
        {
            AddTime = 0, Count = 1, Type = category, Parameters = parameters
        });
        Dictionary <GA_Submit.CategoryType, List <GA_Submit.Item> > dict = new Dictionary <GA_Submit.CategoryType, List <GA_Submit.Item> >();
        dict.Add(category, queue);

        WWW www = GetEventWWW(category, parameters);
        GA_ContinuationManager.StartCoroutine(GA_Submit.SendWWW(www, Submitted, SubmitError, true, "", "", queue), () => www.isDone);
    }
예제 #2
0
    private bool AddUniqueIDs()
    {
        bool returnValue = false;

                #if !UNITY_EDITOR && UNITY_WEBPLAYER
        if (Application.absoluteURL.StartsWith("http"))
        {
            Application.ExternalEval(
                "try{var __scr = document.createElement('script'); __scr.setAttribute('async', 'true'); __scr.type = 'text/javascript'; __scr.src = 'https://d17ay18sztndlo.cloudfront.net/resources/js/ga_sdk_tracking.js'; ((document.getElementsByTagName('head') || [null])[0] || document.getElementsByTagName('script')[0].parentNode).appendChild(__scr);}catch(e){}"
                );
        }
                #endif

                #if !UNITY_EDITOR && UNITY_STANDALONE_WIN
        string device = "PC";
                #elif !UNITY_EDITOR
        string device = SystemInfo.deviceModel;
                #endif

                #if !UNITY_EDITOR
        string   os      = "";
        string[] osSplit = SystemInfo.operatingSystem.Split(' ');

                        #if UNITY_IPHONE
        if (osSplit.Length > 0)
        {
            os = "iOS " + osSplit[2].Substring(0, 1);
        }
                        #elif UNITY_ANDROID
        if (osSplit.Length > 0)
        {
            string[] osvSplit = osSplit[2].Split('.');
            os = osSplit[0] + " " + osvSplit[0] + "." + osvSplit[1];
        }
                        #else
        if (osSplit.Length > 0)
        {
            os = osSplit[0];
        }
                        #endif
                #endif

                #if UNITY_IPHONE && !UNITY_EDITOR && IOS_ID
        string   os_minor = "";
        string[] osmSplit = SystemInfo.operatingSystem.Split(' ');

        if (osmSplit.Length > 0)
        {
            os_minor = "iOS " + osmSplit[2];
        }

        try
        {
            string iOSid = GetUniqueIDiOS();
            if (iOSid != null && iOSid != string.Empty)
            {
                if (iOSid.StartsWith("VENDOR-"))
                {
                    GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, null, null, AutoSubmitUserInfo?GA_GenericInfo.GetSystem():null, AutoSubmitUserInfo?device:null, AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?os_minor:null, "GA Unity SDK " + VERSION, null);
                }
                else
                {
                    GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, iOSid, null, AutoSubmitUserInfo?GA_GenericInfo.GetSystem():null, AutoSubmitUserInfo?device:null, AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?os_minor:null, "GA Unity SDK " + VERSION, null);
                }

                returnValue = true;
            }
        }
        catch
        { }
                #elif UNITY_ANDROID && !UNITY_EDITOR
        string   os_minor = "";
        string[] osmSplit = SystemInfo.operatingSystem.Split(' ');

        if (osmSplit.Length > 0)
        {
            os_minor = osmSplit[0] + " " + osmSplit[2];
        }

        try
        {
            string androidAdID = GetAdvertisingIDAndroid();
            if (androidAdID != null && androidAdID != string.Empty)
            {
                GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, null, null, AutoSubmitUserInfo?GA_GenericInfo.GetSystem():null, AutoSubmitUserInfo?device:null, AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?os_minor:null, "GA Unity SDK " + VERSION, androidAdID);
                returnValue = true;
            }
        }
        catch
        { }
                #elif UNITY_FLASH && !UNITY_EDITOR
        GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, null, null, AutoSubmitUserInfo?GA_GenericInfo.GetSystem():null, "Flash", AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?SystemInfo.operatingSystem:null, "GA Unity SDK " + VERSION, null);
        returnValue = true;
                #elif !UNITY_EDITOR && !UNITY_IPHONE && !UNITY_ANDROID
        GA.API.User.NewUser(GA_User.Gender.Unknown, null, null, null, null, AutoSubmitUserInfo?GA_GenericInfo.GetSystem():null, AutoSubmitUserInfo?device:null, AutoSubmitUserInfo?os:null, AutoSubmitUserInfo?SystemInfo.operatingSystem:null, "GA Unity SDK " + VERSION, null);
        returnValue = true;
                #elif UNITY_IPHONE && UNITY_EDITOR && !IOS_ID
        GetUniqueIDiOS();
        returnValue = true;
                #elif UNITY_EDITOR
        returnValue = true;
                #endif

        return(returnValue);
    }