不执行弹出功能的抬头推送通知 [英] Heads up push notification not doing the Pop up function

查看:81
本文介绍了不执行弹出功能的抬头推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Android 新手,我一直在尝试像 whatsapp 一样显示单挑操作推送通知.

I am new to Android and I have been trying to show a Heads up action push notification just like whatsapp does.

这是我的通知配置:

NotificationCompat.Builder notificationBuilder =
                new NotificationCompat.Builder(this, ADMIN_CHANNEL)
                        .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_foreground))
                        .setSmallIcon(R.drawable.m_icon)
                        .setContentTitle(remoteMessage.getNotification().getTitle())
                        .setTicker(remoteMessage.getNotification().getBody())
                        .setColor(ContextCompat.getColor(getApplicationContext(), R.color.mblue))
                        .setAutoCancel(true)
                        .setSound(defaultSoundUri)
                        .setStyle(new NotificationCompat.BigTextStyle()
                                .bigText(remoteMessage.getNotification().getBody()))
                        .setPriority(NotificationCompat.PRIORITY_HIGH)
                        .setContentIntent(likePendingIntent);

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0,notificationBuilder.build());

我在一些帖子中读到,完成此操作的关键是为通知设置高优先级,但它仍然对我不起作用.

I have read in some post that the key to acomplish this is to set high priority to the notification but, It is still not working for me.

推荐答案

对于模拟器上的 Android Pie (9),我将我的频道设置为IMPORTANCE_HIGH",并将我的构建器优先级设置为PRIORITY_HIGH".

For Android Pie (9) on the emulator, I setup my channel with "IMPORTANCE_HIGH", and also set my builder priority to "PRIORITY_HIGH".

但是,我仍然无法收到提醒通知!

But, I still could not get heads-up notifications!

最后,在 Android 9 模拟器上,我不得不:

Finally, on the Android 9 emulator, I had to:

  1. 向下滑动通知抽屉
  2. 点按管理通知"
  3. 选择我的应用
  4. 选择我的频道
  5. 选择行为"
  6. 启用在屏幕上发出声音并弹出".

现在可以了.

这篇关于不执行弹出功能的抬头推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆