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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: for plugins the removeAllListeners function does not exist on iOS #7435

Open
1 of 3 tasks
JanMisker opened this issue Apr 28, 2024 · 6 comments
Open
1 of 3 tasks
Labels
platform: ios type: bug A confirmed bug report

Comments

@JanMisker
Copy link
Contributor

Capacitor Version

[warn] The bundledWebRuntime configuration option has been deprecated. Can be safely deleted.
馃拪 Capacitor Doctor 馃拪

Latest Dependencies:

@capacitor/cli: 6.0.0
@capacitor/core: 6.0.0
@capacitor/android: 6.0.0
@capacitor/ios: 6.0.0

Installed Dependencies:

@capacitor/cli: 6.0.0
@capacitor/core: 6.0.0
@capacitor/ios: 6.0.0
@capacitor/android: 6.0.0

[success] iOS looking great! 馃憣
[success] Android looking great! 馃憣

Other API Details

% npm --version       
10.5.0
% node --version
v18.20.2
% pod --version
1.15.2

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

On iOS the removeAllListeners() function on plugins is undefined, whereas on Android it exists as expected.
I reproduced for PushNotifications but also checked it via console for built-in plugins like Camera.

Maybe has to do with this: https://capacitorjs.com/docs/updating/plugins/6-0#remove-removealllisteners-method

Expected Behavior

The removeAllListeners() function should work the same on iOS and Android.

Project Reproduction

https://github.com/JanMisker/TestPushNotifRemoveAll

Additional Information

No response

@jcesarmobile
Copy link
Member

The provided app doesn't include any removeAllListeners() call, can you update it?

Are you sure you updated correctly? looks like you updated your plugins to Capacitor 6 but you are still using @capacitor/ios 5.x.

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Apr 29, 2024
@ionitron-bot ionitron-bot bot removed the triage label Apr 29, 2024
@JanMisker
Copy link
Contributor Author

Sorry my bad I wasn't using the src dir, I modified the repository to show the issue. I just put everything in src/index.html.
I do use the 6 version of ios, as you can see in the package.json.

Below screenshot of what happens when running on iOS vs. Android emulator

iOS:
Screenshot 2024-04-29 at 13 56 18

Android:
Screenshot 2024-04-29 at 13 56 50

@Ionitron Ionitron removed the needs reply needs reply from the user label Apr 29, 2024
@jcesarmobile jcesarmobile added platform: ios type: bug A confirmed bug report labels Apr 29, 2024
Copy link

ionitron-bot bot commented Apr 29, 2024

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

@jcesarmobile
Copy link
Member

Oh, yeah, since you changed the sample to not import the plugin, the common methods like removeAllListeners don't get generated since that's generated from javascript.

I guess we could generate it from native too as we do for addListeners so it's available even if the plugin is not imported.

But if you import the plugin, the removeAllListeners method is available and works as expected, the problem is just a matter of generating method for being accessible from Capacitor.Plugins.PluginName, which is technically deprecated.

@JanMisker
Copy link
Contributor Author

JanMisker commented Apr 29, 2024

One of our projects is really old and "vanilla" javascript, not using modules. So we'd have to find a way to include that generated plugin code without imports.

Still, isn't it strange that that same sample project, so without importing the plugin, does seem to work on Android? In the sense that the function is not undefined as you can see in the 2nd screenshot.

@jcesarmobile
Copy link
Member

This is an iOS issue only, on Android the plugins methods have annotations that auto generate the javascript and removeAllListeners is one of the base plugin class methods, but on iOS no such thing exists, so they have to be generated programmatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: ios type: bug A confirmed bug report
Projects
None yet
Development

No branches or pull requests

3 participants