【发布时间】:2017-10-05 12:58:06
【问题描述】:
我在我的应用中使用了 FCM 通知, 我正在接收它们,它完美地显示了标题和消息
但是,当我收到通知时,我没有收到任何声音或振动或任何 LED 灯指示
我的通知生成器代码是
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.applogo);
builder.setContentTitle(Title);
builder.setContentText(Message);
builder.setAutoCancel(true);
builder.setSound(Uri.parse("file:///android_asset/notification.mp3"));
builder.setContentIntent(pendingIntent);
builder.setDefaults(Notification.DEFAULT_VIBRATE);
builder.setLights(Color.RED, 1000, 300);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
提前致谢。
【问题讨论】:
-
您是否在 android manifest 中为振动添加了权限..?
标签: android firebase push-notification notifications