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

fix(messaging, ios): Support Ephemeral authorization state #6478

Merged
merged 3 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/messaging/ios-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ The value returned is a number value, which can be mapped to one of the followin
- `0` = `messaging.AuthorizationStatus.DENIED`: The user has denied notification permissions.
- `1` = `messaging.AuthorizationStatus.AUTHORIZED`: The user has accept the permission & it is enabled.
- `2` = `messaging.AuthorizationStatus.PROVISIONAL`: [Provisional authorization](#provisional-authorization) has been granted.
- `3` = `messaging.AuthorizationStatus.EPHEMERAL`: The app is authorized to create notifications for a limited amount of time. Used for app clips.

To help improve the chances of the user granting your app permission, it is recommended that permission is requested at a time which makes
sense during the flow of your application (e.g. starting a new chat), where the user would expect to receive such notifications.
Expand Down
6 changes: 6 additions & 0 deletions packages/messaging/ios/RNFBMessaging/RNFBMessagingModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ - (NSDictionary *)constantsToExport {
}
}

if (@available(iOS 14.0, macCatalyst 14.0, *)) {
if (settings.authorizationStatus == UNAuthorizationStatusEphemeral) {
authorizedStatus = @3;
}
}

resolve(authorizedStatus);
}];
} else {
Expand Down
7 changes: 7 additions & 0 deletions packages/messaging/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ export namespace FirebaseMessagingTypes {
* @platform ios iOS >= 12
*/
PROVISIONAL = 2,

/**
* The app is authorized to create notifications for a limited amount of time.
* Used in App Clips.
* @platform ios iOS >= 14
*/
EPHEMERAL = 3,
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/messaging/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const statics = {
DENIED: 0,
AUTHORIZED: 1,
PROVISIONAL: 2,
EPHEMERAL: 3,
},
NotificationAndroidPriority: {
PRIORITY_MIN: -2,
Expand Down