Not Monitored
Tag not monitored by Microsoft.
41,998 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
使用Xamarin Form 開發的APP,上傳至Google 審查測試時出現以下錯誤:
Exception java.lang.IllegalArgumentException: com.yzu.XamarinPrism: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. at
試圖使用以下方法處理,但仍無法解決。
1.安裝Xamarin.Androidx.Work.Runtime
2.增加POST_NOTIFICATIONS的授權
3.修改 PendingIntent的版本判斷,PendingIntentFlags.Immutable
if (System.Convert.ToInt16(Build.VERSION.SdkInt)>=23)
{
return PendingIntent.GetActivity(context, id, intent, PendingIntentFlags.Immutable);
}
else
{
return PendingIntent.GetActivity(context, id, intent, flag);
}
請問是否有其它的解決方法,或是其它資訊可提供參考,謝謝。
1.更新Xamarin.FireBase.Messaging 套件至適合自己專案的版本,我的例子是從(60.1142.1->71.1740.0) ,因為一次更新到最新版,會造成專案錯誤。
2.加入必要權限授權(POST_NOTIFICATION)
3.在FirebaseMsgingService.cs中加入以下code
public static PendingIntent createPendingIntentGetActivity(Context context, int id, Intent intent, PendingIntentFlags flag)
{
//Android 6.0 (API level 23)
if (System.Convert.ToInt16(Build.VERSION.SdkInt) >= 23)
{
return PendingIntent.GetActivity(context, id, intent, PendingIntentFlags.Immutable);
}
else
{
return PendingIntent.GetActivity(context, id, intent, flag);
}
}
4.在FirebaseMsgingService.cs中SendNotification()中加入
var intent = new Intent(this, typeof(MainActivity));
var pendingIntent = createPendingIntentGetActivity(this, 0, intent, PendingIntentFlags.Immutable);