Failed to setup OneSignal in Ionic2


#1

Hi,

I use OneSignal for push notification, as their instruction I added code as following:

// Call any initial plugins when ready
platform.ready().then(() => {

StatusBar.styleDefault();
Splashscreen.hide();

alert(“Before init”);

// Enable to debug issues.
window[“plugins”].OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});

var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ’ + JSON.stringify(jsonData));
};

window[“plugins”].OneSignal.init(
“2aca2c26-790b-4f00-b5a1-56130206d6e2”,
{googleProjectNumber: “529504018999”, autoRegister: true},
notificationOpenedCallback
);

// Show an alert box if a notification comes in when the user is in your app.
window[“plugins”].OneSignal.enableInAppAlertNotification(true);

alert(“After init”);

});

It doesn’t work (no subscriber in dashboard). When I check source compiled in JS file (app.bundle.js), I got this below:
// Call any initial plugins when ready
platform.ready().then(function () {
ionic_native_1.StatusBar.styleDefault();
ionic_native_1.Splashscreen.hide();
});

Perhaps you guys can help me to explain this symptom and help me to get over this integration problem.
Many thanks!


#2

UPDATED!

I’ve successfully integrate this awesome OneSignal to Ionic2, after reinstall ionic@beta.


#3

Hello, you can share how to integrate the OneSignal with Ionic, I have been able to implement Ionic Push, however need OneSignal (Sorry for my English is not my native language)