我想知道只有Google Pixel 2无法接收通知,我的代码可以完美执行而不中断中间,而且我还能在其他设备中显示通知而没有任何问题。
下面是我的代码。
try
{
Intent newIntent = new Intent(this, typeof(SplashActivity));
newIntent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.BroughtToFront);
newIntent.PutExtra("notificationObj", JsonConvert.SerializeObject(notificationResponse)); // we are giving which activity should raise when we click the notification
Random random = new Random();
int requestCode = random.Next(999999);
PendingIntent resultPendingIntent = PendingIntent.GetActivity(this, requestCode, newIntent, PendingIntentFlags.UpdateCurrent | PendingIntentFlags.OneShot);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.SetDefaults((int)NotificationDefaults.All)
.SetAutoCancel(true)
.SetContentIntent(resultPendingIntent)
.SetContentTitle(!string.IsNullOrEmpty(notificationResponse.Title) ? notificationResponse.Title : "AppName")
.SetSmallIcon(Resource.Drawable.notification_small_icon)
.SetLargeIcon(BitmapFactory.DecodeResource(Resources,
Resource.Drawable.ic_launcher_APP))
.SetStyle(new NotificationCompat.BigTextStyle().BigText(notificationResponse.Message))
.SetContentText(notificationResponse.Message);
NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
notificationManager.Notify(NotificationId.GetID(), builder.Build());
}
catch (Exception ex)
{
Console.WriteLine("MyFirebaseMessagingService: Exception " + ex.StackTrace);
}
任何建议将不胜感激。