|
@@ -98,23 +98,37 @@ export interface NotificationsResponse {
|
98
|
98
|
}
|
99
|
99
|
|
100
|
100
|
const RNPermissions: {
|
101
|
|
- openSettings: () => Promise<true>;
|
102
|
|
- check: (permission: Permission) => Promise<PermissionStatus>;
|
103
|
|
- request: (
|
104
|
|
- permission: Permission,
|
105
|
|
- rationale?: Rationale,
|
106
|
|
- ) => Promise<PermissionStatus>;
|
|
101
|
+ // Android + iOS
|
107
|
102
|
checkNotifications: () => Promise<NotificationsResponse>;
|
108
|
103
|
requestNotifications: (
|
109
|
104
|
options: NotificationOption[],
|
110
|
105
|
) => Promise<NotificationsResponse>;
|
|
106
|
+ openSettings: () => Promise<true>;
|
111
|
107
|
|
112
|
|
- // android only module methods
|
|
108
|
+ // Android only
|
113
|
109
|
isAvailable: (permission: Permission) => Promise<boolean>;
|
114
|
|
- setNonRequestable: (permission: Permission) => Promise<true>;
|
115
|
110
|
getNonRequestables: () => Promise<Permission[]>;
|
|
111
|
+ setNonRequestable: (permission: Permission) => Promise<true>;
|
|
112
|
+
|
|
113
|
+ // iOS only
|
|
114
|
+ check: (permission: Permission) => Promise<PermissionStatus>;
|
|
115
|
+ request: (
|
|
116
|
+ permission: Permission,
|
|
117
|
+ rationale?: Rationale,
|
|
118
|
+ ) => Promise<PermissionStatus>;
|
116
|
119
|
} = NativeModules.RNPermissions;
|
117
|
120
|
|
|
121
|
+// Produce an error if we don't have the native module
|
|
122
|
+if (RNPermissions == null) {
|
|
123
|
+ throw new Error(`react-native-permissions: NativeModule.RNPermissions is null. To fix this issue try these steps:
|
|
124
|
+• Run \`react-native link react-native-permissions\` in the project root.
|
|
125
|
+• Rebuild and re-run the app.
|
|
126
|
+• If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
|
|
127
|
+• Check that the library was linked correctly when you used the link command by running through the manual installation instructions in the README.
|
|
128
|
+* If you are getting this error while unit testing you need to mock the native module. Follow the guide in the README.
|
|
129
|
+If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-permissions`);
|
|
130
|
+}
|
|
131
|
+
|
118
|
132
|
const platformPermissions = Object.values(
|
119
|
133
|
Platform.OS === 'ios' ? IOS : ANDROID,
|
120
|
134
|
);
|