1
firebase를 사용하여 알림을 보내고 있습니다. 사용자가 알림을 클릭하면 ResultActivity가 열립니다. 앱이 포 그라운드에있을 때 제대로 작동합니다. 그러나 앱이 백그라운드에있을 때 ResultActivity가 아닌 HomeActivity (앱의 런처 활동)를 엽니 다. 문제가 뭔지 이해가 안되니?왜 PendingIntent가 특정 활동이 아닌 앱의 런처 활동을 여는 이유가 무엇입니까?
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle(getResources().getString(R.string.app_name));
notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
notificationBuilder.setAutoCancel(true);
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);
Intent intent = new Intent(getApplicationContext(), ResultActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
}
마지막으로 새 질문을하기 전에 몇 가지 검색을 어제 질문을 받았다이 정확한 질문 –
http://stackoverflow.com/questions/40718155로 이동해야합니다/open-specific-activity-when-notification-click-in-fcm –
[여기] (http://stackoverflow.com/questions/37407366/firebase-fcm-notifications-click-action-payload)를보십시오. 도움이 될지도 모릅니다. –