1

I plan to extend my Xamarin.Android app (runs only on Android 9 devices) to periodically check a web service for new info and if there's new info, show a notification to the user.

How can I implement this if the polling and the notification shall also happen when the app is not running, e.g. when the device has just started?

Are IntentService and AlarmManager the right places to dig into?

dsungaro
  • 148
  • 1
  • 11
  • You could use AlarmManager if you want to send notification in a specific time . Check https://stackoverflow.com/questions/62909338/local-notification-not-triggering-in-android-10/62911610#62911610 – Lucas Zhang Jul 31 '20 at 10:29

1 Answers1

1

Rather than writing a service in the background which may be killed by the android or having issue with the network reliability and complicated retry logic. It is far better to use the FCM push notification from the server to the devices and show them the information what you want to show.

For more you can check this https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/notifications/

Devesh
  • 4,500
  • 1
  • 17
  • 28
  • 1
    Thanks! But I read on [this page](https://learn.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/firebase-cloud-messaging) that "Because client apps are not always connected or running, the FCM connection server enqueues and stores messages, sending them to client apps as they reconnect and become available." Does FCM really cause the notification to show even if the app has not been started on the device? – dsungaro Aug 03 '20 at 06:01
  • Another question: my app is not on Google Play, can it still use FCM? – dsungaro Aug 03 '20 at 06:50
  • Yes @dsungaro https://learn.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/remote-notifications-with-fcm?tabs=windows – Devesh Aug 08 '20 at 13:44