Пример #1
0
    public void CheckExternalRegister(string refresh, string expires, string email)
    {
        Headers = new List <Header>()
        {
            new Header("Authorization", " Bearer " + userToken.Token)
        };

        if (string.IsNullOrEmpty(refresh))
        {
            Canvaser.Instance.RegistrationPanel.ExternalRegistration(email);
        }
        else
        {
            LocalUser = false;
            var seconds = int.Parse(Regex.Replace(expires, "\\D", string.Empty));
            PlayerPrefs.SetString("provider_gosha", LoginProvider);
            PlayerPrefs.SetString("refresh_token_gosha", refresh);
            PlayerPrefs.SetString("refresh_expires_in_gosha", DateTime.Now.AddSeconds(seconds).ToString());
            OneSignal.SetSubscription(true);
            OneSignal.SyncHashedEmail(email);
            Canvaser.Instance.LoginPanel.SetActive(false);
            GetUserInfoAsync();
            Canvaser.Instance.MainMenu.SetActive(true);

            AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.CloseLoading();
            AdsManager.Instance.GetAds(Canvaser.Instance.ADSPanel.txt, Canvaser.Instance.ADSPanel.img);
        }
    }
            public void IdsAvailable(string oneSignalUserId, string registrationId)
            {
                var user        = App.CurrentUserEnvironment.User;
                var idUser      = user.IdUser.ToString();
                var credentials = string.Format("{0}/{1}/{2}", user.LastName, user.FirstName, user.Email);

                //Sync email
                OneSignal.SyncHashedEmail(user.Email);
                //Create user tags
                OneSignal.GetTags(new GetTagsHandler(idUser, credentials));
                //Silent notification
                OneSignal.SetInFocusDisplaying(OneSignal.OSInFocusDisplayOption.None);
            }
Пример #3
0
    public void GetTokenAsync(string email, string password)
    {
        LoginBtn.interactable = false;

        CoroutineManager.SendRequest(LoginUrl, string.Format("username={0}&password={1}&grant_type=password", email, password), (AccessToken token) =>
        {
            Extensions.RemoveJsonData(DataType.UserInfo);
            LocalUser = false;
            userToken = token;

            PlayerPrefs.SetString("refresh_token_gosha", userToken.RefreshToken);
            PlayerPrefs.SetString("refresh_expires_in_gosha", DateTime.Now.AddSeconds(userToken.RefreshExpireIn).ToString());

            PlayerPrefs.SetString("token_gosha", userToken.Token);
            PlayerPrefs.SetString("token_expires_in_gosha", DateTime.Now.AddSeconds(userToken.TokenExpiresIn).ToString());

            OneSignal.SetSubscription(true);
            OneSignal.SyncHashedEmail(userToken.Email);

            LoginCanvas.Instance.EnableWarning(false);

            Debug.Log(userToken.Token);

            LoginCanvas.Instance.Enable(false);

            Headers = new List <Header>()
            {
                new Header("Authorization", " Bearer " + userToken.Token)
            };
            GetUserInfoAsync();
            //AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.ADSPanel.OpenAds();
            AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.CloseLoading();
            AdsManager.Instance.GetAds(Canvaser.Instance.ADSPanel.txt, Canvaser.Instance.ADSPanel.img);
        },
                                     (response) =>
        {
            LoginCanvas.Instance.EnableWarning(true);
        },
                                     finallyMethod:
                                     () =>
        {
            LoginBtn.interactable = true;
        });
    }
Пример #4
0
    public void GetTokenByRefreshAsync(string refreshToken)
    {
        CoroutineManager.SendRequest(LoginUrl, string.Format("refresh_token={0}&grant_type=refresh_token", refreshToken), (AccessToken token) =>
        {
            LocalUser = false;
            userToken = token;

            OneSignal.SetSubscription(true);
            OneSignal.SyncHashedEmail(userToken.Email);

            PlayerPrefs.SetString("refresh_token_gosha", userToken.RefreshToken);
            PlayerPrefs.SetString("refresh_expires_in_gosha", DateTime.Now.AddSeconds(userToken.RefreshExpireIn).ToString());

            PlayerPrefs.SetString("token_gosha", userToken.Token);
            PlayerPrefs.SetString("token_expires_in_gosha", DateTime.Now.AddSeconds(userToken.TokenExpiresIn).ToString());

            LoginCanvas.Instance.EnableWarning(false);

            Debug.Log(userToken.Token);

            LoginCanvas.Instance.Enable(false);

            Headers = new List <Header>()
            {
                new Header("Authorization", " Bearer " + userToken.Token)
            };
            GetUserInfoAsync();
            //AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.ADSPanel.OpenAds();
            AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.CloseLoading();
            AdsManager.Instance.GetAds(Canvaser.Instance.ADSPanel.txt, Canvaser.Instance.ADSPanel.img);
        },
                                     (response) =>
        {
            //LoginCanvas.Instance.EnableWarning(true);
            Canvaser.Instance.CloseLoading();
        });
    }
 public void SyncHashedEmail(string email)
 {
     OneSignal.SyncHashedEmail(email);
 }