Handle push notifcation works only once


#1

Hey there,

i am using the ionic-cloud/push - Service just as described here:https://docs.ionic.io/services/push/

I receive push messages but the in-app-handling doesnt work after restarting the app.

If you take this from the docs:

this.push.rx.notification() .subscribe((msg) => { alert(msg.title + ': ' + msg.text); });

For me the alert works as long, as I am not restarting the app. After the restart just nothing happens.

I placed the piece of code into my app.componet.ts inside the platform.ready callback. So it should get executed on each startup.

Any ideas ?

I am using ionic2 and, phonegap-plugin-push 1.10.4

Thanks in advance.


#2

Does your push token maybe change on every start?


#3

I dont think this is the case, since I still receive push notifications for the app, but the handling inside the app is just not triggering.

When the token would change, I wouldnt receive push notifications at all. Or am I wrong?


#4

No, you’re right. I skipped that half-sentence.

What platform are you testing on?
You can only test the first time after you installed and opened the app, correct?


#5

I am testing on ios.

And yes thats correct. When I open the app for the first time everthing works fine (with multiple messsages, so not just the first message is working). But after closing the app and starting it again the handling of the message just doesnt trigger anymore.


#6

How do you know the device is still receiving push notifications?
How do you know while the app is already open?

(Just trying to gather all information as this seems really strange…)


#7

I receive push notification when puttingn the app in the background but not closing it. When tapping on the message the app opens, but no alert is showing up.

And I am also receiving push messages when the app is closed.


#8

Ok, so when you open the app a second time and receive a push notification while it is open just nothing happens. When you then put it in the background the OS shows the pushes, but when you “activate” them the app does nothing to handle them again.


#9

Yes that is correct.


#10

Are there any reasons against using 2 push-plugins ?

I would really like to continue to use the ionic-cloud push service because we are heavily relying on the auth - service and the combination with push when it comes to adressing secific users with push notifications. And the ionic push service is bound to the phonegap-plugin-push (as far as I understood).

But could I use a different plugin like cordoca-plugin-fcm (https://github.com/fechanique/cordova-plugin-fcm) for realising the “missing/buggy” part concerning the in-app handling of the messages.

Any ideas? I think I’ll give it a try … although I know this sounds kind of desperate :slight_smile:


#11

Ok, got it …

You need to call the register-method on every startup of the app. The docs state this is recommended. But its also written that the login function would be the best place to put it. Since we are using localstorage to save the authentification the login was not called anymore.

Now it works just fine!