firebase messagingservice当应用不处于调试模式时



firebase通知在不在调试模式下时未接收。但是在Firebase控制台中显示为已完成。

下面是我的代码

 @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        context = (EEmployeeApplication) EEmployeeApplication.getContext();
        Log.d("Notification","From: "+remoteMessage.getFrom());
        if (remoteMessage.getData().size() > 0){
            Log.d("FCM","Message data payload: "+remoteMessage.getData());
        }
        if (remoteMessage.getNotification() != null) {
            Log.d("FCM", "Message Notification Body: " + remoteMessage.getNotification().getBody());
        }
        if (remoteMessage.getNotification() != null) {
            Log.d("FCM", "Message Notification Body Verse: " + remoteMessage.getData().get("PLAN_ID"));
            String PlanID = remoteMessage.getData().get("PLAN_ID");
            context.eEMPSharedPreference.setNotification(PlanID);
        }
        if (remoteMessage.getNotification() != null) {
            Log.d("FCM", "Message Notification Click action: " + remoteMessage.getNotification().getClickAction());
        }
        String image = remoteMessage.getNotification().getIcon();
        String title = remoteMessage.getNotification().getTitle();
        String text = remoteMessage.getNotification().getBody();
        int id = 0;
        Object obj = remoteMessage.getData().get("id");
        if (obj != null){
            id = Integer.valueOf(obj.toString());
        }
        this.sendNotification(new NotificationData(image,id,title,text));
    }
    private void sendNotification(NotificationData notificationData){
        Intent intent = new Intent(this, Navigationdrawer.class);
        intent.putExtra(NotificationData.TEXT,notificationData.getTextMessage());
        PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
        NotificationCompat.Builder notificationBulder = new NotificationCompat.Builder(this);
        notificationBulder.setContentTitle(notificationData.getTitle());
        notificationBulder.setContentText(notificationData.getTextMessage());
        notificationBulder.setAutoCancel(true);
        //notificationBulder.setSmallIcon(R.mipmap.ic_launcher);
        notificationBulder.setContentIntent(pendingIntent);
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(notificationData.getId(), notificationBulder.build());
    }

如何解决它?预先感谢

我也有相同的问题,您可以通过覆盖弹药并将Waitfordebugger方法进行修复,然后将其类似地放置。

override fun onCreate() {
       Debug.waitForDebugger()
} 

相关内容

  • 没有找到相关文章

最新更新