Skip to content

Commit

Permalink
[expo-notifications][expo-permissions] Move notification permission r…
Browse files Browse the repository at this point in the history
…equesters to notifications package (#8486)

# Why

Fixes https://github.com/unimodules/react-native-unimodules/issues/136. This is what we wanted to do anyway—move code responsible for permissions to respective modules.

# How

- removed `EXUserNotificationPermissionRequester` as it was left only as a fallback for when `expo-notifications` is not installed. Now that in Expo Client `expo-notifications` will be installed, this class would never be used.
- moved remote notification permission requester from `expo-permissions` to `expo-notifications`, effectively removing support for calling `askAsync(Permissions.NOTIFICATIONS)` from `expo-permission` if `expo-notifications` is not installed
  - while moving I write a way for the requester to receive callbacks about permission being accepted or declined. I used a `UIApplicationDelegate` singleton module to which requesters can register to receive callbacks.
  - since new notification permission requesters now may return `null` inside the permission response I had to either:
    - add support for `NSNull` in `EXPermissionsManager` (it is returned by the user notifications permissions requester)
    - exclude `notifications` and `userFacingNotifications` from being saved to kernel service since we don't scope them even so (thanks @lukmccall for the tip!)
    
    We decided to stick to the second idea.

# Test Plan

- [x] Ran Expo Client on an ExpoClient-less device, fetched and asked for both notification-related permissions.
  • Loading branch information
sjchmiela committed May 27, 2020
1 parent fd64944 commit 096a701
Show file tree
Hide file tree
Showing 35 changed files with 774 additions and 840 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

490 changes: 253 additions & 237 deletions apps/bare-expo/ios/Pods/EXNotifications.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

165 changes: 61 additions & 104 deletions apps/bare-expo/ios/Pods/EXPermissions.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions docs/pages/versions/unversioned/sdk/permissions.md
Expand Up @@ -24,8 +24,8 @@ The following table shows you which permissions correspond to which packages.

| Permission type | Packages |
| --------------------------- | ----------------------------------------- |
| `NOTIFICATIONS` | `expo-permissions` |
| `USER_FACING_NOTIFICATIONS` | `expo-permissions` |
| `NOTIFICATIONS` | `expo-notifications` |
| `USER_FACING_NOTIFICATIONS` | `expo-notifications` |
| `LOCATION` | `expo-location` |
| `CAMERA` | `expo-camera`, `expo-barcode-scanner` |
| `AUDIO_RECORDING` | `expo-av` |
Expand Down
Expand Up @@ -70,7 +70,10 @@ - (void)askForPermissionUsingRequesterClass:(Class)requesterClass
// ask for permission. If granted then save it as scope permission
void (^customOnResults)(NSDictionary *) = ^(NSDictionary *permission){
UM_ENSURE_STRONGIFY(self)
[self.permissionsService savePermission:permission ofType:permissionType forExperience:self.experienceId];
// if permission should be scoped save it
if ([self shouldVerifyScopedPermission:permissionType]) {
[self.permissionsService savePermission:permission ofType:permissionType forExperience:self.experienceId];
}
resolve(permission);
};

Expand Down
8 changes: 4 additions & 4 deletions ios/Pods/.project_cache/installation_cache.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 096a701

Please sign in to comment.