Skip to content

Commit 54ac46f

Browse files
committed
1 parent ff797bc commit 54ac46f

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/index.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,37 @@ export interface NotificationsResponse {
9898
}
9999

100100
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
107102
checkNotifications: () => Promise<NotificationsResponse>;
108103
requestNotifications: (
109104
options: NotificationOption[],
110105
) => Promise<NotificationsResponse>;
106+
openSettings: () => Promise<true>;
111107

112-
// android only module methods
108+
// Android only
113109
isAvailable: (permission: Permission) => Promise<boolean>;
114-
setNonRequestable: (permission: Permission) => Promise<true>;
115110
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>;
116119
} = NativeModules.RNPermissions;
117120

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+
118132
const platformPermissions = Object.values(
119133
Platform.OS === 'ios' ? IOS : ANDROID,
120134
);

0 commit comments

Comments
 (0)