private static async void CreateWNSChannel(IInitializeHandler handler) { try { PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); channel.PushNotificationReceived -= OnPushNotificationReceived; channel.PushNotificationReceived += OnPushNotificationReceived; ApplicationData.Current.LocalSettings.Values[HAS_WNS_CHANNEL_KEY] = true; handler.OnInitialized(channel.Uri); } catch (Exception e) { handler.OnInitializationError(e.Message, true); } }
//public public static bool Initialize(bool willHandleReceivedNotifications, int startId, bool incrementalId, IInitializeHandler handler, bool pushEnabled, bool dontShowWhenRunning, string titleFieldName, string textFieldName, string userDataFieldName, string notificationProfileFieldName, string idFieldName, string badgeFieldName) { var settings = ApplicationData.Current.LocalSettings; settings.Values[HANDLE_NOTIFICATIONS_KEY] = willHandleReceivedNotifications; settings.Values[NEXT_ID_KEY] = startId; settings.Values[INCREMENTAL_ID_KEY] = incrementalId; settings.Values[DONT_SHOW_WHEN_RUNNING_KEY] = dontShowWhenRunning; settings.Values[TITLE_FIELD_NAME_KEY] = titleFieldName; settings.Values[TEXT_FIELD_NAME_KEY] = textFieldName; settings.Values[USER_DATA_FIELD_NAME_KEY] = userDataFieldName; settings.Values[NOTIFICATION_PROFILE_FIELD_NAME_KEY] = notificationProfileFieldName; settings.Values[ID_FIELD_NAME_KEY] = idFieldName; settings.Values[BADGE_FIELD_NAME_KEY] = badgeFieldName; PackageVersion packageVersion = Package.Current.Id.Version; string appVersion = packageVersion.Major + "." + packageVersion.Minor + "." + packageVersion.Revision + "." + packageVersion.Build; RegisterBackgroundTasks(appVersion, pushEnabled); if (pushEnabled) { CreateWNSChannel(handler); } else { CloseWNSChannel(); } return(true); }
public static void EnablePushNotifications(IInitializeHandler handler) { throw new NotImplementedException(); }
public static void EnablePushNotifications(IInitializeHandler handler) { PushBackgroundTask.Register(); CreateWNSChannel(handler); }
public static bool Initialize(bool willHandleReceivedNotifications, int startId, bool incrementalId, IInitializeHandler handler, bool pushEnabled, bool dontShowWhenRunning, string titleFieldName, string textFieldName, string userDataFieldName, string notificationProfileFieldName, string idFieldName, string badgeFieldName) { throw new NotImplementedException(); }