コード例 #1
0
        //private
        private static async void RegisterBackgroundTasks(string appVersion, bool pushEnabled)
        {
            if (!ApplicationData.Current.LocalSettings.Values.ContainsKey(VERSION_STORE_KEY) || (string)ApplicationData.Current.LocalSettings.Values[VERSION_STORE_KEY] != appVersion)
            {
                if (ApplicationData.Current.LocalSettings.Values.ContainsKey(VERSION_STORE_KEY))
                {
                    BackgroundExecutionManager.RemoveAccess();
                }

                if (await BackgroundExecutionManager.RequestAccessAsync() != BackgroundAccessStatus.Denied)
                {
                    ApplicationData.Current.LocalSettings.Values[VERSION_STORE_KEY] = appVersion;
                }
            }

            BackgroundTask.Register();
            if (pushEnabled)
            {
                PushBackgroundTask.Register();
            }
        }
コード例 #2
0
 public static void EnablePushNotifications(IInitializeHandler handler)
 {
     PushBackgroundTask.Register();
     CreateWNSChannel(handler);
 }