Open specific page when app is not running

I am creating a voip app. I am sending a FCM push notification to my ionic app when there is a new call instantiated. I want to show my call’s screen when notification is received. I am using cordova’s phonegap push plugin.
I am stuck in this issue and didn’t find any solution.
Can someone help me with this? How can I open the app and show the call’s page with a ringtone in incoming push notification?
Any help will be really appreciated. Thanks!

I’d assume the push notification will provide some sort of data when it’s click? In that case, you could catch that in the root app.component and redirect based on some sort of key in the data.

I’d suggest trying this first and then sharing some code if you are still having issues.

1 Like

@mhartington thanks for replying. I am reading notification event, and redirecting it on the page that I want. But it works when I click on notification. I want to open a page without clicking on notification and when my app is not running.
Exactly like how call’s screen pops up in whatsapp even when whatsapp is not running.

Hi @divyasmehta!
I’m assuming that you FCM push Notifications is working and configured well, so I can suggest you to do the following. You can see the two ways, when the app is running and also when it is closed. In the app.component.ts file check this.

  startNotifications() {
    this.fcm.getToken().then(token => {
      console.log('Push Token: ', { "tkn": token});
    this.fcm.onTokenRefresh().subscribe(token => {
      console.log('Push Token: ', { "tkn": token});
    this.fcm.onNotification().subscribe(data => {
      console.log('Push Data: ', data);
      if (data.wasTapped) {
        console.log('Received in background'); // Here is, if your App is closed
        this.route.navigate([data.calls_page, data.msg]);
      } else {
        console.log('Received in foreground'); // Here is, if your App is running
        this.route.navigate([data.calls_page, data.msg]);

I think this functionality is out of scope to an Ionic app, an Ionic app can’t create this kind of widgets, maybe you have to had a solution with some native code to do this.

Thanks for your quick reply @TomCosta! I am sorry that I didn’t mention in my question, have just edited it for others. I am using cordova’s plugin for notification i.e. phonegap push notification. I did not find any solution in that plugin.

1 Like

Ahh! Wish there was some way in ionic too! :frowning:

Maybe creating your own cordova plugin, but I never seen something like that in any cordova app

Hi @divyasmehta!
Don’t worries, the logic will be the same as I mentioned before.
But If your plugin doesn’t give you what do you need, change it.
Don’t waste your time, if you can improve it.
Go ahead and success!

Hi sir I have implemented above code it’s working only in background and foreground but if app is kill then tap notification page is not redirected in such case.
Can you tell me why it’s not redirected if kill then app?

Is thia solve now? This error also occur for me. Give advice if u solve this.

@Susmita11010 Unfortunately no! Maybe this is a limitation of using a cross platform app. I was only able to open a page by writing that code on the tap event of notification.