So I have push notifications setup in my app and it works great. I've recently just learned about silent notifications and wanted to implement it in case a user opts out of push notifications. I've followed all the sources I can find, but I can't seem to get the device token. I'm not sure if I'm missing something.
In testing I'll decline the alert for push notications after this method is called:
- (void)registerForRemoteNotifications {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
}
}];
}
unlike when a user accepts push notifications:
didRegisterForRemoteNotificationsWithDeviceToken
is never called -- so I don't receive the current device token and I'm not able to update my server.
I've added background modes -> remote notifications and have also added the key/value in my plist.
Am I missing something? Thanks in advance for your help