예제 #1
0
    private void ReadGameStateFromCookie()
    {
#if !UNITY_EDITOR
        var results = CookieApi.GetInstantAppCookie();


        Debug.Log("readGameStateFromCookie: " + results);
        if (string.IsNullOrEmpty(results))
        {
            return;
        }
        var attributes = results.Split(',');
        if (attributes.Length < 2)
        {
            return;
        }

        var cookieLevel = attributes[0];
        var cookieScore = attributes[1];
        _level = int.Parse(cookieLevel);
        _score = int.Parse(cookieScore);
        Debug.Log("CookieLevel: " + cookieLevel);
        Debug.Log("CookieScore: " + cookieScore);
#endif
    }
예제 #2
0
        /// <summary>
        /// Reads the cookie and verifies if it matches the one we stored.
        /// </summary>
        public void ButtonEventReadCookie()
        {
            // TODO: Currently reading the cookie from the instant app. Prefer to read it from installed app.
            var readCookie = CookieApi.GetInstantAppCookie();

            Debug.LogFormat("Successfully read cookie: {0}", readCookie);
            if (string.Equals(readCookie, _storedCookie))
            {
                Debug.Log("Read cookie matches the value we stored");
            }
            else
            {
                Debug.LogError("Read cookie does not match the value we stored");
            }
        }
예제 #3
0
    public void DoInstallClick()
    {
        Debug.Log("DoInstallClick");
#if PLAY_INSTANT
        Debug.LogFormat("Cookie max size: {0}", CookieApi.GetInstantAppCookieMaxSizeBytes());
        var result = CookieApi.SetInstantAppCookie("test-cookie");
        Debug.LogFormat("Set cookie result: {0}", result);

        using (var activity = UnityPlayerHelper.GetCurrentActivity())
            using (var postInstallIntent = InstallLauncher.CreatePostInstallIntent(activity))
            {
                InstallLauncher.PutPostInstallIntentStringExtra(postInstallIntent, "payload", "test-payload-value");
                InstallLauncher.ShowInstallPrompt(activity, 1234, postInstallIntent, "test-referrer");
            }
#else
        Debug.LogErrorFormat("Intent result: \"{0}\"", InstallLauncher.GetPostInstallIntentStringExtra("payload"));
        Debug.LogErrorFormat("Cookie: \"{0}\"", CookieApi.GetInstantAppCookie());
#endif
    }