android FCM推送,无声音,无振动,无抬头

android FCM推送,无声音,无振动,无抬头,android,Android,我正在使用FCM生成推送消息 我通过复制和粘贴FCM网站上的代码来实现所有推送机制 这样做之后,我已经测试了好几次,以检查它是否工作良好。 我检查了Log.d,发现当接收到推送消息时,会触发onMessageReceived和sendPushNotification方法。 然而,当收到信息时,我的手机没有发出任何声音,没有振动,没有抬头 当我打开屏幕时,屏幕上刚好显示了该消息 有人能告诉我如何解决这些问题吗 public class FirebaseMessagingService exten

我正在使用FCM生成推送消息

我通过复制和粘贴FCM网站上的代码来实现所有推送机制

这样做之后,我已经测试了好几次,以检查它是否工作良好。 我检查了
Log.d
,发现当接收到推送消息时,会触发
onMessageReceived
sendPushNotification
方法。 然而,当收到信息时,我的手机没有发出任何声音,没有振动,没有抬头

当我打开屏幕时,屏幕上刚好显示了该消息

有人能告诉我如何解决这些问题吗

public class FirebaseMessagingService  extends com.google.firebase.messaging.FirebaseMessagingService {
    private static final String TAG = "FirebaseMsgService";

    // [START receive_message]
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

       // sendPushNotification(remoteMessage.getData().get("message"));



        if(remoteMessage.getData().size() > 0){

            sendPushNotification(remoteMessage.getNotification().getBody());

        }

    }

    private void sendPushNotification(String message) {
        System.out.println("received message : " + message);

        Intent intent = new Intent(this, Activity_Login_Main.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0  //Request code
                , intent,
                PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);  
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.backicon).setLargeIcon(BitmapFactory.decodeResource(    getResources(),R.mipmap.ic_launcher) )
                .setContentTitle("Push Title ")
                .setContentText(message)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setDefaults(Notification.DEFAULT_SOUND)
                .setContentIntent(pendingIntent);

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wakelock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,     "TAG");
        wakelock.acquire(5000);

        notificationManager.notify(0 // ID of notification
    , notificationBuilder.build());
    }
}

你正在发送的通知有效载荷是什么,如果你的应用程序在后台,根据FCM文档,它应该有一个
声音
键,只有当你的应用程序在前台时,你的代码才会工作。

你正在发送的通知有效载荷是什么,如果你的应用程序在后台,根据FCM文档,它应该有一个
声音
键,只有当你的应用程序在前台时,你的代码才会工作。

你不会将其设置为振动,也不会将优先级设置为
priority\u HIGH
,这样它会发出提示。你为什么期望振动和抬头?你能告诉我更多的细节如何修复振动和抬头吗?如果没有vibaration、heads up和sound,用户就不会注意到新消息已到达。您不会将其设置为振动,也不会将优先级设置为
priority\u HIGH
,这样它会发出heads up通知。你为什么期望振动和抬头?你能告诉我更多的细节如何修复振动和抬头吗?如果没有振动、抬头和声音,用户就不会注意到新消息已经到达。