Delphi-Google Play上的新应用必须针对Android 8(API级别26)-后台推送通知 [英] Delphi - New apps on Google Play must target Android 8 (API level 26) - PUSH notification in background

查看:125
本文介绍了Delphi-Google Play上的新应用必须针对Android 8(API级别26)-后台推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从2018年8月开始,Google Play上的所有新应用必须以Android 8(API级别26)或更高版本为目标;从2018年11月开始,Google Play上的所有应用更新必须是Google Play上相同应用的更新。

From August 2018, all new apps on Google Play must target Android 8 (API level 26) or higher, and from November 2018, all app updates on Google Play must of the same apps on Google Play.

现在,您唯一必须上传针对Android 8的新应用程序的唯一方法是编辑文件AndroidManifest.template.xml并替换
targetSdkVersion =%targetSdkVersion%
由:
Android:targetSdkVersion = 26

Right now the only way you have to upload a new App that target Android 8 is to edit the file AndroidManifest.template.xml and replace targetSdkVersion = "% targetSdkVersion%" by: Android: targetSdkVersion = "26"

问题是从那一刻起,该应用便受到了Android O的限制。权限仅将它们包含在AndroidManifest文件中的事实,就不会将它们视为危险(相机,位置,SMS等)。

The problem is that from that moment the app has the restrictions introduced by Android O. The permissions considered as dangerous (camera, location, SMS, ...) will not be granted to the app by the mere fact of including them in the AndroidManifest file. Goodbye to the camera, to the GPS, ...

在此网络中,您可以按照一些简单的步骤开始向用户请求权限:
http://delphiworlds.com/2018/05/targeting-android- 8位及更高版本/

In this web, you can following a few simple steps to start requesting permissions from the user: http://delphiworlds.com/2018/05/targeting-android-8-and-higher/

但是,目标Android 8具有更多含义。我的应用程序仅出于将targetSDKVersion从25更改为26的事实而无法在应用程序未运行时(或在后台)接收推送通知。

HOWEVER, target Android 8 has many more implications. My application, for the mere fact of changing the targetSDKVersion from 25 to 26 DOES NOT RECEIVE PUSH NOTIFICATIONS when the application is not running (or in background).

我的测试是很简单:我更改了targetSDK,它不再起作用了。我倒带了一下,并且无论是在应用运行还是在后台运行或关闭的情况下,它都能再次正常工作。

My test is simple: I change the targetSDK and it does not work anymore. I rewind and it works again, both with the app running and with the app in background or closed.

关键是更改TARGETSDKVERSION,因为我一直尝试选择SDK Manager中的SDK 24.3.3。

The key is the change of TARGETSDKVERSION because I have always tried selecting the SDK 24.3.3 in the SDK Manager.

我认为主要原因之一是Android O中后台服务的消失,正如 https://blog.klinkerapps.com/android-o-background-services/ 但是我

I think one of the main reasons is the disappearance of the Background Services in Android O, as they explain in https://blog.klinkerapps.com/android-o-background-services/ But I’m not sure.

我的大问题。

我刚刚上传了一个Android 7(25级)应用到Google Play。问题是,自2018年11月起,如果我不将TARGETSDKVERSION更改为26级,将无法上传更新。但是,如果我这样做了……我将停止接收PUSH通知,并且如果没有PUSH通知,我的应用程序将无法运行

I just uploaded an Android 7 (Level 25) app to Google Play. The problem is that as of November 2018 I will NOT be able to upload updates if I do not change TARGETSDKVERSION to Level 26. But if I do ... I will stop receiving PUSH notifications, and without PUSH notifications, my App DOES NOT WORK FOR ANYTHING.

我承认对此感到有些害怕

I confess that I'm a little scared with this

对不起英语。

非常感谢。

推荐答案

您必须确保您的通知具有较高的优先级,FCM会立即将其发布

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


FCM尝试立即传递高优先级消息,从而允许FCM服务在必要时唤醒睡眠设备并运行一些有限的处理(包括非常有限的网络访问)。高优先级消息通常应导致用户与您的应用进行交互。如果FCM检测到他们没有采用的模式,则您的邮件可能会被取消优先级

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

如果您的用户与通知FCM进行交互不会延迟。在某些情况下,Android O中可能不允许后台服务,但这并不意味着您无法发送通知

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);

}

这篇关于Delphi-Google Play上的新应用必须针对Android 8(API级别26)-后台推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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