如何解决这个问题 "Unable to trigger default handler prompt prior to runtime permissions"

how to fix this "Unable to trigger default handler prompt prior to runtime permissions"

今天我从 google 团队收到了这封邮件我的应用程序发布状态:已拒绝。

无法在运行时权限之前触发默认处理程序提示 *如果您的应用是默认处理程序,则默认处理程序提示必须在运行时权限提示之前。

根据我们的审核,您的应用似乎没有在运行时权限提示之前正确触发默认处理程序提示。请在任何运行时权限提示之前添加默认处理程序提示。*

请帮助解决这个问题,我也使用了默认的处理程序提示,但不知道为什么 google 给我发了这封邮件。

您需要明确提示默认处理程序,而不是简单地在清单中声明权限。

RoleManager roleManager = (RoleManager) 
activity.getSystemService(Context.ROLE_SERVICE);
Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_DIALER);
activity.startActivityForResult(intent, requestCode);

更改默认处理程序:

Intent setDefaultSmsIntent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
setDefaultSmsIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getPackageName());
startActivityForResult(setDefaultSmsIntent, requestCode);

来自 Google 的 Android 文档,这是关于 Play Store policy

Given the sensitive user information that an app accesses while serving as a default handler, your app cannot become a default handler unless it meets the following Play Store listing and core functionality requirements:

Your app must be able to perform the functionality for which it's a default handler. For example, a default SMS handler should be able to send text messages.

Your app must provide a privacy policy.

Your app must make its core functionality clear in the Play Store description.

For example, a default Phone handler should describe its phone-related capabilities in the description.

Your app must declare permissions that are appropriate for its use case. For more details about which permissions you can declare as a given handler, see the guidance on using SMS or call log permission groups in the Play Console Help Center.

Your app must ask to become a default handler before it requests the permissions associated with being that handler. For example, an app must request to become the default SMS handler before it requests the READ_SMS permission.