Determine if local notification is allowed

2019-09-04 10:21发布

How to detect local(not push notification) notifications are allowed or not ? I'm going to integrate local notifications with my app, and for app functionality is very important to detect are local notifications allowed or not.

3条回答
再贱就再见
2楼-- · 2019-09-04 10:38

As I know user can not disable local notification. So, you do not need to check availability of them.

查看更多
不美不萌又怎样
3楼-- · 2019-09-04 10:56

Use CLLocationManager Delegate if user not allow location service the delegate call:

- (void)locationManager:(CLLocationManager *)manager
   didFailWithError:(NSError *)error;

And when the notification service allow you can use local notification whit this function:

- (void)startMonitoringForRegion:(CLRegion *)region
             desiredAccuracy:(CLLocationAccuracy)accuracy __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA,__IPHONE_4_0, __IPHONE_6_0);
查看更多
The star\"
4楼-- · 2019-09-04 11:00

Local notifications are always allowed and are available as any other functionality in iOS SDK. Push notifications, however, require special signature for the app to work. Read more about that in Developer docs.

If your app is frontmost and requires to respond to local notification, just implement method application:didReceiveLocalNotification: If it's not, then implement functionality, that is described in Apple Developer docs in method application:didFinishLaunchingWithOptions:

查看更多
登录 后发表回答