【发布时间】:2016-10-19 09:12:00
【问题描述】:
我已经通过堆栈溢出搜索了不同的建议,但到目前为止没有一个对我有帮助。
我正在使用 firebase 测试推送通知。我的应用程序中使用的服务可以很好地检索消息有效负载,并将在应用程序或手机打开时构建并显示通知。当我锁定我的手机时,仍然会从 firebase 中检索到消息并且仍在构建通知,但问题是,它似乎没有振动我的手机,所以我根本不知道收到任何通知。
这是我的服务以及通知的构造位置:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO: Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated.
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(remoteMessage.getFrom())
.setContentText(remoteMessage.getNotification().getBody())
.setPriority(Notification.PRIORITY_MAX)
.setVibrate(new long[] {100, 500, 100, 500, 100 ,500});
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(001, notificationBuilder.build());
}
如果有人可以提供一些帮助,那就太好了!
谢谢!
【问题讨论】:
标签: android firebase sleep firebase-cloud-messaging vibration