Exemplo n.º 1
0
        private static async System.Threading.Tasks.Task RegisterForPush(bool registerAgain = true)
        {
            PushNotificationHelper.RegisterPushNotificationChannel();

            var helper = new TaskHelper();
            var pushNotificationTask = await helper.RegisterTask(nameof(PushNotificationTask),
                                                                 typeof(PushNotificationTask).FullName,
                                                                 new PushNotificationTrigger(),
                                                                 registerAgain);

            if (pushNotificationTask == null)
            {
                Debug.WriteLine("Push notification background task is not started");
            }
        }
Exemplo n.º 2
0
        private static async Task RegisterForPush(TaskHelper helper, bool registerAgain = true)
        {
            try
            {
                PushNotificationHelper.RegisterPushNotificationChannel();

                var pushNotificationTask = await helper.RegisterTask(nameof(PushNotificationTask), typeof(PushNotificationTask).FullName,
                                                                     new PushNotificationTrigger(), registerAgain).AsTask();

                if (pushNotificationTask == null)
                {
                    Debug.WriteLine("Push notification background task is not started");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Failed to register for push notification. Error: {e.Message}");
            }
        }