Esempio n. 1
0
        static NotificationCenter()
        {
            try
            {
                Current = new Platform.iOS.NotificationServiceImpl();

                if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0) == false)
                {
                    return;
                }

                var alertsAllowed = false;

                UNUserNotificationCenter.Current.GetNotificationSettings((settings) =>
                {
                    alertsAllowed = settings.AlertSetting == UNNotificationSetting.Enabled;
                });

                if (!alertsAllowed)
                {
                    // Ask the user for permission to get notifications on iOS 10.0+
                    UNUserNotificationCenter.Current.RequestAuthorizationAsync(
                        UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound);
                }

                UNUserNotificationCenter.Current.Delegate = new LocalNotificationDelegate();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
 static NotificationCenter()
 {
     try
     {
         Current = new Platform.iOS.NotificationServiceImpl();
         UNUserNotificationCenter.Current.Delegate = new LocalNotificationDelegate();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
 }