public static async Task SetupNotificationsIfNeeded(INotificationsService notificationsService, IUniversalWindowsRemoteNotificationsPresenter notificationsPresenter) { _notificationsPresenter = notificationsPresenter; if (PushNotificationChannel == null) { PushNotificationChannel = await PushNotificationChannelManager .CreatePushNotificationChannelForApplicationAsync(); PushNotificationChannel.PushNotificationReceived += PushChannel_PushNotificationReceived; } await Task.Run(async() => { bool?booleanValue = false; lock (synchronizationObject) { booleanValue = ApplicationData.Current.LocalSettings.Values[ShouldForceSubcribeToPushSettingsKey] as bool?; } if (booleanValue.HasValue && booleanValue.Value) { await Polly.Policy .Handle <Exception>() .WaitAndRetryForever(x => TimeSpan.FromMinutes(5)) .ExecuteAsync(async() => { await notificationsService.SubscribeToNotifications(true); lock (synchronizationObject) { ApplicationData.Current.LocalSettings.Values[ShouldForceSubcribeToPushSettingsKey] = false; } }); } }); }
public static void HandlePushActivation(IActivatedEventArgs e, IUniversalWindowsRemoteNotificationsPresenter presenter) { var toastNotificationActivatedEventArgs = e as ToastNotificationActivatedEventArgs; if (toastNotificationActivatedEventArgs == null) { return; } presenter.HandleRemoteNotificationActivation(toastNotificationActivatedEventArgs.Argument ?? string.Empty); }
public UWPRemotePushNotificationsService(IPersistedStorage persistedStorage, IRemotePushRegistrationService remotePushRegistrationService, IPushTagsProvider pushTagsProvider, IUniversalWindowsRemoteNotificationsPresenter remoteNotificationsPresenter) { uwpNotificationsService = new PushInvalidateRegistrationAppUpdateBackgroundTaskNotificationsServiceDecorator( new PushBackgroundTaskNotificationServiceDecorator( new UniversalWindowsRemotePushNotificationService(persistedStorage, remotePushRegistrationService, pushTagsProvider) )); }
public UWPRemotePushNotificationsService(IRemotePushRegistrationService remotePushRegistrationService, IPushTagsProvider pushTagsProvider, IUniversalWindowsRemoteNotificationsPresenter remoteNotificationsPresenter) : this(new UWPDefaultPersistedStorage(), remotePushRegistrationService, pushTagsProvider, remoteNotificationsPresenter) { }
public static void HandlePushRelatedBackgroundActivation(BackgroundActivatedEventArgs args, IUniversalWindowsRemoteNotificationsPresenter notificationsPresenter, INotificationsService notificationsService) { PushServicesExtensions.SetupNotificationsIfNeeded(notificationsService, notificationsPresenter); if (args.TaskInstance.Task.Name == PushBackgroundTaskNotificationServiceDecorator.BackgroundTaskName) { notificationsPresenter.HandleNotification((args.TaskInstance.TriggerDetails as RawNotification).Content); } if (args.TaskInstance.Task.Name == PushInvalidateRegistrationAppUpdateBackgroundTaskNotificationsServiceDecorator.BackgroundTaskName) { HandleAppUpdateBackgroundActivation(args, notificationsService); } }