iOS 10 推送Tips

2016-09-18  本文已影响125人  寒咯
1.注册方式:
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
 [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) {
   if (!error) {
     NSLog(@"succeeded!");
   }
 }];
 center.delegate = self;
 [[UIApplication sharedApplication] registerForRemoteNotifications];```
#####2.获取用户设置状态
```objectivec
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { NSLog(@"%@",settings);}];
3.新增方法
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
 completionHandler(UNNotificationPresentationOptionBadge);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler {
 NSDictionary *userinfo = response.notification.request.content.userInfo;
   if (userinfo && [userinfo isKindOfClass:[NSDictionary class]]) {
   }
}
4.配置问题
上一篇 下一篇

猜你喜欢

热点阅读