Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Local Notifications - ok to generate when app in foreground?

$
0
0

Have a Xamarin Forms app and looking to implement local notifications so as to alert the user when the app is in the background. Experimentign with the Acr.Notifications and the Xam.Plugins.Notifier packages. Either package works great for the main use case:

  • App is in background
  • App generates local notification based on something occurring in the app, e.g. a timer
  • User clicks notification
  • User is navigated back to the app (e.g. MainActivity.OnCreate method is invoked).

However, if the app stayed in the foreground the whole time, and the user clicked the local notification, MainActivity.OnCreate is still invoked which fouls up the app - a white screen appears and basically prevents further use of the app.

Should I basically just not generate a local notification if the app is in the foreground? I just have to add functionality so my view models can know whether the app is in the foreground or background. Feels a little weird, but I think very doable.

Otherwise, what can I do to simply have the app/OS just "dismiss" the local notification if the user chooses to click on it while the app is in the foreground?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>