OneSignal issue

So I am trying to implement OneSignal with my Ionic 2 app.

I followed https://ionicframework.com/docs/native/onesignal/ for installation and then I imported

import { OneSignal } from '@ionic-native/onesignal'; in my app.component.ts

Put private oneSignal: OneSignal in the constructor.

And then put

this.oneSignal.startInit(ONE SIGNAL APP ID);
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.endInit();

this.oneSignal.handleNotificationOpened().subscribe((jsonData) => {
    console.log(jsonData);
});

inside the this.platform.ready().then(() => {});

When I try to run this in my android device, I am getting

console.error: EXCEPTION: Error in :0:0 caused by: No provider for OneSignal! error.

What might be the issue?

Fixed it. Had to import OneSignal as a provider in app.module.ts.

4 Likes