Cannot get Azure notifications working reliably

GerryHGerryH USMember ✭✭✭
edited March 6 in Xamarin.Android

Since Google forced the upgrade to 8.0, I cannot get notifications working reliably. Specifically, if the user puts my app into the background attempting to receive or perhaps display notifications causes a crash. It takes some time and/or number of notifications to cause the crash, usually a minute or two, and/or half dozen messages.

Google talks about calling methods like StartForegroundService() and StartForeground() in order to get things to work, but I cannot figure out how this fits into the Xamarin framework. StartForegroundService is supposed to be called in the MainActivity's OnCreate, and then StartForeground in the Service's OnCreate within 5 seconds. Well there is no way that is happening in 5 seconds.

Many Xamarin sample projects are old and/or limited in scope. How do you create a user app that can be put into the background, receive Azure push messages and display notifications without crashing on Android 8.0+?

And what, if anything, does this have to do with JobScheduler?


  • GerryHGerryH USMember ✭✭✭

    Any hints? Xamarin development is 5% of my job so a push in the right direction would really help.

  • GerryHGerryH USMember ✭✭✭

    I implemented JobScheduler. This did not fix the problem.

  • GerryHGerryH USMember ✭✭✭

    Currently I am getting:

    Java.Lang.IllegalStateException: Not allowed to start service Intent { flg=0x1000010 pkg=com.rimex.tyresense cmp=com.rimex.tyresense/md5bf34da605c12d097dc5a495af95e9376.AzureListenerService (has extras) }: app is in background uid UidRecord{97b888d u0a173 TRNB bg:+4m43s213ms idle change:idle procs:1 seq(0,0,0)} occurred

  • GerryHGerryH USMember ✭✭✭

    Trying out

    I added the app as is to my Firebase account, then downloaded/installed the google-services.json and it seems to run okay (shows token and can subscribe to topic) but Google's "Checking if the app has communicated with our servers..." never returns.

Sign In or Register to comment.