ionic-team / legacy-ionic-cloud

JavaScript Client for legacy Ionic Cloud services. See Ionic Pro for our new take on the ionic development lifecycle
Apache License 2.0
65 stars 26 forks source link

Handling notifications in foreground #128

Open tolgap opened 7 years ago

tolgap commented 7 years ago

If I follow the documentation steps, I end up with an application that can only respond to Push notifications if the application is completely closed. It can't even be running in the background. What is the reasoning behind this? I have to force close my application before I can even enter the documented callback steps:

        return this.push
            .rx
            .notification()
            .subscribe((data) => {
                console.log("only fires if application is completely closed")
            }

The phonegap-plugin-push package allows you to respond to push notifications even if your application is in the foreground. How can I achieve this using ionic-cloud?

Fuiste commented 7 years ago

This is not expected behavior @tolgap, and I can't reproduce it on my testing apps.

First steps, I'd verify that you're calling register on each start of the app, and that your push subscription code is also being invoked on each app start.

tolgap commented 7 years ago

I am calling register, as I can see ionic-cloud generating a console.log message with a push token when I open up the app. I can also see that the messages are being sent to the server (they are enqueued) when I list all messages from the cloud API.

janpio commented 7 years ago

Did you get this fixed @tolgap ?

tolgap commented 7 years ago

@piotrowski nope.

@Fuiste Can you show me how you do it in your testing apps? I assume I was doing something wrong, because otherwise more people would've complained by now :D