0
votes

I am using Ionic2 and am building a Chat App with Push Messaging. I am using FCM (Firebase Cloud Messaging). I followed the following tutorial which uses the phonegap-plugin-push plugin, and everything was working perfectly.

My PC then crashed and I had to reinstall all my Cordova plugins. Since then, the Push Notifications are causing the app to crash. When I try initialise Push and the following code is invoked:

import { StatusBar, Push, SQLite } from 'ionic-native';
                    ...

            let push = Push.init({
              android: {
                senderID: "XXXXXXXXXXXXXX",
                topics: topics
              },
              ios: {
                alert: "true",
                badge: false,
                sound: "true",
                topics: topics
              },
              windows: {}
            });

I get the following error with nothing in the logs:

enter image description here

If I don't make use of Push it works with no errors, but I obviously want to use Push Notifications.

If anyone has any suggestions, I would appreciate it.

I have tried the following with no success:

  1. Reinstall all Cordova Plugins
  2. Created a new FCM project and used its SENDER_ID
  3. Remove & Add the android platform (ionic platform remove android & ionic platform add android)
  4. Tried reinstalling Ionic Native (npm install ionic-native --save)

More info:

E:\Development\IDE\ionic-apps\theWhoZoo>cordova plugin list
cordova-plugin-camera 2.2.0 "Camera"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.3 "Console"
cordova-plugin-crop 0.1.0 "CropPlugin"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-geolocation 2.2.0 "Geolocation"
cordova-plugin-network-information 1.3.0 "Network Information"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
cordova-sqlite-plugin 3.0.0 "Cordova SQLite Plugin"
cordova-sqlite-storage 1.4.8 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 1.8.3 "PushPlugin"
plugin.google.maps 1.3.9 "phonegap-googlemaps-plugin"

npm install gives me the following:

....

npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.

> [email protected] postinstall E:\Development\IDE\ionic-apps\theWhoZoo\node_modules\ionic-gulp-sass-build\node_modules\gulp-sass\node_modules\node-sass
> node scripts/build.js

"E:\Development\IDE\ionic-apps\theWhoZoo\node_modules\ionic-gulp-sass-build\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-x64-48\binding.node" exists.
 testing binary.
Binary is fine; exiting.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Richard\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.2.2
npm ERR! npm  v2.15.11
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @angular/[email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/[email protected] wants @angular/compiler@^2.0.0-rc.4
npm ERR! peerinvalid Peer @angular/[email protected] wants @angular/[email protected]
npm ERR! peerinvalid Peer [email protected] wants @angular/compiler@^2.0.0
npm ERR! peerinvalid Peer @angular/[email protected] wants @angular/[email protected]
npm ERR! peerinvalid Peer @angular/[email protected] wants @angular/[email protected]

npm ERR! Please include the following file with any support request:
npm ERR!     E:\Development\IDE\ionic-apps\theWhoZoo\npm-debug.log
1

1 Answers

0
votes

try to this way:

  1. use "phonegap-plugin-push 1.8.4"
  2. Don't use native "import {StatusBar, Push, SQLite } from 'ionic-native';"
  3. try with import { Push, PushToken } from '@ionic/cloud-angular'; (youpage.ts)
  4. import { CloudSettings, CloudModule } from '@ionic/cloud-angular'; (app.module.ts)

     const cloudSettings: CloudSettings = { 'core': {
                'app_id': 'xxx'
              },
              'push': {
                'sender_id': 'yyy',
                'pluginConfig': {
                  'ios': {
                    'badge': true,
                    'sound': true
                  },
                  'android': {
                    'iconColor': '#ff0000'
                  }
                }
              }
            };
    

Its working for me.