My code.
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!error) {
NSLog(@"~ios10-----");
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
}else{
NSLog(@"~ios10---error--");
}
}];
This code in iPhone 5s ios 11.4.1 is work, didRegisterForRemoteNotificationsWithDeviceToken method called. But in iPhone 6s ios 13.5.0 doesn't work. After few days of googled, in APNS connection failure found a solution, fix was to change the phones to use an alternative DNS like Google (8.8.8.8) or Cloudflare (1.1.1.1) in the wifi settings. But I can't modify the DNS of the user's phone.
If you have any ideas, please let me know. Thanks