【发布时间】:2018-05-11 04:22:37
【问题描述】:
我有一个使用 Firebase 发送通知的应用。当我发送它们并显示通知时,提供了样式,但通知的其余部分与描述不符
Notification notification = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.lascanadaslogo)
.setContentTitle("Titulo")
.setContentIntent(pi)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification().getBody()))
.build();
此外,当我单击它时,它会执行一个意图,但不是对我的 url 执行此操作,而是对我的应用程序 (MainPage) 执行此操作。我给你看完整的代码:
public class MyFirebaseMessagingService extends FirebaseMessagingService{
private static final String TAG = "FCM Service";
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.lascanadas.es/reservas"));
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
Notification notification = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.lascanadaslogo)
.setContentTitle("Titulo")
.setContentIntent(pi)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification().getBody()))
.build();
NotificationManager notificationManager2 = (NotificationManager) getApplicationContext().getSystemService(Service.NOTIFICATION_SERVICE);
notificationManager2.notify(0, notification);
//Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
}
}
【问题讨论】:
标签: android android-studio firebase android-intent notifications