diff --git a/local-notifications/README.md b/local-notifications/README.md
index c45739244..caeb60db2 100644
--- a/local-notifications/README.md
+++ b/local-notifications/README.md
@@ -273,7 +273,7 @@ The object that describes a local notification.
| Prop | Type | Description | Since |
| -------- | ------------------- | ---------------------------- | ----- |
-| **`id`** | string
| The notification identifier. | 1.0.0 |
+| **`id`** | number
| The notification identifier. | 1.0.0 |
#### ScheduleOptions
diff --git a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotification.java b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotification.java
index 5582392d7..fe28faa69 100644
--- a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotification.java
+++ b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotification.java
@@ -252,7 +252,12 @@ public static JSObject buildLocalNotificationPendingList(List ids) {
JSArray jsArray = new JSArray();
for (String id : ids) {
JSObject notification = new JSObject();
- notification.put("id", id);
+ try {
+ int intId = Integer.parseInt(id);
+ notification.put("id", intId);
+ } catch (NumberFormatException ex) {
+ notification.put("id", -1);
+ }
jsArray.put(notification);
}
result.put("notifications", jsArray);
diff --git a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationsPlugin.java b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationsPlugin.java
index 8936c5d93..481285798 100644
--- a/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationsPlugin.java
+++ b/local-notifications/android/src/main/java/com/capacitorjs/plugins/localnotifications/LocalNotificationsPlugin.java
@@ -63,7 +63,7 @@ public void schedule(PluginCall call) {
JSArray jsArray = new JSArray();
for (int i = 0; i < ids.length(); i++) {
try {
- JSObject notification = new JSObject().put("id", ids.getString(i));
+ JSObject notification = new JSObject().put("id", ids.getInt(i));
jsArray.put(notification);
} catch (Exception ex) {}
}
diff --git a/local-notifications/ios/Plugin/LocalNotificationsHandler.swift b/local-notifications/ios/Plugin/LocalNotificationsHandler.swift
index dd42743f4..570ea4a4e 100644
--- a/local-notifications/ios/Plugin/LocalNotificationsHandler.swift
+++ b/local-notifications/ios/Plugin/LocalNotificationsHandler.swift
@@ -75,7 +75,7 @@ public class LocalNotificationsHandler: NSObject, NotificationHandlerProtocol {
func makeNotificationRequestJSObject(_ request: UNNotificationRequest) -> JSObject {
let notificationRequest = notificationRequestLookup[request.identifier] ?? [:]
return [
- "id": request.identifier,
+ "id": Int(request.identifier) ?? -1,
"title": request.content.title,
"sound": notificationRequest["sound"] ?? "",
"body": request.content.body,
diff --git a/local-notifications/ios/Plugin/LocalNotificationsPlugin.swift b/local-notifications/ios/Plugin/LocalNotificationsPlugin.swift
index 588ae3e14..1ee6e437b 100644
--- a/local-notifications/ios/Plugin/LocalNotificationsPlugin.swift
+++ b/local-notifications/ios/Plugin/LocalNotificationsPlugin.swift
@@ -88,7 +88,7 @@ public class LocalNotificationsPlugin: CAPPlugin {
let ret = ids.map({ (id) -> JSObject in
return [
- "id": id
+ "id": Int(id) ?? -1
]
})
call.resolve([
@@ -137,7 +137,14 @@ public class LocalNotificationsPlugin: CAPPlugin {
return
}
- let ids = notifications.map { $0["id"] as? String ?? "" }
+ let ids = notifications.map({ (value: JSObject) -> String in
+ if let idString = value["id"] as? String {
+ return idString
+ } else if let idNum = value["id"] as? NSNumber {
+ return idNum.stringValue
+ }
+ return ""
+ })
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: ids)
call.resolve()
@@ -534,7 +541,7 @@ public class LocalNotificationsPlugin: CAPPlugin {
func makePendingNotificationRequestJSObject(_ request: UNNotificationRequest) -> JSObject {
return [
- "id": request.identifier
+ "id": Int(request.identifier) ?? -1
]
}
diff --git a/local-notifications/src/definitions.ts b/local-notifications/src/definitions.ts
index 3f9fe329f..35e6075d9 100644
--- a/local-notifications/src/definitions.ts
+++ b/local-notifications/src/definitions.ts
@@ -162,7 +162,7 @@ export interface LocalNotificationDescriptor {
*
* @since 1.0.0
*/
- id: string;
+ id: number;
}
export interface ScheduleOptions {
diff --git a/local-notifications/src/web.ts b/local-notifications/src/web.ts
index 185135651..4cb2eee12 100644
--- a/local-notifications/src/web.ts
+++ b/local-notifications/src/web.ts
@@ -35,7 +35,7 @@ export class LocalNotificationsWeb
return {
notifications: options.notifications.map(notification => ({
- id: notification.id.toString(),
+ id: notification.id,
})),
};
}
@@ -43,7 +43,7 @@ export class LocalNotificationsWeb
async getPending(): Promise {
return {
notifications: this.pending.map(notification => ({
- id: notification.id.toString(),
+ id: notification.id,
})),
};
}
@@ -55,7 +55,7 @@ export class LocalNotificationsWeb
async cancel(pending: ScheduleResult): Promise {
this.pending = this.pending.filter(
notification =>
- !pending.notifications.find(n => n.id === notification.id.toString()),
+ !pending.notifications.find(n => n.id === notification.id),
);
}