android tv can not receive fcm messages when device in standby
@kroikie 已經在處理了。
開始於 2018年12月17日。
評估
這個 Issue 還沒有評估資料。
描述
As we know, tv has no system bar, so I just send data only messages, it works when messaging app is in foreground, background and even not runnning. But When I press "Power" key (with power instant on), the device will enter standby mode(str standby), I can promise the message has sent successfully:
{
"to" : "xxx",
"collapse_key" : "tv",
"priority": "high",
"content_available":true,
"data" : {
"body" : "wake up"
}
}
{
"multicast_id": xxx,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "xxx"
}
]
}
And I can see the log:
broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.tcl.fcmapp (has extras) }
When tv is in standby, I wake up the device by calling method like below:
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// [START_EXCLUDE]
// There are two types of messages data messages and notification messages. Data messages
// are handled
// here in onMessageReceived whether the app is in the foreground or background. Data
// messages are the type
// traditionally used with GCM. Notification messages are only received here in
// onMessageReceived when the app
// is in the foreground. When the app is in the background an automatically generated
// notification is displayed.
// When the user taps on the notification they are returned to the app. Messages
// containing both notification
// and data payloads are treated as notification messages. The Firebase console always
// sends notification
// messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
// [END_EXCLUDE]
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
wakeUpScreen();
}
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
}
private void wakeUpScreen() {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
@SuppressLint("InvalidWakeLockTag") PowerManager.WakeLock wakeLock = pm.newWakeLock
(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "LiveTV");
wakeLock.setReferenceCounted(false);
try {
wakeLock.acquire();
} catch (Exception e) {
e.printStackTrace();
}
}
I have read the docs about FCM, it says FCM support wake up the device, so is there anything wrong with my using ways?
- 主要語言
- Kotlin
- 星號
- 9.3k
- 分支
- 7.4k
- 平均合併
- 7 天 9 小時
- 30 天內合併 PR
- 6
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
firebase/quickstart-android 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 35/100
firebase/quickstart-android#2756 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 35/100
firebase/quickstart-android#2754 · 5 則留言 · 1 個 reaction ·
-
難度 4/5 3-5 天 新手友好度 32/100
firebase/quickstart-android#2668 ·
-
難度 4/5 3-5 天 新手友好度 25/100
firebase/quickstart-android#2663 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 25/100
firebase/quickstart-android#1669 · 3 則留言 ·
查看 firebase/quickstart-android 的全部 Issue
相似的 Issue
-
android:plan main:plan packages:learn
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
Needs Triage
難度 2/5 1-3 小時 新手友好度 72/100
ankidroid/Anki-Android#23453 ·
維護者通常 1 天內回覆
-
afk-ok area:data-quality importer size:S
難度 2/5 1-3 小時 新手友好度 78/100
enorm-labs/event-junkie#5278 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
bazel-contrib/rules_kotlin#1846 ·
維護者通常 2 天內回覆