When App Receive Push Notification by token the app crashing


#1

In my app when I send public push notification from firebase app works very well. But when app is in foreground and sending by Single device for my device token App crashing shows that unfortunately MyApp has Stopped . But when app is it is in background receiving very well without error. the only code i Used for firebase is to get the token to send notification nothing much.

this.firebase.getToken()
  .then(token => console.log(`The token is ${token}`)) 
  .catch(error => console.error('Error getting token', error));

#2

Where do you execute this code? What’s around it?
How do you handle push in your app?
How did you implement push in your app in general?


#3

Please share the code.


#4

There is exactly nothing written as code only fallowing lines
app.module.ts

import { Firebase } from '@ionic-native/firebase';

providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler },
    LocalNotifications, Vibration, Geolocation,
    NativeAudio,NativeStorage]

dashboardpage.ts

import { Firebase } from '@ionic-native/firebase';

constructor(private firebase: Firebase);

gettoken(){
this.firebase.getToken()
  .then(token => console.log(`The token is ${token}`)) 
  .catch(error => console.error('Error getting token', error));
}

this is the crash report of firebase:

this is the message that I send directly from firebase console:



#5

Firebase is missing from your Providers:
https://ionicframework.com/docs/native/#Add_Plugins_to_Your_App_Module


#6

l add firebase to providers of module but still the same.


#7

I removed plugin and installed it and update to latest Ionic Native but now is not getting token.


#8

Update : I’ve installed FCM instead of Firebase plugin. then in build time it shows fallowing errors:

Found com.google.android.gms:play-services-maps:10.0.0, but version 9.0.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-location:10.0.0, but version 9.0.0 is needed for the google-services plugin.

then I removed FCM and test to check build now getting token but app crashing in both User Segment(all devices) and Single device


#9

There is no any Idea,help?


#10

The solution in this page gives a great help for me and app is not crashing any more.