Esempio n. 1
0
        public bool CheckPermission(string permission)
        {
            switch (permission)
            {
            case "IOS.permission.LOCATION":
                //application dont need location per below ios 8.0
                if (!(UIDevice.CurrentDevice.CheckSystemVersion(8, 0)))
                {
                    return(true);
                }

                switch (CLLocationManager.Status)
                {
                case CLAuthorizationStatus.Authorized:
                    return(true);

                //break;
                case CLAuthorizationStatus.AuthorizedWhenInUse:
                    return(true);

                //break;
                case CLAuthorizationStatus.Denied:
                    return(false);

                //break;
                case CLAuthorizationStatus.NotDetermined:
                    return(false);
                    //break;
                }
                break;

            case "IOS.permission.NOTIFICATION":

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

                UIUserNotificationType types = UIApplication.SharedApplication.CurrentUserNotificationSettings.Types;

                if (types.HasFlag(UIUserNotificationType.Alert) /*|| types.HasFlag(UIUserNotificationType.Badge) || types.HasFlag(UIUserNotificationType.Sound)*/)
                {
                    return(true);
                }
                return(false);
                //break;
            }
            return(false);
        }
Esempio n. 2
0
 void RegisterNotifications(UIUserNotificationType notifications, UIRemoteNotificationType remoteNotification)
 {
     if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
     {
         if (!notificationTypes.HasFlag(notifications))
         {
             notificationTypes |= notifications;
             var settings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, null);
             UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
         }
     }
     else if (!remoteNotificationTypes.HasFlag(remoteNotification))
     {
         remoteNotificationTypes |= remoteNotification;
         UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(remoteNotificationTypes);
     }
 }