Hi there,
I’m trying to implement push notifications using OneSignal, but couldn’t get it working.
When calling any method from OneSignal, it stops.
Here are some informations:
cli packages: (/usr/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
local packages:
@ionic/app-scripts : 3.1.1
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Node : v11.9.0
npm : 6.7.0
OS : Linux 4.20
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
and the code:
import { OneSignal } from '@ionic-native/onesignal/ngx';
export class MyApp {
constructor(platform: Platform, oneSignal: OneSignal) {
platform.ready().then(() => {
if (platform.is('cordova')) {
oneSignal.setLogLevel({ logLevel: 6, visualLevel: 0 });
oneSignal.startInit("foo", "bar");
oneSignal.inFocusDisplaying(oneSignal.OSInFocusDisplayOption.InAppAlert);
oneSignal.handleNotificationReceived().subscribe(notif => {
// on notification received
});
oneSignal.handleNotificationOpened().subscribe(notif => {
// on notification opened
});
oneSignal.endInit();
} else {
console.log("no push notifications");
}
});
}
When launching the app, here is the error using adb logcat
(yes, not very verbose):
02-08 10:47:00.261 12654 12654 D SystemWebChromeClient: file:///android_asset/www/build/vendor.js: Line 1 : ERROR
02-08 10:47:00.261 12654 12654 I chromium: [INFO:CONSOLE(1)] "ERROR", source: file:///android_asset/www/build/vendor.js (1)
Anyone got an idea?
Thanks!
EDIT: sure, OneSignal is provided in app.module.ts
EDIT2: using some console.log
between oneSignal’s calls shows that it stops on first call (here, setLogLevel
), and same behavior when starting with startInit