public async Task Fire_OnSignInComplete(bool signedIn, string message, bool signedUp, SignInAErrorType errorType) { if (signedIn) { #if _IOS_ if (!remoteNotificationsInitialized) { remoteNotificationsInitialized = true; RemoteNotificationsService.Instance.RegisteredForNotifications += async(sender, b) => { string error = string.Empty; if (b.Success) { await NotificationClient.AddDevice(RemoteNotificationsService.Instance.GetTokenType(), b.Info); } else { error = b.Info; } //Inform user we failed to register for remote notifications if (!string.IsNullOrEmpty(error) && !IsInBackground) { await Application.Current.MainPage.DisplayAlert("Notifications Subscription Error", b.Info, "OK"); } }; } if (RemoteNotificationsService.Instance.CanRegisterForNotifications() && RemoteNotificationsService.Instance.IsRegisteredForNotifications()) { RemoteNotificationsService.Instance.RegisterForNotifications(); } //In case background app refresh is disabled inform the user RemoteNotificationsService.Instance.BackgroundRefreshStatusChanged += async(s, enabled) => { if (!enabled && !IsInBackground) { await Application.Current.MainPage.DisplayAlert(string.Empty, "Please enable Background App Refresh for \"PlayOn Cloud\" in Settings-General in order to stay up-to-date with your recordings", "OK"); } }; if (!RemoteNotificationsService.Instance.IsBackgoundRefreshEnabled()) { if (await Application.Current.MainPage.DisplayAlert(string.Empty, "Please enable Background App Refresh for \"PlayOn Cloud\" in Settings-General in order to stay up-to-date with your recordings", "Yes", "No")) { RemoteNotificationsService.Instance.OpenGeneralAppSettings(); } } #endif //if (signedUp) // await Application.Current.MainPage.DisplayAlert("Account Created!", // "Check your email to receive your free recording credits.", "OK"); } OnSignInComplete?.Invoke(this, new SignInArgs(signedIn, message, errorType)); }
/* Получить данные об авторизации по ключу */ public async Task <bool> SignInByKey(string access_token, OnSignInComplete complete, OnSignInError error) { // Формируем данные для отправки var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("access_token", access_token), new KeyValuePair <string, string>("lang", club_instance.language) }); // Отправка запроса bool auth = await club_instance.requests.sendRequest(api_route + "login/", formContent, ((string data) => { credentials = JsonConvert.DeserializeObject <authModel>(data); // Конверсия JSON access_token = credentials.token; // Установить токен complete(access_token); }), ((string code) => { error(code); })); // Все ок return(true); }