コード例 #1
0
        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));
        }