C# firebase messaging在Xamarin.Android上运行缺少哪种proguard配置?
我已经在play store上部署了一个针对Android的Xamarin表单应用程序。我尝试将链接与以下proguard.cfg文件一起使用“仅SDK程序集”:C# firebase messaging在Xamarin.Android上运行缺少哪种proguard配置?,c#,firebase,xamarin.android,firebase-cloud-messaging,proguard,C#,Firebase,Xamarin.android,Firebase Cloud Messaging,Proguard,我已经在play store上部署了一个针对Android的Xamarin表单应用程序。我尝试将链接与以下proguard.cfg文件一起使用“仅SDK程序集”: -keep class com.google.android.gms.** { *; } -dontwarn com.google.android.gms.** -keep class com.google.gms.** { *; } -dontwarn com.google.gms.** -keep class com.google
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class com.google.gms.** { *; }
-dontwarn com.google.gms.**
-keep class com.google.firebase.** { *; }
-dontwarn com.google.firebase.**
-keep class android.support.v7.widget.** { *; }
-dontwarn android.support.v7.widget.*
-keep class android.support.v4.widget.Space { *; }
-dontwarn android.support.v4.widget.Space
我注意到该应用程序总体运行良好,但Firebase从未使用此配置将令牌返回给该应用程序。我使用的是FirebaseMessagingService
的以下实现,在我的情况下,OnNewToken(string)
从未被调用:
[Service]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
public class MyFirebaseMessagingService : FirebaseMessagingService
{
public MyFirebaseMessagingService()
{
}
public override async void OnNewToken(string token)
{
try
{
await SecureStorage.SetAsync("fcm_token", token);
}
catch (Exception e)
{
// Possible that device doesn't support secure storage on device.
}
}
public override void OnMessageReceived(RemoteMessage p0)
{
base.OnMessageReceived(p0);
new NotificationHelper().CreateNotification(p0.Data);
}
}
该应用程序在调试模式下运行良好,并在发布时将链接选项设置为“无”-这是我目前在play store上的设置,因此该应用程序至少可以工作。。。但很明显,我想让它更干净,我很确定我离它不远了
我没有更多的错误/警告,我还尝试设置程序集的忽略链接:Xamarin.Firebase.Common;Xamarin.Firebase.Iid;Xamarin.Firebase.Messaging
,但这没有帮助
为了使firebase消息与设置为“仅SDK程序集”的链接一起工作,我在这里遗漏了什么?链接器有时会删除您想要保留的代码 您可以使用Android.Runtime.Preserve属性
public class Example
{
[Android.Runtime.Preserve]
public Example ()
{
}
}
有关更多详细信息,请查看下面的链接。
我明白了,谢谢你的建议和链接!我只能通过保留类级别的所有成员
(AllMembers=true)
,使其在本地SDK程序集的发布模式下工作。您是否知道是否设置了“忽略程序集链接”-Xamarin.Firebase.Common;Xamarin.Firebase.Iid;我提到的Xamarin.Firebase.Messaging
,有什么意义吗?还是可以忽略?