From b89fb15c0fac98aebd436351d5d5279c7f3f8ee2 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Tue, 25 Feb 2020 20:02:12 +0100 Subject: [PATCH] fix(LocalNotifications): return proper LocalNotificationScheduleResult on schedule (#2490) --- .../com/getcapacitor/plugin/LocalNotifications.java | 12 +++++++++++- core/src/web/local-notifications.ts | 2 +- .../Capacitor/Plugins/LocalNotifications.swift | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java index 6b5b1e5c63..b129990bf6 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java @@ -71,7 +71,17 @@ public void schedule(PluginCall call) { } JSONArray ids = manager.schedule(call, localNotifications); notificationStorage.appendNotificationIds(localNotifications); - call.success(new JSObject().put("ids", ids)); + JSObject result = new JSObject(); + JSArray jsArray = new JSArray(); + for (int i=0; i < ids.length(); i++) { + try { + JSObject notification = new JSObject().put("id", ids.getString(i)); + jsArray.put(notification); + } catch (Exception ex) { + } + } + result.put("notifications", jsArray); + call.success(result); } @PluginMethod() diff --git a/core/src/web/local-notifications.ts b/core/src/web/local-notifications.ts index 24bb64b056..8ae1636a77 100644 --- a/core/src/web/local-notifications.ts +++ b/core/src/web/local-notifications.ts @@ -66,7 +66,7 @@ export class LocalNotificationsPluginWeb extends WebPlugin implements LocalNotif }); return Promise.resolve({ - notifications: notifications.map(_ => { return { id: '' }; }) + notifications: options.notifications.map(notification => { return { id: '' + notification.id }; }) }); } diff --git a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift index c19c8c763e..a8f578d100 100644 --- a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift +++ b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift @@ -86,8 +86,13 @@ public class CAPLocalNotificationsPlugin : CAPPlugin { ids.append(request.identifier) } + let ret = ids.map({ (id) -> [String:String] in + return [ + "id": id, + ] + }) call.success([ - "ids": ids + "notifications": ret ]) }