在用户解锁屏幕之前,推送通知不会传递到应用程序

时间:2019-03-12 08:33:11

标签: android push-notification

我们使用旧的GCM HTTP服务器向应用发送推送通知。

在应用程序中收到它们时,我们使用通知生成器显示消息:

 NotificationChannel mChannel = new NotificationChannel(
            "com.....app.notification", "...",
            android.app.NotificationManager.IMPORTANCE_HIGH);
        mChannel.setShowBadge(true);
        mNotificationManager.createNotificationChannel(mChannel);

        mBuilder =
                new NotificationCompat.Builder(context, mChannel.getId());

 mBuilder.setWhen(System.currentTimeMillis())
            .setContentTitle(fromHtml(title))
            .setTicker(fromHtml(title))
            .setContentIntent(contentIntent)
            .setAutoCancel(true)
            .setPriority(Notification.PRIORITY_MAX);
...
mNotificationManager.notify(appName, notId, mBuilder.build());

一切正常,除了在某些设备上,只有在用户解锁屏幕时,才能传递推送。

我知道有一些Android设置可能会允许或不允许这样做。 但是它们太复杂了,没有用户可能会找到所有它们。

所以我的问题是: 有没有办法以编程方式确保始终显示推送?

0 个答案:

没有答案