capacitor: bug: Plugins stop working after re-compilation
Bug Report
Capacitor Version
npx cap doctor output:
π Capacitor Doctor π
Latest Dependencies:
@capacitor/cli: 2.0.2
@capacitor/core: 2.0.2
@capacitor/android: 2.0.2
@capacitor/electron: 2.0.2
@capacitor/ios: 2.0.2
Installed Dependencies:
@capacitor/electron not installed
@capacitor/cli 2.0.0
@capacitor/android 2.0.0
@capacitor/ios 2.0.0
@capacitor/core 2.0.0
Affected Platform(s)
- Android
- iOS
- Electron
- Web
Current Behavior
Whenever I re-compile my app ionic capacitor copy there is a ~40% chance that all my plugins stop working. The Plugins Iβm currently using are [Device, PushNotifications, Storage, SplashScreen, and AdMob].
When I say stop working, there are two specific cases in mind:
- For PushNotifications, no callbacks are ever fired, I call
PushNotifications.register();, butPushNotifications.addListener('registration')nor any other listener fire. - More on PushNotifications, if the register callback is triggered, sometimes both foreground and background notifications continue to work, other times only background notifications work.
- For Storage, I call
Storage.set()and it never even saves the value to memory.
I specifically notice this starts getting buggy when I install new npm packages or clear the cache of XCode or Android Studio.
Expected Behavior
After successfully confirming Plugins like PushNotifications and Storage work in iOS/Android⦠rebuilding the project with ionic capacitor copy should not stop Plugins from working.
If I clear my cache in XCode or Android Studio, Iβd expect running
npx cap sync && cd ios/app && pod install && cd ../../ && ionic capacitor copy should get everything re-synced and working again.
Iβd even optionally add: rm -rf ./node_modules && npm install before the commands above, but that still seems to be flaky.
Sample Code or Sample Application Repo
Reproduction Steps
I made a Github Repo where you can clone an MVP of testing device, storage, and push-notification plugins. The README has all steps to setup and test.
In this demo repo:
- Device plugin works in web + iOS + Android
- Storage plugin only works in web
- Push Notification plugin doesnβt work on iOS (register callback never triggered)
Other Technical Details
npm --version output:
6.11.3
node --version output:
v12.11.1
pod --version output (iOS issues only):
1.9.1
Other Information
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (2 by maintainers)
Okay I think I found the problem. It was something with my APNs certificates/keys.
I believe the certificate being used in my iOS app was not the same certificate that Firebase was using (Firebase uses keys).
I re-created some keys and certificates, reuploaded them all, and it finally works.