Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Unable to observe if the timeSensitive permission has been granted #1194

Open
luca-tomasetti opened this issue Jan 23, 2025 · 2 comments

Comments

@luca-tomasetti
Copy link

luca-tomasetti commented Jan 23, 2025

I am developing a mobile application and some notifications rely on the timeSensitive interruption level.
As far as I can see here, observing the setting doe not provide any information on the timeSensitive value.

Is it possible to observe if the timeSensitive permission has been granted on the device?

I can easily observe the other values (as documented here) but nothing that I can see about the timeSensitive permission...

PS. I'm currently using the latest version as today:
"@notifee/react-native": "^9.1.8",

@luca-tomasetti
Copy link
Author

This is what I can observe after requesting the notification permissions:

const notificationSettings = await notifee.requestPermission()

console.log(NotificationSettings["ios"]) 
// ==> {"alert": 1, "announcement": 0, "authorizationStatus": 1, "badge": 1, "carPlay": -1, "criticalAlert": 1, "inAppNotificationSettings": 0, "lockScreen": 1, "notificationCenter": 1, "showPreviews": 1, "sound": 1}

Setting the Time-Sensitive Notifications switch to true or false does NOT change the NotificationSettings object after requesting the permissions with notifee.requestPermission() ...

Image

@mikehardy
Copy link
Collaborator

time-sensitive interruption level is no longer a permission, it is an entitlement. Your app either has it or it doesn't.

But I think that's just a language thing - that is, semantics - in the iOS docs it is definitely an entitlement now but it is also a "setting", which...works like a permission.

The actual permission is deprecated here, was only ever on iOS 15 - https://developer.apple.com/documentation/usernotifications/unauthorizationoptions/timesensitive

But! Assuming you have the entitlement, it is an interruption level you may set - it appears we have implemented it based on the sample code in current docs
https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel/timesensitive
https://docs.page/invertase/notifee/react-native/ios/behaviour#interruption-levels

And it looks like it should come through as information about current notification center settings:
https://developer.apple.com/documentation/usernotifications/unnotificationsettings#Getting-Device-Specific-Settings

We parse those and return them here, but it looks like we're missing a fetch for timeSensitiveSetting

iosDictionary[@"showPreviews"] = showPreviews;
iosDictionary[@"authorizationStatus"] = authorizationStatus;
iosDictionary[@"alert"] =
[NotifeeCoreUtil numberForUNNotificationSetting:settings.alertSetting];
iosDictionary[@"badge"] =
[NotifeeCoreUtil numberForUNNotificationSetting:settings.badgeSetting];
iosDictionary[@"sound"] =
[NotifeeCoreUtil numberForUNNotificationSetting:settings.soundSetting];
iosDictionary[@"carPlay"] =
[NotifeeCoreUtil numberForUNNotificationSetting:settings.carPlaySetting];
iosDictionary[@"lockScreen"] =
[NotifeeCoreUtil numberForUNNotificationSetting:settings.lockScreenSetting];
iosDictionary[@"notificationCenter"] =
[NotifeeCoreUtil numberForUNNotificationSetting:settings.notificationCenterSetting];

If you added that in and tested it I bet it would work? I'd happily take a PR for it if it worked for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants