0

내 앱에서 밀어 넣기 알림을 사용하고 있습니다.하지만 작업 관리자에서 앱을 제거 할 때 fine.but가 작동합니다. 푸시 알림이 도착하지 않습니다. 내가 알지 못하는 문제가 있습니다. 누구든지 알면 어떻게 해결할 수 있니? 제발 말해줘. 앱에서 작업 관리자를 정리 (제거) 할 때 푸시 알림이 표시되지 않습니까?

이있는 내가 통지를 전송하고있는 방법이다 : -

private void sendNotification(String msg) { 

     mNotificationManager = (NotificationManager) this 
       .getSystemService(Context.NOTIFICATION_SERVICE); 


     Intent intent = new Intent(this, MainActivity.class); 

     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); 
     Log.e("message.....", msg); 


     if (msg.equals("You Have got New Message")) { 

      Log.e("msg occuring..", "intent enter in message..."); 
      intent.putExtra("KEYMESSAGE", "Message"); 


     } else { 

      Log.e("notification occuring..", "notification occurs....."); 
      intent.putExtra("KEYNOTIFICATION", "aman"); 


     } 




PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 

     mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this) 
       .setSmallIcon(getNotificationIcon()) 
       .setContentTitle("Telepoh") 
       .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) 
       .setContentText(msg) 
       .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); 

     mBuilder.setContentIntent(contentIntent); 
     mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; 
     mBuilder.getNotification().flags |= Notification.FLAG_ONGOING_EVENT; 
     mBuilder.setOngoing(false); 

     mBuilder.setAutoCancel(true); 


     mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); 


    } 

내 문제는 알림이 제대로오고있을 때 실행 state.but에서 응용 프로그램 때 작업에서 응용 프로그램 제거 (청소) 매니저에게 통보가 도착하지 않습니다. 누구든지 문제가 무엇인지 안다면 제발 말해줘.

+0

[응용 프로그램이 다중 작업 표시 줄에서 정지 할 때 안드로이드 응용 프로그램은 중포 기지 알림이 수신되지 않는 경우]의 사용 가능한 복제 (http://stackoverflow.com/questions/39504805/android -app-not-receiving-firebase-notification-when-multi-t-stopped- –

+0

방송을 통해 메시지를 받고 있습니까 –

+0

@MujammilAhamed 예! 하지만 때 실행 상태 또는 백그라운드 state.but에서 애플 리케이션은 다음 작업 관리자에서 알림을 도착하지 않는 응용 프로그램을 청소. – aarav

답변

0

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); 

으로이 일

intent.addFlags(FLAG_INCLUDE_STOPPED_PACKAGES|Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); 

편집을이 줄을 바꾸기 :

사항에 따라 안드로이드 가이드 라인를 앱이 힘이 후, 모든 서비스를 종료됩니다되면, 리시버와 알람이 파손되므로 알림을받지 못합니다.

+0

아니요! 이 작동하지 않습니다. 앱이 작업 관리자에서 지울 때 – aarav

+0

문제는 무엇입니까? 실행중인 상태 또는 백그라운드 상태에서 응용 프로그램이 알림을 받고있는 중입니다.하지만 응용 프로그램이 작업 관리자에서 정리 된 후 알림을받지 못하는 경우입니다. – aarav

+0

체크 아웃 내 편집 된 답변 !!! –

0

푸시 알림은 서버에서 클라이언트로 푸시 된 메시지입니다. 사용자가 항상 메시지를 접할 수 있도록 백그라운드에서 실행중인 앱의 일부 서비스 여야합니다.

제 의견으로는 Firebase Cloud Messaging으로 이동하십시오. 완전한 튜토리얼 및 코드는 아래를 참조하십시오

https://firebase.google.com/docs/notifications/