Skip to content

fix ts cancelLocalNotification prop #754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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).
Loading
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.