Trying to init Push Notifications


#1

Hi,

I’m trying to config Push Notification Native plugin to my app, I think is all right but I don’t know why I got this warning:

Native: tried calling PushNotification.init, but the PushNotification plugin is not installed.

I need a help.

package.json

"@angular/common": "^4.1.3",
  "@angular/compiler": "^4.1.3",
  "@angular/compiler-cli": "^4.1.3",
  "@angular/core": "^4.1.3",
  "@angular/forms": "^4.1.3",
  "@angular/http": "^4.1.3",
  "@angular/platform-browser": "^4.1.3",
  "@angular/platform-browser-dynamic": "^4.1.3",
  "@ionic-native/core": "^4.1.3",
  "@ionic-native/geolocation": "^4.0.0",
  "@ionic-native/google-maps": "^4.0.0",
  "@ionic-native/launch-navigator": "^4.0.1",
  "@ionic-native/splash-screen": "3.12.1",
  "@ionic-native/status-bar": "3.12.1",
  "@ionic-native/web-intent": "^4.0.1",
  "@ionic/storage": "^2.0.1",
  "@types/google-maps": "^3.2.0",
  "angularfire2": "^4.0.0-rc.1",
  "com-darryncampbell-cordova-plugin-intent": "0.0.14",
  "cordova-android": "^7.1.0",
  "cordova-plugin-actionsheet": "^2.3.3",
  "cordova-plugin-compat": "^1.1.0",
  "cordova-plugin-device": "^1.1.4",
  "cordova-plugin-dialogs": "^1.3.3",
  "cordova-plugin-geolocation": "^2.4.3",
  "cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
  "cordova-plugin-splashscreen": "^4.0.3",
  "cordova-plugin-statusbar": "^2.2.2",
  "cordova-plugin-whitelist": "^1.3.1",
  "cordova-sqlite-storage": "^2.0.4",
  "firebase": "^4.1.3",
  "ionic-angular": "3.5.0",
  "ionic-plugin-keyboard": "^2.2.1",
  "ionicons": "3.0.0",
  "rxjs": "5.4.0",
  "sw-toolbox": "3.6.0",
  "uk.co.workingedge.phonegap.plugin.launchnavigator": "^4.0.1",
  "zone.js": "0.8.12"

app.component.ts

initializeApp() {
this.platform.ready().then(() => {
this.pushSetup();
});
}

pushSetup() {
const options: PushOptions = {
android: { senderID: ‘256624249194’ },
ios: {
alert: ‘true’,
badge: true,
sound: ‘false’
}
};

const pushObject: PushObject = this.push.init(options);

pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));

pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));

pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));

}

<plugin name="phonegap-plugin-push" spec="^2.1.2">
    <variable name="SENDER_ID" value="256624249194" />
</plugin>

I miss something?

Victor Magalhães.


#2

How do you send notifications?


#3

Via FCM on Firebase Console @baldodavi


#4

Try to use the java code in this tutorial.
https://medium.com/@ankushaggarwal/push-notifications-in-ionic-2-658461108c59 and take a look to
https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md . I’ve some issues with Firebase Console messages generation and cordova plugin


#5

You just add this plugin in your package.json file dependencies and then once again install the node modules

“phonegap-plugin-push”: “^2.2.2”,

In my case solved it.


#6

@sabarinathen doesn’t work :confused:
@baldodavi thanks for the tip