You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building PWA (browser platform) plugin starts to interfere with Service Worker from Web SDK. This causes Service Worker to throw exceptions (many different types). The only way I found how to fix that is to manually edit the /platforms/browser/platform_www/cordova_plugins.js file and remove everything linked to cordova-onesignal-plugin.
Steps to reproduce?
Install both onesignal-cordova-plugin and Web SDK Service Worker. First for iOS and Android, second for PWA. Setup Web SDK, install PWA to the phone. Open it, subscribe (see Quick Start guide), nothing special. Then close PWA and open it again: you will get exceptions. Refreshing a page sometimes helps. Sometimes you need to stop SW and clear site data. But every time when your PWA is closed and you receive push - PWA will open with exceptions. Tested on Android 14 in Chrome.
Remove onesignal-cordova-plugin (or modify cordova_plugins.js file in browser platform) and PWA will immediately start to work like a charm.
What did you expect to happen?
Plugin not installed for the browser platform, /platforms/browser/platform_www/cordova_plugins.js does not contain any mention of this plugin.
In onesignal's case, they are providing a JS module for all platforms (because it's not isolated inside a block. If onesignal uses an alternate library for the browser that isn't a cordova plugin, then they should be able to move
into the block, but they'll need to have 2 copies of it, one for iOS and one for android. This should prevent the JS module from being installed for browser targets, but have it installed for iOS and android targets. Again suggesting this more as a workaround, but if one signal's plugin doesn't support browser, it might be better for one signal to adjust their config so it won't be installed on browser targets to begin with.
OneSignal Cordova SDK version
5
Which platform(s) are affected?
iOS
Android
Relevant log output
Uncaught (in promise) n: OneSignal.context is undefined. Make sure to call OneSignal.init() before calling getPermissionStatus().
at pe.<anonymous> (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160101:1:42784)
at Generator.next (<anonymous>)
at https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160101:1:260596
at new Promise (<anonymous>)
at o (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160101:1:260341)
at pe.getPermissionStatus (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160101:1:42723)
at nn.<anonymous> (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160101:1:219668)
at Generator.next (<anonymous>)
at r (https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.es6.js?v=160101:1:260398)
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'userConfig')
at bi.<anonymous> (InitHelper.js:291:47)
at Generator.next (<anonymous>)
at tslib.es6.js:121:71
at new Promise (<anonymous>)
at o (tslib.es6.js:117:12)
at bi.handleAutoResubscribe (OneSignalSDK.page.es6.js?v=160101:1:170304)
at bi.<anonymous> (InitHelper.js:63:26)
at Generator.next (<anonymous>)
at r (tslib.es6.js:118:58)
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'serviceWorkerManager')
at bi.<anonymous> (InitHelper.js:20:33)
at Generator.next (<anonymous>)
at tslib.es6.js:121:71
at new Promise (<anonymous>)
at o (tslib.es6.js:117:12)
at bi.internalInit (OneSignalSDK.page.es6.js?v=160101:1:163203)
at OneSignal.js:141:30
at Generator.next (<anonymous>)
at r (tslib.es6.js:118:58)
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'subscriptionManager')
at bi.<anonymous> (InitHelper.js:58:52)
at Generator.next (<anonymous>)
at r (tslib.es6.js:118:58)
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
What happened?
When building PWA (
browser
platform) plugin starts to interfere with Service Worker from Web SDK. This causes Service Worker to throw exceptions (many different types). The only way I found how to fix that is to manually edit the/platforms/browser/platform_www/cordova_plugins.js
file and remove everything linked tocordova-onesignal-plugin
.Steps to reproduce?
Install both
onesignal-cordova-plugin
and Web SDK Service Worker. First for iOS and Android, second for PWA. Setup Web SDK, install PWA to the phone. Open it, subscribe (see Quick Start guide), nothing special. Then close PWA and open it again: you will get exceptions. Refreshing a page sometimes helps. Sometimes you need to stop SW and clear site data. But every time when your PWA is closed and you receive push - PWA will open with exceptions. Tested on Android 14 in Chrome.Remove
onesignal-cordova-plugin
(or modifycordova_plugins.js
file inbrowser
platform) and PWA will immediately start to work like a charm.What did you expect to happen?
Plugin not installed for the
browser
platform,/platforms/browser/platform_www/cordova_plugins.js
does not contain any mention of this plugin.Dev from Cordova asked to my issue about that: apache/cordova-lib#892 (comment)
OneSignal Cordova SDK version
5
Which platform(s) are affected?
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: