Skip to content

Commit

Permalink
fix ts cancelLocalNotification prop (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielEliraz committed Jun 29, 2021
1 parent 48a95d5 commit aa503f5
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -20,7 +20,7 @@ Apps using React Native Notifications may target iOS 10 and Android 5.0 (API 21)

### iOS

<img src="https://s3.amazonaws.com/nrjio/interactive.gif" alt="Interactive notifications example" width=350/>
<!-- <img src="https://s3.amazonaws.com/nrjio/interactive.gif" alt="Interactive notifications example" width=350/> -->

- Remote (push) notifications
- Local notifications
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Notifications.ts
Expand Up @@ -76,7 +76,7 @@ export class NotificationsRoot {
/**
* cancelLocalNotification
*/
public cancelLocalNotification(notificationId: string) {
public cancelLocalNotification(notificationId: number) {
return this.commands.cancelLocalNotification(notificationId);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/adapters/NativeCommandsSender.ts
Expand Up @@ -15,7 +15,7 @@ interface NativeCommandsModule {
registerPushKit(): void;
getBadgeCount(): Promise<number>;
setBadgeCount(count: number): void;
cancelLocalNotification(notificationId: string): void;
cancelLocalNotification(notificationId: number): void;
cancelAllLocalNotifications(): void;
isRegisteredForRemoteNotifications(): Promise<boolean>;
checkPermissions(): Promise<NotificationPermissions>;
Expand Down Expand Up @@ -71,7 +71,7 @@ export class NativeCommandsSender {
this.nativeCommandsModule.setBadgeCount(count);
}

cancelLocalNotification(notificationId: string) {
cancelLocalNotification(notificationId: number) {
this.nativeCommandsModule.cancelLocalNotification(notificationId);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/src/commands/Commands.test.ts
Expand Up @@ -150,8 +150,9 @@ describe('Commands', () => {

describe('cancelLocalNotification', () => {
it('sends to native', () => {
uut.cancelLocalNotification("notificationId");
verify(mockedNativeCommandsSender.cancelLocalNotification("notificationId")).called();
const notificationId = 1;
uut.cancelLocalNotification(notificationId);
verify(mockedNativeCommandsSender.cancelLocalNotification(notificationId)).called();
});
});

Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/Commands.ts
Expand Up @@ -56,7 +56,7 @@ export class Commands {
this.nativeCommandsSender.setBadgeCount(count);
}

public cancelLocalNotification(notificationId: string) {
public cancelLocalNotification(notificationId: number) {
this.nativeCommandsSender.cancelLocalNotification(notificationId);
}

Expand Down
4 changes: 2 additions & 2 deletions website/docs/api/general-api.md
Expand Up @@ -29,12 +29,12 @@ Notifications.postLocalNotification({
sound: 'chime.aiff',
category: 'SOME_CATEGORY',
link: 'localNotificationLink',
fireDate: new Date()
fireDate: new Date() // only iOS
}, id);
```

## cancelLocalNotification(id)
Relevant for notifications sent with `fireDate`.
Only iOS. Relevant for notifications sent with `fireDate`.

```js
Notifications.cancelLocalNotification(id);
Expand Down
14 changes: 8 additions & 6 deletions website/docs/docs/localNotifications.md
Expand Up @@ -16,9 +16,10 @@ let localNotification = Notifications.postLocalNotification({
body: "Local notification!",
title: "Local Notification Title",
sound: "chime.aiff",
silent: false,
silent: false,
category: "SOME_CATEGORY",
userInfo: { }
userInfo: { },
fireDate: new Date(),
});
```

Expand All @@ -45,7 +46,8 @@ let someLocalNotification = Notifications.postLocalNotification({
title: "Local Notification Title",
sound: "chime.aiff",
category: "SOME_CATEGORY",
userInfo: { }
userInfo: { },
fireDate: new Date(),
});

Notifications.cancelLocalNotification(someLocalNotification);
Expand All @@ -72,9 +74,9 @@ Call `removeAllDeliveredNotifications()` to dismiss all delivered notifications
notifications).


<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/APK_format_icon.png/768px-APK_format_icon.png" width={30}/> Android
<img src="./../../static/img/Android_icon-icons.com_66772.png"/> Android

Much like on iOS, notifications can be triggered locally. The API to do so is a simplified version of the iOS equivalent that works more natually with the Android perception of push (remote) notifications:
Much like on iOS, notifications can be triggered locally. The API to do so is a simplified version of the iOS equivalent that works more naturally with the Android perception of push (remote) notifications:

```jsx
Notifications.postLocalNotification({
Expand All @@ -84,4 +86,4 @@ Notifications.postLocalNotification({
});
```

Upon notification opening (tapping by the device user), all data fields will be delivered as-is). Note that scheduled notifications are not yet implemented on Android. See [Issue 484](https://github.com/wix/react-native-notifications/issues/484).
Upon notification opening (tapping by the device user), all data fields will be delivered as-is. Note that scheduled notifications are not yet implemented on Android. See [Issue 484](https://github.com/wix/react-native-notifications/issues/484).
Binary file added website/static/img/Android_icon-icons.com_66772.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/static/img/favicon.ico
Binary file not shown.

0 comments on commit aa503f5

Please sign in to comment.