0

これは何百万回も前に尋ねられたものですが、私が見たすべてのものを試しましたが、うまくいきません。データペイロード通知があります。 を受信中です.MessageReceived()通知トレイで通知をクリックすると、ランチャーにリダイレクトされません。 LandingActivityFCMのデータペイロード通知で上記のアクティビティが開かれない

if (remoteMessage.getData().size() > 0) { 
     Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString()); 
     JSONObject data = json.getJSONObject("data"); 
     Intent resultIntent = new Intent(getApplicationContext(), LandingActivity.class); 

     Bundle bundle = new Bundle(); 
     bundle.putString("data", data.toString()); 
     resultIntent.putExtras(bundle); 


      // image is present, show notification with image 
      //showNotificationMessageWithBigImage(getApplicationContext(), title, message, "13", resultIntent, profilePicThumb); 
      Intent intent = new Intent(this, LandingActivity.class); 
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
      PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, 
        PendingIntent.FLAG_ONE_SHOT); 

      Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
      NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
        .setSmallIcon(R.mipmap.ic_launcher) 
        .setContentTitle("FCM Message") 
        .setContentText("my message") 
        .setAutoCancel(true) 
        .setSound(defaultSoundUri) 
        .setContentIntent(pendingIntent); 

      NotificationManager notificationManager = 
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

      notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 
    } 

は私のアプリのランチャー活動です。オプションのdata_payloadとnotification_payloadが、私はLandingActivity内のデータを得たが、私は得るときdata_payloadクリックredriectionが

が起こるdoesntのデータ・ペイロード構造は、このようなものです与えられた

私のmanifest.xml

<activity 
     android:name=".landing.LandingActivity_" 
     android:screenOrientation="portrait" 
     android:theme="@style/AppTheme.FullScreen"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

"data" : 
{ 
"notification_type" : "QUIZ_WINNER", 
"notification_message": "You hav won the quiz ", 
"notification_data" : [ 
     "user_id"   : id, 
     "full_name"  : full_name, 
     "profile_pic_thumb": user_profile_picthumb, 
     'quiz_id'   : quiz_id, 
     'question_id'  : question_id, 
     'quiz_title'  : quiz_title, 
    ], 
"user_id"    : from_id, 
'notification_to'  : to_id, 
'created_at'   : date, 
'updated_at'   : date, 

}

私は通知を受け取ることができますが、私はLandingActivityを開くことができません

助けてください。 ありがとうございます。

FINAL ANSWERは、最後に私はworking..Iはアンドロイド注釈throught私のプロジェクトを使用していたそれを得ました。私が開く必要がある活動にも注釈が付けられました。代わりに、コード

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

のこのラインのそこで私は、この

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

を追加し、それはいつかの誰かのために有用であることを願っています。

+0

オプションのデータの有無にかかわらず、関数showNotificationMessageの内容とペイロードのサンプルを表示できますか? –

+0

@JudeFernandes私の投稿をご覧ください。私はペイロードを追加しました。 showNotificationMessage()はもう使用されていません – suja

+0

こんにちは@suja答えに加えてください。 Stack Overflowでは、セルフアンサーが強く勧められています。私はあなたが前に1つを追加したことを知っている、あなたは先に進み、それを元に戻すことができ、その後数時間後にそれを受け入れることができます。 :) –

答えて

0

「保留中の意図」を設定する行では、ゼロ以外の要求コードを使用する必要があります。私の問題は解決しました。あなたの問題も解決することを願っています。

int requestCode = (int) System.currentTimeMillis(); 
PendingIntent pendingIntent = PendingIntent.getActivity(this, requestCode /* Request code */, intent, 
       PendingIntent.FLAG_ONE_SHOT); 
+0

私はそれを試して、あなたを更新します – suja

+0

それは動作しません。とにかく助けてくれてありがとう。 – suja

関連する問題