내 앱에 푸시 알림을 보내고 일부 값을 sharedpreferences에 저장하려는 경우 Firebase를 사용하고 있습니다. 앱이 포 그라운드 일 때 완벽하게 작동하지만 앱이 백그라운드 일 때 값을 저장하지 않습니다.FCM 알림 문제
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e("Remotemessage",remoteMessage.toString());
String Heading = remoteMessage.getNotification().getTitle();
String message = remoteMessage.getNotification().getBody();
Map<String, String> data = remoteMessage.getData();
Log.e("Firebase notification ", " KEY1");
sessionManager=new SessionManager(this);
Log.e("Firebase notification ", " KEY"+data.get("click_action"));
Log.e("Firebase notification ", " KEY new"+data.get("key"));
int studentid= Integer.parseInt(data.get("student_id"));
Log.e("STUDENT ID",""+studentid);
if(studentid!=0)
{
sessionManager.saveStudentId(studentid);
}
}
을하지만 알림이 두 경우를 보여주고있다 : 내 코드는 다음과 같습니다. 이 문제를 해결하는 방법 ??
이 문서에서는 앱이 백그라운드 일 때 알림을 수신하는 방법에 대해서도 설명합니다. 이러한 경우 알림은 장치의 시스템 트레이로 전달되며 데이터 페이로드는 다음과 같은 목적으로 제공됩니다. 런처 활동. –
'sessionManager = new SessionManager = 새로운 SessionManager = 새로운 SessionManager (getBaseContext()); ' –
서버에서 알림을 보내는 동안 데이터 필드 만 사용하십시오. –