Determine if local notification is allowed

血红的双手。 提交于 2020-01-06 08:15:26

问题


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.


回答1:


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:




回答2:


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




回答3:


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);


来源:https://stackoverflow.com/questions/21181519/determine-if-local-notification-is-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!