Delphi - New apps on Google Play must target Android 8 (API level 26) - PUSH notification in background

时光总嘲笑我的痴心妄想 提交于 2019-12-04 05:55:43

You will have to make sure that your notification is a high priority, FCM will post it immediately

FCM attempts to deliver high priority messages immediately, allowing the FCM service to wake a sleeping device when necessary and to run some limited processing (including very limited network access). High priority messages generally should result in user interaction with your app. If FCM detects a pattern in which they don't, your messages may be de-prioritized

If your users interact with the notifcaiton FCM will not delay it. Background services may not be allowed in some cases in Android O but it doesn't mean you cannot send notifications

Also your notification will not be displayed if your not using notification channels, You can use this code to create notification channels

public void initChannels(Context context) {
if (Build.VERSION.SDK_INT < 26) {
    return;
}
NotificationManager notificationManager =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel("default",
                                                      "Channel name",
                                                      NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("Channel description");
notificationManager.createNotificationChannel(channel);

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!