Closed noor07 closed 6 years ago
Hi there, you can no longer run 'ionic serve' when you have this plugin installed, that is why you see this error. You will need to emulate your app / run it on a real device OR simply click the 'close' button and you can still view your app, but whenever you make an update, the error will show again.
@T-Munyaka @noor07
In order to avoid this problem, you can put your one signal initialization code in an if statement that check whether you are running the app on a device or a browser. Change the code in your app.component.ts to this:
// check if in browser or on device before running OneSignal Code
if(platform.is('core') || platform.is('mobileweb')) {
console.log("Platform is core or is mobile web");
} else {
var notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
};
window["plugins"].OneSignal
.startInit("<< APPID>>", "<<GOOGLE PROJECT ID>>")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
}
@charis-the-programmer
your code it's not working for me the error still showing
lets see your code in app.component.ts
@charis-the-programmer your code is working for me.
Runtime Error Uncaught (in promise): TypeError: Cannot read property 'OneSignal' of undefined TypeError: Cannot read property 'OneSignal' of undefined at http://localhost:8100/build/main.js:803:31 at t.invoke (http://localhost:8100/build/polyfills.js:3:14976) at Object.onInvoke (http://localhost:8100/build/vendor.js:4982:33) at t.invoke (http://localhost:8100/build/polyfills.js:3:14916) at r.run (http://localhost:8100/build/polyfills.js:3:10143) at http://localhost:8100/build/polyfills.js:3:20242 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4973:33) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581) at r.runTask (http://localhost:8100/build/polyfills.js:3:10834)
Hey Everyone, i got an error in IONIC 3, i already install the plugin and go through the onesignal docs, but there is still an error