TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
208 stars 48 forks source link

Making push notifications work after device reboot when using Plugin.Firebase #336

Open gautambjain opened 2 weeks ago

gautambjain commented 2 weeks ago

First of all, thanks for making life easy with this plugin.

I don't know how to make Plugin.Firebase work after device boot. Meaning, the push notifications are not received until I explicitly run the app once. Can you please guide?

Currently trying on Android platform. But I believe similar issue may exist on iOS also.

Is this a limitation? Or is there any workaround?

AdamEssenmacher commented 2 weeks ago

Meaning, the push notifications are not received until I explicitly run the app once.

Do you mean once ever? Or do you need to run the app once each time the device is restarted?

But I believe similar issue may exist on iOS also.

Why do you believe this?

gautambjain commented 2 weeks ago

I use push notifications to initiate syncing of notes data with the server. And I have widgets also on Android home screen.

After reboot, I want the the above functionality to work without having to run the app. But this doesn't work with Plugin.Firebase.

Why do you believe this?

Because it seems to be initialization issue due to which CrossFirebaseCloudMessaging.Current may be null inside the intent service (MESSAGING_EVENT). That's why it may not be able to trigger the events although the intent service may be receiving the calls.

In order to make it work, I have explicitly write my own intent service (MESSAGING_EVENT) and do the work (syncing notes data) like I did before in Xamarin.Forms.

AdamEssenmacher commented 2 weeks ago

Because it seems to be initialization issue due to which CrossFirebaseCloudMessaging.Current may be null inside the intent service (MESSAGING_EVENT).

Are you getting specific error messages around this? Why do you think this is the problem?

gautambjain commented 2 weeks ago

Are you getting specific error messages around this? Why do you think this is the problem?

About error messages, I am not able to check easily because after a reboot, the device is disconnected from the debugger. Once I launch the app after the reboot, the push notifications work. I saw the plugin code and it is using CrossFirebaseCloudMessaging.Current object to trigger the events from the intent service (MESSAGING_EVENT).