Xamarin 表单 Android 推送通知 "Message was successfully sent, but there were no matching targets."
Xamarin Forms Android push notifications "Message was successfully sent, but there were no matching targets."
我正在尝试按照 this tutorial and this 示例在 Xamarin.Forms Android 应用程序上设置推送通知。我的AndroidManifest.xml、FirebaseService.cs、MainActivity.cs和样本基本一样。当我启动 Android 模拟器并从 Azure 通知中心执行测试发送时,我得到:“消息已成功发送,但没有匹配的目标。”该教程是否过时?
我使用真实设备调试应用程序,但收到一条错误消息:“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'”
这是因为我的代码收缩器 (ProGuard/R8) 缺少一些配置。在 this 文章之后,我创建了一个 proguard.cfg 文件并添加了这个:
-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-keep class com.google.firebase.** { *; }
我尝试了从 Azure 通知中心发送的测试,它成功了!
我正在尝试按照 this tutorial and this 示例在 Xamarin.Forms Android 应用程序上设置推送通知。我的AndroidManifest.xml、FirebaseService.cs、MainActivity.cs和样本基本一样。当我启动 Android 模拟器并从 Azure 通知中心执行测试发送时,我得到:“消息已成功发送,但没有匹配的目标。”该教程是否过时?
我使用真实设备调试应用程序,但收到一条错误消息:“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'”
这是因为我的代码收缩器 (ProGuard/R8) 缺少一些配置。在 this 文章之后,我创建了一个 proguard.cfg 文件并添加了这个:
-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-keep class com.google.firebase.** { *; }
我尝试了从 Azure 通知中心发送的测试,它成功了!