0
我需要在應用程序使用Firebase
通知系統在後臺運行時(未殺死)打開特定活動。根據文檔,通知托盤將打開默認活動並將意圖發送給它。如何在應用程序在後臺運行時打開特定活動?
打開特定的活動,我添加了一個<Intent>
到Manifest
文件:
<intent-filter>
<action android:name="OPEN_ACTIVITY_1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
發送數據通過Postman
爲Post
要求:
{
"notification" : {
"OPEN_ACTIVITY_1":".activity.TemActivity_",
"body" : "update !"
},
"data": {
"type":0,
"question":"open the activity"
},
"to": "dDmXZa9k6-o:APA91bEx91oyYnOyzK3kX839EqbvA2CgY74s-
fLUs8MCYZzVmnp-RpgyI3zicEFVS37K7A4kPpbbqYU9hMBEbs-
PrBXlSTYTOBVd7O3CNvl1vaTEbGIHjLLRTWvEK2VRCvJkhQTXWtr3"
}
不過,我收到notificaiton當我點擊notificaiton
托盤。它總是打開默認的意圖活動。我在做什麼錯在這裏打開TeamActivity_
(使用的是Android註釋)
編輯-1
public class MessagingService extends FirebaseMessagingService {
public String TAG = "Data";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
System.out.println("data");
}
}
我token
是有效的,因爲我可以看到通知欄。
請你分享的火力消息 –
@AshishPandey火力地堡短信代碼的Java代碼運行的是什麼?你在問'onMessageReceived'嗎? –
是的,只是發佈你寫在該類中的整個代碼 –