両方は私が見ることができますどのようにFirebase
Firebase通知は、タイトルとメッセージ
を使用してpush notification
を送信するためにthisチュートリアルを使用しています含まれていTitle and Message
両方の通知バーenter code here
(それでも私は、通知バーでmessage
*Title*
などのコンテンツを取得していますで)...
あなたはthisscreenshot
で見ることができるように(このため、私はをunable
からdeliver
が完了しています私はこのような通知を送達するためにAdvanced Rest Client (Messaging API)
を使用していますユーザーへ、通知バーのタイトルに制限maximum 1 line
を持っているので)
:
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIza************adrTY
{ "data": {
"image": "https://ibin.co/2t1lLdpfS06F.png",
"message": "Firebase Push Message Using API"
"AnotherActivity": "True"
},
"to" : "f25gYF3***********************HLI"
}
コード
/**
* Create and show a simple notification containing the received FCM message.
*/
private void sendNotification(String messageBody, Bitmap image, String TrueOrFalse) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("AnotherActivity", TrueOrFalse);
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)
.setLargeIcon(image)/*Notification icon image*/
.setSmallIcon(R.drawable.firebase_icon)
.setContentTitle(messageBody)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(image))/*Notification with Image*/
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
これは私もこの行を使用する必要があることを意味します:String title = remoteMessage.getData()。get( "title");メッセージの場合と同じように、私はString message = remoteMessage.getData()。get( "message");を使用しています。 – Sophie
Yeap。あなたの 'NotificationCompat.Builder'の' setContentTitle'に 'remoteContent.getData()。get(" message ")'が 'setContentText'と' remoteMessage.getData()。get( "title") 'に行きます。 – GuilhermeFGL