Skip to content

Commit aa503f5

Browse files
authored
fix ts cancelLocalNotification prop (wix#754)
1 parent 48a95d5 commit aa503f5

9 files changed

+18
-15
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Apps using React Native Notifications may target iOS 10 and Android 5.0 (API 21)
2020

2121
### iOS
2222

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

2525
- Remote (push) notifications
2626
- Local notifications

lib/src/Notifications.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class NotificationsRoot {
7676
/**
7777
* cancelLocalNotification
7878
*/
79-
public cancelLocalNotification(notificationId: string) {
79+
public cancelLocalNotification(notificationId: number) {
8080
return this.commands.cancelLocalNotification(notificationId);
8181
}
8282

lib/src/adapters/NativeCommandsSender.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface NativeCommandsModule {
1515
registerPushKit(): void;
1616
getBadgeCount(): Promise<number>;
1717
setBadgeCount(count: number): void;
18-
cancelLocalNotification(notificationId: string): void;
18+
cancelLocalNotification(notificationId: number): void;
1919
cancelAllLocalNotifications(): void;
2020
isRegisteredForRemoteNotifications(): Promise<boolean>;
2121
checkPermissions(): Promise<NotificationPermissions>;
@@ -71,7 +71,7 @@ export class NativeCommandsSender {
7171
this.nativeCommandsModule.setBadgeCount(count);
7272
}
7373

74-
cancelLocalNotification(notificationId: string) {
74+
cancelLocalNotification(notificationId: number) {
7575
this.nativeCommandsModule.cancelLocalNotification(notificationId);
7676
}
7777

lib/src/commands/Commands.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ describe('Commands', () => {
150150

151151
describe('cancelLocalNotification', () => {
152152
it('sends to native', () => {
153-
uut.cancelLocalNotification("notificationId");
154-
verify(mockedNativeCommandsSender.cancelLocalNotification("notificationId")).called();
153+
const notificationId = 1;
154+
uut.cancelLocalNotification(notificationId);
155+
verify(mockedNativeCommandsSender.cancelLocalNotification(notificationId)).called();
155156
});
156157
});
157158

lib/src/commands/Commands.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class Commands {
5656
this.nativeCommandsSender.setBadgeCount(count);
5757
}
5858

59-
public cancelLocalNotification(notificationId: string) {
59+
public cancelLocalNotification(notificationId: number) {
6060
this.nativeCommandsSender.cancelLocalNotification(notificationId);
6161
}
6262

website/docs/api/general-api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ Notifications.postLocalNotification({
2929
sound: 'chime.aiff',
3030
category: 'SOME_CATEGORY',
3131
link: 'localNotificationLink',
32-
fireDate: new Date()
32+
fireDate: new Date() // only iOS
3333
}, id);
3434
```
3535

3636
## cancelLocalNotification(id)
37-
Relevant for notifications sent with `fireDate`.
37+
Only iOS. Relevant for notifications sent with `fireDate`.
3838

3939
```js
4040
Notifications.cancelLocalNotification(id);

website/docs/docs/localNotifications.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ let localNotification = Notifications.postLocalNotification({
1616
body: "Local notification!",
1717
title: "Local Notification Title",
1818
sound: "chime.aiff",
19-
silent: false,
19+
silent: false,
2020
category: "SOME_CATEGORY",
21-
userInfo: { }
21+
userInfo: { },
22+
fireDate: new Date(),
2223
});
2324
```
2425

@@ -45,7 +46,8 @@ let someLocalNotification = Notifications.postLocalNotification({
4546
title: "Local Notification Title",
4647
sound: "chime.aiff",
4748
category: "SOME_CATEGORY",
48-
userInfo: { }
49+
userInfo: { },
50+
fireDate: new Date(),
4951
});
5052

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

7476

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

77-
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:
79+
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:
7880

7981
```jsx
8082
Notifications.postLocalNotification({
@@ -84,4 +86,4 @@ Notifications.postLocalNotification({
8486
});
8587
```
8688

87-
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).
89+
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).
751 Bytes
Loading

website/static/img/favicon.ico

124 KB
Binary file not shown.

0 commit comments

Comments
 (0)