One signal using ionic


#1

Hi,

I tried push notifications for ionic app.

First i installed the one signal plugin.

ionic cordova plugin add onesignal-cordova-plugin
 npm install --save @ionic-native/onesignal

Here is my code

this.platform.ready().then(() => {
      this.oneSignal.getIds().then((ids)=>{
          console.log("USER ID");
          console.log(ids.userId);
        }).catch((e)=>{
          console.log("error")
          console.log(e);
        })
    })

But does not get app id.why?

The error is plugin_not_installed.

I remove this plugin again added.

But still get the same error.

Kindly advice me,

Thanks.


#2

How and where are you testing?
What is your ionic info output?


#3

Thanks for ur reply.My ionic info

global packages:

    @ionic/cli-utils : 1.5.0
    Ionic CLI        : 3.5.0

System:

    Node       : v6.10.3
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 3.10.10

I tested on real device.


#4

Please run ionic info in your project directory.


#5

Here my project directory

global packages:

    @ionic/cli-utils : 1.5.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.5.0

local packages:

    @ionic/app-scripts              : 1.3.12
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.2.3
    Ionic Framework                 : ionic-angular 3.5.0

System:

    Node       : v6.10.3
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 3.10.10

#6

You have to run

this.onesignal.startInit(x);

where x is your app Id before you run anything else. After, run the handle notification received and opened commands, then end init. You can find that easily if you google it.
After ending init, you can start getting id’s, etc.

And that’s only possible if you manage to figure out how to get Ionic and onesignal to work together. It’s difficult to get going these days.


#7

Hi @anivaishu!

Sample project that shows how to integrate OneSignal in Ionic: