1

Firebase에 대해 배우려고했습니다. 성공적으로 알림을 받았습니다. 하지만 알림을 클릭하면 어떻게 다른 활동을 열 수 있습니까?Firebase 안드로이드에서 핸들 알림

이 내 코드 : 알림에 대한

public class MyFirebaseMessagingService extends FirebaseMessagingService { 

private static final String TAG = "MyFirebaseMsgService"; 

@Override 
public void onMessageReceived(RemoteMessage remoteMessage) { 
    super.onMessageReceived(remoteMessage); 
    Log.d("msg", "onMessageReceived: " + remoteMessage.getData().get("message")); 
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.mipmap.ic_launcher) 
      .setContentTitle("test") 
      .setContentText(remoteMessage.getData().get("message")); 
    NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
    manager.notify(0, builder.build()); 



} 
+0

Firebase 콘솔에서 알림을 보내시겠습니까? 데이터 메시지를 사용해야합니다 –

+0

원하는대로 [Firebase FCM 알림 클릭 \ _action 페이로드] (http://stackoverflow.com/questions/37407366/firebase-fcm-notifications-click-action-payload) –

+0

을 복사 할 수 있습니다. 여기 솔루션을 찾으십시오. –

답변

0

을 정의 할 필요가 페이로드를 data

+0

감사합니다. –

0

그건 STH, 아무것도 중포 기지를 할 수 있습니다.

check this 당신은 당신이 필요로하는, Tosin 제안대로 중포 기지 콘솔에서 푸시 알림을 보내는 경우는, 노 티피 케이션

Intent intent = new Intent(this, MyActivity.class); 
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); 

Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
     .setSmallIcon(R.drawable.your_icon) 
     .setContentTitle("Notification Title") 
     .setContentText(messageBody) 
     .setAutoCancel(true) 
     .setContentIntent(pendingIntent); 

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
notificationManager.notify(0, notificationBuilder.build()); 

을 PendingIntent를 구축하고 사용하여 통지 할 필요가 알림의 행동