Skip to content

Commit

Permalink
Make requestNotifications options optional
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Jan 13, 2025
1 parent c513c50 commit 1e08069
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ The `rationale` is only available and used on Android. It can be a native alert

```ts
function requestNotifications(
options: NotificationOption[], // only used by iOS
options?: NotificationOption[], // only used by iOS
rationale?: Rationale,
): Promise<NotificationsResponse>;
```
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ PODS:
- React-logger (= 0.76.2)
- React-perflogger (= 0.76.2)
- React-utils (= 0.76.2)
- RNPermissions (5.2.2):
- RNPermissions (5.2.3):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1893,7 +1893,7 @@ SPEC CHECKSUMS:
React-utils: c8c0c746031419a29cfd8c72a394fdeac0684a84
ReactCodegen: a64e8f3a8bba0ecf88fce06c2874e021d55148f3
ReactCommon: 7b9403030ff3430ccffed63cd25c8aeab2a3ea7e
RNPermissions: 58daf8003d82766ca706ec9b19b7e54d74b5e4f4
RNPermissions: dd5cd0b304f83156d217b43564bb348d91b10d6a
RNVectorIcons: a24016b773380b1aa37fca501ec6b94a951890a0
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 96872ee462cfc43866ad013c8160d4ff6b85709b
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-permissions",
"version": "5.2.2",
"version": "5.2.3",
"license": "MIT",
"description": "An unified permissions API for React Native on iOS, Android and Windows",
"author": "Mathieu Acthernoene <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type Contract = {
permissions: P,
): Promise<Record<P[number], PermissionStatus>>;
requestNotifications(
options: NotificationOption[],
options?: NotificationOption[],
rationale?: Rationale,
): Promise<NotificationsResponse>;
};
2 changes: 1 addition & 1 deletion src/methods.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const checkNotifications: Contract['checkNotifications'] = async () => {
}
};

const requestNotifications: Contract['requestNotifications'] = async (options, rationale) => {
const requestNotifications: Contract['requestNotifications'] = async (options = [], rationale) => {
if (USES_LEGACY_NOTIFICATIONS) {
const response = (await NativeModule.requestNotifications(options)) as NotificationsResponse;
return response;
Expand Down
4 changes: 3 additions & 1 deletion src/methods.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const checkNotifications: Contract['checkNotifications'] = async () => {
return response;
};

const requestNotifications: Contract['requestNotifications'] = async (options) => {
const requestNotifications: Contract['requestNotifications'] = async (
options = ['alert', 'badge', 'sound'],
) => {
const response = (await NativeModule.requestNotifications(options)) as NotificationsResponse;
return response;
};
Expand Down

0 comments on commit 1e08069

Please sign in to comment.