ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.04k stars 999 forks source link

bug: LocalNotification.schedule does not return a LocalNotificationScheduleResult on iOS or Android #2152

Closed dotrub closed 4 years ago

dotrub commented 4 years ago

Bug Report

Capacitor Version

npx cap doctor output:

Latest Dependencies:

@capacitor/cli: 1.3.0

@capacitor/core: 1.3.0

@capacitor/android: 1.3.0

@capacitor/ios: 1.3.0

Installed Dependencies:

@capacitor/cli 1.3.0

@capacitor/core 1.3.0

@capacitor/ios 1.3.0

@capacitor/android 1.3.0

[success] Android looking great! 👌 Found 2 Capacitor plugins for ios: cordova-plugin-safariviewcontroller (1.6.0) cordova-plugin-whitelist (1.3.4) [success] iOS looking great! 👌

Affected Platform(s)

Current Behavior

The type definitions for core-plugin-definitions.ts says that the result of LocalNotifications.schedule should be Promise<LocalNotificationScheduleResult>, where LocalNotificationScheduleResult simply extends LocalNotificationPendingList. LocalNotificationPendingList is an object containing a key of notifications which is a list of LocalNotificationRequest.

When I call LocalNotifications.schedule on iOS or Android, I get an object containing a key ids, mapped to a list of LocalNotificationRequest. Looking at the source code (links below), one can see that the implementation of schedule on iOS and Android is returning the wrong type of object. The web implementation is returning the correct shape.

Expected Behavior

Calling LocalNotification.schedule should produce a result that matches its type definition, especially since that type definition is exported.

Reproduction Steps

Comparing these 3 URLs is enough to see that the return type is incorrect: https://github.com/ionic-team/capacitor/blob/master/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift#L90 https://github.com/ionic-team/capacitor/blob/master/android/capacitor/src/main/java/com/getcapacitor/plugin/LocalNotifications.java#L74 https://github.com/ionic-team/capacitor/blob/master/core/src/core-plugin-definitions.ts#L974

Other Technical Details

npm --version output: 6.9.0

node --version output: v10.16.3

pod --version output (iOS issues only): 1.7.1

Other Information

The type definition can be updated to match the shape returned by iOS and Android, but that means also updating the web implementation of the plugin to return that shape as well. I think it's preferable to update the iOS and Android implementations to return the correct type.

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.