推送的权限
// 自定义方法-获取用户推送通知授权
-(void)registerAutor{
if(@available(iOS 10,*))
{
UNUserNotificationCenter * center =[UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound completionHandler:^(BOOL granted,NSError * _Nullable error){
if(granted){
//允许推送
}else{
//不允许
}
}];
}
else if(@available(iOS 8,*))
{
UIApplication * application =[UIApplication sharedApplication];
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]];
[application registerForRemoteNotifications];
}
else
{
UIApplication * application =[UIApplication sharedApplication];
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
[application registerForRemoteNotifications];
}
}