简体   繁体   English

Delphi - Google Play上的新应用必须定位到Android 8(API级别26) - 后台的PUSH通知

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

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. 从2018年8月起,Google Play上的所有新应用都必须定位到Android 8(API级别26)或更高级别,从2018年11月起,Google Play上的所有应用更新都必须使用Google Play上的相同应用。

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 8的新应用程序的唯一方法是编辑文件AndroidManifest.template.xml并将targetSdkVersion =“%targetSdkVersion%”替换为:Android:targetSdkVersion =“26”

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. 问题是,从那一刻起,应用程序就有了Android O引入的限制。被认为是危险的权限(相机,位置,短信......)不会被仅仅通过将它们包含在AndroidManifest中的事实授予应用程序文件。 Goodbye to the camera, to the GPS, ... 再见相机,GPS,......

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/ 在此Web中,您可以按照几个简单的步骤开始向用户请求权限: http//delphiworlds.com/2018/05/targeting-android-8-and-higher/

HOWEVER, target Android 8 has many more implications. 但是,目标Android 8有更多的含义。 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). 我的应用程序,因为仅将应用程序未运行(或在后台运行)时将targetSDKVersion从25更改为26的事实不会收到推送通知。

My test is simple: I change the targetSDK and it does not work anymore. 我的测试很简单:我更改了targetSDK,它不再起作用了。 I rewind and it works again, both with the app running and with the app in background or closed. 我回放它再次运行,无论是应用程序运行还是应用程序在后台或关闭。

The key is the change of TARGETSDKVERSION because I have always tried selecting the SDK 24.3.3 in the SDK Manager. 关键是TARGETSDKVERSION的更改,因为我一直尝试在SDK Manager中选择SDK 24.3.3。

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 O中背景服务的消失,正如他们在https://blog.klinkerapps.com/android-o-background-services/中解释的那样但我不确定。

MY BIG PROBLEM. 我的大问题。

I just uploaded an Android 7 (Level 25) app to Google Play. 我刚刚将Google 7(Level 25)应用程序上传到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. 问题是,截至2018年11月,如果我没有将TARGETSDKVERSION更改为26级,我将无法上传更新。但如果我这样做...我将停止接收PUSH通知,并且没有PUSH通知,我的应用程序不工作为了任何东西。

I confess that I'm a little scared with this 我承认我对此有点害怕

I'm sorry for my English. 对不起我的英语。

Thank you VERY much. 非常感谢你。

You will have to make sure that your notification is a high priority, FCM will post it immediately 您必须确保您的通知是高优先级,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). FCM尝试立即传递高优先级消息,允许FCM服务在必要时唤醒休眠设备并运行一些有限的处理(包括非常有限的网络访问)。 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检测到他们没有的模式,则可能会对您的消息进行去优先级排序

If your users interact with the notifcaiton FCM will not delay it. 如果您的用户与notifcaiton FCM进行交互,则不会延迟。 Background services may not be allowed in some cases in Android O but it doesn't mean you cannot send notifications 在Android O中的某些情况下可能不允许使用后台服务,但这并不意味着您无法发送通知

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM