相关疑难解决方法(0)

Android通知无法获得声音和振动

我在我的应用程序中使用了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());
Run Code Online (Sandbox Code Playgroud)

提前致谢.

notifications android push-notification firebase

5
推荐指数
1
解决办法
1973
查看次数

当应用在后台时,Firebase推送通知不会播放声音

我已经使用AndroidHive中的 Firebase云消息传递FCM实现了Android推送通知,但是当应用程序处于后台时通知没有响起.

任何人都可以帮我在firebase后台通知上设置声音吗?

android push-notification firebase firebase-cloud-messaging firebase-notifications

2
推荐指数
1
解决办法
2594
查看次数