I am trying to setup push notifications on a Xamarin.Forms Android app following this tutorial and this sample. My AndroidManifest.xml, FirebaseService.cs and MainActivity.cs are basically the same as the sample. When I fire up the Android Emulator and do a Test Send from Azure Notification Hubs I get: "Message was successfully sent, but there were no matching targets." Is that tutorial outdated?
Asked
Modified
5 years ago
Viewed
1k times
Part
of Mobile Development, Google Cloud and Microsoft Azure Collectives
2
-
1If you have access to a real device try running your app there and see if you have other results.pinedax– pinedax2020-07-07 06:47:36 +00:00Commented Jul 7, 2020 at 6:47
-
1Thanks, that helped me get an error message: "Java.Lang.RuntimeException: 'Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver: java.lang.InstantiationException: java.lang.Class<com.google.firebase.iid.FirebaseInstanceIdReceiver> cannot be instantiated'" I need to figure out why this is happening.Luis Lema– Luis Lema2020-07-07 17:50:52 +00:00Commented Jul 7, 2020 at 17:50
Add a comment
|
1 Answer
I used a real device to debug the application and I got an error message: "Java.Lang.RuntimeException: 'Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver: java.lang.InstantiationException: java.lang.Class<com.google.firebase.iid.FirebaseInstanceIdReceiver> cannot be instantiated'"
This was due to my code shrinker (ProGuard/R8) missing some configurations. Following this article I created a proguard.cfg file and added this:
-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-keep class com.google.firebase.** { *; }
I tried a Test Send from Azure Notification Hubs and it worked!
3 Comments
Kyle Kamperschroer
Thanks for following up and providing what worked! I'm glad you got it working. :)
Ron
@Luis Do you happen to remember what clases/libraries you needed to "keep" to make this work ? I am getting the same error and have tried multiple variations of the class names and it still keeps failing
Michal Diviš
Thanks! I've been using the FirebasePushNotificationPlugin in Xamarin.Forms and this resolved my problem.