フォアグラウンドだけでなくバックグラウンドでもfirebase通知メッセージを処理したい。私は開発者からのyoutubeリンクを構成するメッセージを送信します。ユーザーが通知バーをタップすると、リンクを開くようユーザーに指示する必要があります。誰がそれがどのように行われているか知っていますか?バックグラウンドとフォアグラウンドでのfirebase通知の処理方法は?
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
// [END_EXCLUDE]
// TODO(developer): Handle FCM messages here.
// Not getting messages here? See why this may be:
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());
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
// 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.
}
私の目標を達成するために次に何をしますか?ありがとうございます。
掲載されたコードは、サンプルに含まれているものです。だから私はあなたがそれらを通過したと仮定しています。それについて何か混乱していましたか?あなたはまた、ドキュメントを行ったことがありますか?今、これは私のコード*の質問と同じです。 –
私のソリューションを試してみませんか?
私はすでに試してみました。
それは動作します
https://stackoverflow.com/questions/48897883/how-to-handle-notifications-with-fcm-when-app-is-in-either-foreground-or-backgro/48899186#48899186 –