So iOS 12 introduced Provisional Authorization for Quiet Notifications that could be seen in Notification Center but not on the Lock screen. It has very cool advantage - you don't need user's approval to send one.
Several articles (smashingmagazine.com, gadgethacks.com, etc.) claim that iOS app will be able to set it's badge if received Provisional Authorization.
Is it really possible to set app badge when app is Provisionally Authorized?
I request authorization using code below:
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionProvisional
completionHandler:^(BOOL granted, NSError *_Nullable error) {
if (granted) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
I receive token at didRegisterForRemoteNotificationsWithDeviceToken:
that could be used to send Push Notification. When I send Push Notification with a payload {"aps":{"alert":"Testing..","badge":1}}
I see it in Notification Center but app doesn't get badged.
I tried setting badge using UIApplication.sharedApplication.applicationIconBadgeNumber = 1;
but it didn't work as well. It works though if I request regular authorization without providing UNAuthorizationOptionProvisional option.
Use provisional authorization to send notifications on a trial basis. Users can then evaluate the notifications and decide whether to authorize them. The system delivers provisional notifications quietly—they don't interrupt the user with a sound or banner, or appear on the lock screen.
Nope, Apple does not allow push notifications on iOS.
When important, time-sensitive events occur, inform your website users with push notifications you send from your server. In Safari 16 in macOS 13 or later, Safari supports web push — push notifications that use the cross-browser Push API, Notifications API, and Service Worker standards.
Same issue here.
It seems, that app badges are off by default for provisional authorization. I couldn't find anything about it in the documentation.
But you can see it in the apps notification settings. The "Badges" switch is off by default:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With