Skip to content
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

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

Closed
2 of 4 tasks
dotrub opened this issue Nov 9, 2019 · 1 comment · Fixed by #2490
Closed
2 of 4 tasks

Comments

@dotrub
Copy link
Contributor

dotrub commented Nov 9, 2019

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)

  • Android
  • iOS
  • Electron
  • Web

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.

@dotrub dotrub changed the title bug: LocalNotification.schedule does not return a LocalNotificationScheduleResult bug: LocalNotification.schedule does not return a LocalNotificationScheduleResult on iOS or Android Nov 9, 2019
@jcesarmobile jcesarmobile added this to the 2.0.0 milestone Jan 16, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 12, 2022

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants