Nativescript Firebase plugin - “cannot read property of null” after upgrade to NS 3.4.0 - firebase

My angular - Nativescript project uses the Nativescript-Firebase-Plugin. It works perfectly well in Nativescript 3.3
I upgraded my project to Nativescript 3.4. After upgrading the project, I am facing a major issue with all firebase queries.
**JS: Error in firebase.query: TypeError: Cannot read property 'child' of null**
JS: NO QUESTIONS FOR THIS USER
JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'length' of undefined
JS: TypeError: Cannot read property 'length' of undefined
JS: at file:///data/data/org.nativescript.qbank/files/app/feed/alphaCreate.component.js:55:23
JS: at SafeSubscriber.schedulerFn [as _next] (file:///data/data/org.nativescript.qbank/files/app/tns_modules/#angular/core/bundles/core.umd.js:3870:36)
JS: at SafeSubscriber.__tryOrUnsub (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:238:16)
JS: at SafeSubscriber.next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:185:22)
JS: at Subscriber._next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:125:26)
JS: at Subscriber.next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subscriber.js:89:18)
JS: at EventEmitter.Subject.next (file:///data/data/org.nativescript.qbank/files/app/tns_modules/rxjs/Subject.js:55:25)
JS: at EventEmitter.emit (file:///data/data/org.nativescript.qbank/files/app/tns_modules/#angular/core/bundles/core.umd.js:3844:76)
JS: at file:///data/data/org.nativescript.qbank/files/app/services/my-questions.service.js:51:42
JS: at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:365:26)
JS: at Object.onInvoke (file:///data/data/org.nativescript.qbank/files/app/tns_modules/#angular/core/bundles/core.umd.js:4156:37)
JS: at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:364:32)
JS: at Zone.run (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:125:43)
JS: at file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:760:57
JS: at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.qbank/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:398:31)
I tried to resolve it by
a. upgrading the native script firebase plugin: 5.0.5
b. upgrading all the dependenices of the project
But the issue is still occurring. This is a big blocker, and Please suggest what I can do to fix this.
My package json is as below:
{
"android": {
"markingMode": "none"
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.qbank",
"tns-ios": {
"version": "3.4.0"
},
"tns-android": {
"version": "3.4.0"
}
},
"dependencies": {
"#angular/animations": "~5.0.0",
"#angular/common": "~5.0.0",
"#angular/compiler": "~5.0.0",
"#angular/core": "~5.0.0",
"#angular/forms": "~5.0.0",
"#angular/http": "~5.0.0",
"#angular/platform-browser": "~5.0.0",
"#angular/platform-browser-dynamic": "~5.0.0",
"#angular/router": "~5.0.0",
"nativescript-algolia": "0.0.4",
"nativescript-angular": "~5.0.0",
"nativescript-camera": "^3.1.4",
"nativescript-email": "^1.5.1",
"nativescript-fancyalert": "^1.1.2",
"nativescript-filter-select": "^1.2.1",
"nativescript-geolocation": "^3.0.0",
"nativescript-gif": "^1.0.9",
"nativescript-imagepicker": "^4.0.1",
"nativescript-iqkeyboardmanager": "^1.1.0",
"nativescript-loading-indicator": "^2.3.2",
"nativescript-plugin-firebase": "^5.0.5",
"nativescript-pro-ui": "^3.3.0",
"nativescript-theme-core": "~1.0.4",
"nativescript-toast": "^1.4.5",
"nativescript-web-image-cache": "^4.2.2",
"reflect-metadata": "~0.1.8",
"rxjs": "^5.5.0",
"tns-core-modules": "^3.4.0"
},
"devDependencies": {
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
"codelyzer": "~4.0.2",
"es6-promise-loader": "^1.0.2",
"lazy": "1.0.11",
"nativescript-dev-typescript": "^0.6.0",
"tslint": "^5.1.0",
"typescript": "~2.4.2",
"zone.js": "^0.8.4"
}
}

The problem was that firebase was not initialising. I solved this by putting firebase init in a timeout.

Related

ERROR Error: Uncaught (in promise): TypeError: i.BehaviorSubject is not a constructor in Angular 10 SSR

I'm getting this issue after build successfully and run on browser with angular universal
Here is my package json :
{
"name": "ssr",
"version": "1.0.0",
"private": true,
"dependencies": {
"#angular/animations": "10.0.5",
"#angular/cdk": "10.1.0",
"#angular/common": "10.0.5",
"#angular/compiler": "10.0.5",
"#angular/core": "10.0.5",
"#angular/fire": "^6.0.2",
"#angular/forms": "10.0.5",
"#angular/http": "^7.2.16",
"#angular/localize": "^10.0.5",
"#angular/material": "10.1.0",
"#angular/material-moment-adapter": "10.1.0",
"#angular/platform-browser": "10.0.5",
"#angular/platform-browser-dynamic": "10.0.5",
"#angular/platform-server": "^10.0.5",
"#angular/router": "10.0.5",
"#ng-bootstrap/ng-bootstrap": "^7.0.0",
"#ng-toolkit/universal": "^8.1.0",
"#nguniversal/express-engine": "^10.0.1",
"#types/jquery": "^3.5.1",
"#types/node": "^8.10.62",
"angular-in-memory-web-api": "^0.11.0",
"angular-ng-autocomplete": "^2.0.1",
"classlist.js": "^1.1.20150312",
"codelyzer": "^6.0.0",
"core-js": "2.6.9",
"crypto-js": "^3.3.0",
"express": "^4.15.2",
"firebase": "^7.17.1",
"hammerjs": "^2.0.8",
"jquery": "^3.5.1",
"localstorage-polyfill": "^1.0.1",
"moment": "2.24.0",
"ng2-slim-loading-bar": "^4.0.0",
"ng5-slider": "^1.1.14",
"ngx-order-pipe": "^2.0.4",
"ngx-pagination": "^3.2.1",
"ngx-spinner": "^10.0.1",
"rxjs": "^6.6.0",
"rxjs-compat": "^6.6.0",
"sweetalert2": "^8.19.0",
"tslib": "^1.13.0",
"web-animations-js": "^2.3.2",
"whatwg-fetch": "^3.2.0",
"zone.js": "0.10.3"
},
I just updated my project to Angular 10 and started facing this issue.
What i did was , wherever I had BehaviorSubject imports ,
i changed them from import { BehaviorSubject } from "rxjs/Rx"; to import { BehaviorSubject } from "rxjs";
This makes production build work without any error.
I got solution, use rxjs-tslint and migrate all rxjs syntax : https://www.npmjs.com/package/rxjs-tslint
I am able to solve this by using the build command as ng build --configuration=prod --aot= false --build-optimizer=false. Application is up and running for us now. But it's a work around only. We are trying to check few more ways without setting optimiser to false.Will update you.
I guess your question is solved,
I fixed it using ng build instead of ng build --prod. I am now investigating why the --prod command line compile my app differently
I guess your question is solved,
I fixed it using ng build instead of ng build --prod. I am now investigating why the --prod command line compile my app differently

#react-native-firebase breaking unit tests

I installed v6 of #react-native-firebase, it's working as expected but when I try to run a unit test I get the following error:
Jest encountered an unexpected token
Details:
/node_modules/#react-native-firebase/database/lib/index.js:18
import { isBoolean, isNumber, isString } from '#react-native-firebase/app/lib/common';
^
SyntaxError: Unexpected token {
I tried adding #react-native-firebase/database & #react-native-firebase/app to jest config transformIgnorePatterns and get the following error:
Test suite failed to run
Invariant Violation: Native module cannot be null.
at invariant (node_modules/invariant/invariant.js:40:15)
at RNFBNativeEventEmitter.NativeEventEmitter (node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:36:7)
at new RNFBNativeEventEmitter (node_modules/#react-native-firebase/app/lib/internal/RNFBNativeEventEmitter.js:24:5)
at Object.<anonymous> (node_modules/#react-native-firebase/app/lib/internal/RNFBNativeEventEmitter.js:48:16)
at Object.<anonymous> (node_modules/#react-native-firebase/app/lib/internal/registry/nativeModule.js:21:1)
I also tried mocking the module with Jest like so:
import * as FBCommon from '#react-native-firebase/app/lib/common'
jest.mock(FBCommon, () => {
return () => ({
isBoolean: jest.fn(),
isNumber: jest.fn(),
isString: jest.fn()
})
});
and like this:
jest.mock('#react-native-firebase/database', () => {
return () => ({
ref: jest.fn()
})
});
but get the same error, any suggestions?
my package.json:
{
"name": "Project",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/push-notification-ios": "^1.0.6",
"#react-native-firebase/app": "^6.3.1",
"#react-native-firebase/database": "^6.3.1",
"#react-native-firebase/messaging": "^6.3.1",
"axios": "^0.19.0",
"base-64": "^0.1.0",
"blinkid-react-native": "^5.2.0",
"firebase": "^7.6.0",
"lodash": "^4.17.15",
"mobx": "^5.15.0",
"mobx-persist": "^0.4.1",
"mobx-react": "^6.1.4",
"react": "16.9.0",
"react-native": "0.61.4",
"react-native-auth0": "^2.1.0",
"react-native-collapsible": "^1.5.1",
"react-native-config": "^0.12.0",
"react-native-confirmation-code-input": "^1.0.4",
"react-native-datepicker": "^1.7.2",
"react-native-device-info": "^5.4.1",
"react-native-elements": "^1.2.7",
"react-native-freshchat-sdk": "^2.3.0",
"react-native-gesture-handler": "^1.5.2",
"react-native-in-app-notification": "^3.0.1",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-phone-input": "^0.2.4",
"react-native-picker-select": "^6.3.3",
"react-native-push-notification": "^3.1.9",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "^1.0.0-alpha.23",
"react-native-signature-capture": "^0.4.10",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^8.0.3",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3"
},
"devDependencies": {
"#babel/core": "^7.7.2",
"#babel/runtime": "^7.7.2",
"#react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"babel-plugin-module-resolver": "^4.0.0",
"chai": "^4.1.2",
"chai-enzyme": "1.0.0-beta.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^6.6.0",
"jest": "^24.9.0",
"jsdom": "15.2.1",
"jsdom-global": "3.0.2",
"metro-react-native-babel-preset": "^0.57.0",
"react-dom": "^16.12.0",
"react-test-renderer": "16.9.0",
"sinon": "^7.2.2"
},
"jest": {
"preset": "react-native",
"setupFilesAfterEnv": [
"./setUpTests.js"
],
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|#react-native-firebase/database|#react-native-firebase/app|react-clone-referenced-element|expo(nent)?|#expo(nent)?/.*|react-navigation|#react-navigation/.*|sentry-expo|native-base))"
]
}
}
You could mock firebase database by creating a mock module in a mocks directory like this:
mkdir -p __mocks__/#react-native-firebase/database
touch index.js
And use jest mocking functions in index.js for the firebase version and database functionalities to test. Something along these lines:
const database = {
functionality1: jest.fn(() => ({
propertyExample1: jest.fn(() => Promise.resolve(true)),
...
})),
...
functionality2: jest.fn(() => ({
property2: jest.fn(() => Promise.resolve(true)),...
})),
};
export default database;
This occurs because the native emitter isn't properly mocked by the library. Adding the following snippet at the top of your tests can resolve this by ensuring the module isn't null.
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
I solved the issue creating jest.setup.js file with the content:
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
And then in package.json inside jest
"setupFiles": ["./yourPath/jest.setup.js"],

Ionic 3 Firebase Google Auth redirects to localhost instead of app

Im using AngularFire2 in my Ionic 3 Project. I have implemented Facebook and Google Login which worked before but somehow it stopped working (maybe because of changes in the Firebase SDK or Google?).
The problem Im facing now is that once a user logs in through google with redirect he logs in but doesnt get redirect back in my app. Instead google just displays this page on redirect:
Here is the Code im using for SignIn:
private oauthSignIn(provider: AuthProv) {
if (!(<any>window).cordova) {
return this.afAuth.auth.signInWithPopup(provider).then((user) => {
this.user = user.user;
});
} else {
return this.afAuth.auth.signInWithRedirect(provider)
.then(() => {
return this.afAuth.auth.getRedirectResult().then(result => {
this.user = result.user;
});
});
}
}
This code is from the AngularFire2 Documentation itself so I cant find any errors.
This is my package.json:
"dependencies": {
"#angular/animations": "5.2.11",
"#angular/common": "5.2.11",
"#angular/compiler": "5.2.11",
"#angular/compiler-cli": "5.2.11",
"#angular/core": "5.2.11",
"#angular/forms": "5.2.11",
"#angular/http": "5.2.11",
"#angular/platform-browser": "5.2.11",
"#angular/platform-browser-dynamic": "5.2.11",
"#ionic-native/admob-plus": "^5.8.0",
"#ionic-native/app-version": "^4.20.0",
"#ionic-native/core": "~4.20.0",
"#ionic-native/keyboard": "^5.8.0",
"#ionic-native/navigation-bar": "^5.8.0",
"#ionic-native/splash-screen": "~4.20.0",
"#ionic-native/status-bar": "~4.20.0",
"#ionic/storage": "2.2.0",
"#ultimate/ngxerrors": "^1.4.0",
"angularfire2": "^5.2.1",
"cordova-admob-plus": "0.30.0",
"cordova-android": "7.1.4",
"cordova-plugin-app-update": "2.0.2",
"cordova-plugin-app-version": "0.1.9",
"cordova-plugin-appversion": "1.0.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "4.1.1",
"cordova-plugin-navigationbar": "1.0.31",
"cordova-plugin-network-information": "git+https://github.com/apache/cordova-plugin-network-information.git",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-startapp-ads": "git+https://github.com/lreiner/cordova-plugin-startapp-ads.git",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"firebase": "^6.1.1",
"ionic-admob": "^0.19.6",
"ionic-angular": "3.9.5",
"ionicons": "3.0.0",
"phonegap-plugin-mobile-accessibility": "git+https://github.com/phonegap/phonegap-mobile-accessibility.git",
"promise-polyfill": "^8.1.3",
"rxjs": "5.5.11",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.29"
},
I have already tried this Solution and added:
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
<allow-navigation href="http://*" />
to my config.xml which also didnt change anything.
I also have tried to downgrade
"cordova-plugin-ionic-webview": "4.1.1",
which also didnt work.
My Google WebClient has the right ClientID, Secred and Redirect URL like in the Firebase Console.
So how can I solve this behavior?

Ionic 2 : Firebase Cloud Messaging and Google services errors

I have tried searching at a ton of places to get FCM working. I am using Google Authentication API and have just installed FCM to use Push Notifications. I would like to use both of them. When i do build I get these errors.
* What went wrong:
A problem occurred evaluating root project 'android'.
Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
BUILD FAILED
Total time: 3.002 secs
> For input string: "+"
This is my project.properties file
target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.+
cordova.system.library.2=com.google.android.gms:play-services-auth:+
cordova.system.library.3=com.google.android.gms:play-services-identity:+
cordova.system.library.4=com.android.support:support-v13:25.1.0
cordova.system.library.5=me.leolin:ShortcutBadger:1.1.17#aar
cordova.system.library.6=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.1=phonegap-plugin-push/starter-push.gradle
Couple of things I tried after reading lot of posts:
1. I removed and added android platform then did the build.
2. I tried changing the versions of below libraries to numerous values, but it does not help.
cordova.system.library.2=com.google.android.gms:play-services-auth:+
cordova.system.library.3=com.google.android.gms:play-services-identity:+
If try changing the version from + to 3.0.0 or 9.8.0 or any version I get this error for firebase
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
> Could not find com.google.firebase:firebase-messaging:11.0.1.
Required by:
project :
Note: Changing the same inside the build.gradle file dosen't help as it gets overridden when we do a build.
this is my package.json.
{
"name": "test",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"start": "node ./bin/www"
},
"dependencies": {
"#angular/common": "4.1.2",
"#angular/compiler": "4.1.2",
"#angular/compiler-cli": "4.1.2",
"#angular/core": "4.1.2",
"#angular/forms": "4.1.2",
"#angular/http": "4.1.2",
"#angular/platform-browser": "4.1.2",
"#angular/platform-browser-dynamic": "4.1.2",
"#ionic-native/core": "3.10.2",
"#ionic-native/facebook": "^3.10.2",
"#ionic-native/google-plus": "^3.12.1",
"#ionic-native/native-storage": "^3.10.3",
"#ionic-native/splash-screen": "3.10.2",
"#ionic-native/status-bar": "3.10.2",
"#ionic/storage": "2.0.1",
"body-parser": "^1.17.2",
"cordova-android": "^6.2.3",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-facebook4": "^1.9.0",
"cordova-plugin-googleplus": "^5.1.1",
"cordova-plugin-nativestorage": "^2.2.2",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"express": "^4.15.3",
"ionic-angular": "3.3.0",
"ionic-native": "^2.5.1",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"mongoose": "^4.11.4",
"morgan": "^1.8.2",
"phonegap-plugin-push": "^2.0.0",
"rxjs": "5.1.1",
"serve-favicon": "^2.4.3",
"socket.io": "^2.0.3",
"socket.io-client": "^2.0.3",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.11"
},
"devDependencies": {
"#ionic/app-scripts": "1.3.7",
"#ionic/cli-plugin-cordova": "1.6.2",
"#ionic/cli-plugin-ionic-angular": "1.4.1",
"ionic": "3.7.0",
"typescript": "2.3.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-facebook4": {
"APP_ID": "xxxxxxx2",
"APP_NAME": "test"
},
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "4xxxxxxxx6-7dsgct91usuntkmomme1n8rq5i7oipq8.apps.googleusercontent.com"
},
"phonegap-plugin-push": {
"SENDER_ID": "81xxxxx8690"
}
},
"platforms": [
"android"
]
},
"main": "index.js",
"keywords": [
"server"
],
"license": "ISC"
}
Can some one please help me out, suggest a better approach to implement Push notification. Thanks in advance!
Try to install Google Repository
Tools -> SDK Manager -> Google Repository
https://i.stack.imgur.com/qe8iu.png

Push notification is not working on Background

I'm using native firebase plugin's push notification feature.
Current behavior:
It is working fine with the foreground.But when the app is in the background and I try to tap the notification it shows undefined.Please see the video below.I have tested this on Anroid device.
Expected behavior:
When I tap the notification message it should open the app and show the message correctly.
Video
app.component.ts
constructor(public platform: Platform)
{
platform.ready().then(() => {
this.onNotificationOpen();
});
}
onNotificationOpen(): void {
if (this.platform.is('cordova')) {
this.firebase.onNotificationOpen()
.subscribe(res => {
if (res.tap) {//background mode
console.log(res.body);
this.showAlert(res.body);
} else if (!res.tap) {//foreground mode
console.log(res.body);
this.showAlert(res.body);
}
});
}
}
showAlert(message: string): void {
let alert = this.alertCtrl.create({
title: 'Push Notification',
subTitle: message,
buttons: ['OK']
});
alert.present();
}
package.json
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"#angular/common": "4.1.0",
"#angular/compiler": "4.1.0",
"#angular/compiler-cli": "4.1.0",
"#angular/core": "4.1.0",
"#angular/forms": "4.1.0",
"#angular/http": "4.1.0",
"#angular/platform-browser": "4.1.0",
"#angular/platform-browser-dynamic": "4.1.0",
"#ionic-native/core": "3.6.1",
"#ionic-native/device": "3.6.1",
"#ionic-native/facebook": "^3.10.0",
"#ionic-native/firebase": "^3.10.3",
"#ionic-native/keyboard": "^3.10.3",
"#ionic-native/splash-screen": "3.6.1",
"#ionic-native/status-bar": "3.6.1",
"#ionic/cli-plugin-cordova": "^1.2.0",
"#ionic/cli-plugin-ionic-angular": "^1.2.0",
"#ionic/storage": "2.0.1",
"#ngrx/core": "^1.2.0",
"#ngrx/store": "^2.2.1",
"d3": "^4.7.4",
"firebase": "^3.7.5",
"ionic-angular": "3.2.1",
"ionicons": "3.0.0",
"moment": "^2.18.1",
"pouchdb": "^6.1.2",
"pouchdb-adapter-cordova-sqlite": "^2.0.2",
"rxjs": "5.1.1",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.10"
},
"devDependencies": {
"#ionic/app-scripts": "1.3.7",
"#ionic/cli-plugin-cordova": "1.2.1",
"#ionic/cli-plugin-ionic-angular": "1.2.0",
"typescript": "~2.2.1"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [
"ios",
{
"platform": "ios",
"version": "",
"locator": "ios"
}
],
"description": "helloWorld: An Ionic project"
}
I'd recommend using the cordova-plugin-firebase instead. You can take a look at this repo to see how to use that plugin.
Please notice that the content of the notification sent will not be the same if the app is running in the foreground or if the app is closed when the notification arrives. In order to handle that, when sending a notification, add the title and the body in the Advanced options section:

Resources