IOS原生推送

2020-05-07  本文已影响0人  wenju

1.注册
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UNUserNotificationCenter * center = [UNUserNotificationCenter currentNotificationCenter];
[center setDelegate:self];
UNAuthorizationOptions type = UNAuthorizationOptionBadge|UNAuthorizationOptionSound|UNAuthorizationOptionAlert;
[center requestAuthorizationWithOptions:type completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
// DBLog(@"注册成功");
}else{
// DBLog(@"注册失败");
}
}];
[application registerForRemoteNotifications];
}

2.通知方式

3.注册结果

上一篇 下一篇

猜你喜欢

热点阅读