Open franciscohanna92 opened 2 years ago
As you say, this error makes sense as the app is completely closed and so no PushNotifications instance currently exists. As you are not able to initialise the instance then you may need to store the new interest values and then update the interests the next time the mainActivity starts.
As an aside, it looks as though you may be managing device <> interest associations on your server sideL detecting when the interest needs to change and then sending a background notification to get the device to carry out the notification. You may consider using Authenticated Users which would allow you to manage user <> topic associations at your server (without the need for these background notifications) and then when you come to publish a notification you can lookup which users should be targeted.
Thanks for your answer! That's exactly what I'm doing.
Will the device receive push notifications even when the app is fully closed using the Authenticated Users feature? If so, I'll redesign my solution and implement it.
I have integrated Pusher Beams into an Android app following the docs. I have setup a service to process data notifications (only payload data).
When my app is fully closed (not in the background), the service throws the following exception:
This is my service implementation:
The error makes sense, since
PushNotifications.start
is only called when myMainActivity
is constructed and in the service I'm trying to update the device interests (wich need Pusher to be initialized). How can I initialize it for this service? I don't have access to the application context to do it. Could I check if the PushNotifications instance has been instantiated before handling the notifications in the service?