我收到通知但由FireBase自动构建。我无法设置自己的通知。我已尝试构建通知并从onMessageReceived方法设置标题,但之后它将停止显示通知。仅显示默认通知
public class FireBaseMessaging extends FirebaseMessagingService {
private static final String TAG = "FCM Service";
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Log.d("Msg", "Message received ["+remoteMessage+"]");
// Create Notification
Intent intent = new Intent(this, WebHandler.class);
intent.putExtra("links","http://www.google.com");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1410,
intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new
NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_shopping_cart_white_24dp)
.setContentTitle("Message")
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1410, notificationBuilder.build());
}
}