在询问通知权限时是否可以有自定义对话框消息? [英] Is it possible to have a custom dialog message when asking for notification permissions?

查看:207
本文介绍了在询问通知权限时是否可以有自定义对话框消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自定义通知权限的以下部分提示符:


通知可能包括警报,声音和图标徽章。这些可以在设置中配置。

Notifications may include alerts, sounds, and icon badges. These can be configured in Settings.

是否可以将其更改为我自己的文本?

Is it possible to change this to my own text?

推荐答案

您无法自定义此消息。有关详细信息,请参阅此处

You are not able to customize this message. Read Here for more information.

大多数应用程序处理此问题的推荐方法是先显示自己的对话框,然后显示Apple系统对话框。

The recommended way that most apps handle this is by first presenting their own dialog, then show the Apple system dialog.

因此,当需要用户提供通知权限时,首先您会触发自己的自定义提醒,其中显示请允许您的应用名称向您发送通知......并且可能是用户应该允许的原因的简要说明。使用此警报,只向UIAlertController添加一个操作,我通常只将动作标题设置为Ok并使用 .default 作为样式。在这个OkUIAlertAction的完成处理程序中,您将触发Apple系统对话框,该对话框为通用UIAlertController提供了用户选择接受或拒绝您的应用程序发送通知的权限的选项。

So when it comes time to ask the user for notification permissions, first you trigger your own custom alert that says something like "Please allow your-app-name to send you notifications..." and maybe a brief description of why the user should allow this. With this alert, only add one action to the UIAlertController, I usually just have the action title set to "Ok" and use .default as the style. In the completion handler of this "Ok" UIAlertAction that is when you will trigger the Apple system dialogue which presents the generic UIAlertController with the option for the user to either accept or deny permissions for your app to send notifications.

所以流程就像 - >用户到达应用程序点,他们必须决定是否要接受或拒绝通知权限 - > app呈现UIAlertController本质上只是解释为什么应用程序想要/需要发送通知 - >一旦用户点击确定然后触发实际上使用户选择接受或拒绝通知权限的通用系统警报。

So the flow is something like -> users reaches point in app where they have to decide if they want to accept or deny notifications permissions -> app presents UIAlertController that is essentially just an explanation of why the app wants/needs to send notifications -> once user taps "Ok" then trigger the generic system alert that actually makes the user choose to accept or deny notification permission.

这样做似乎有一些心理上的好处。通过强制用户在第一个对话框中点击确定通知,它会使他们在紧接着显示的通用Apple对话框中点击允许通知。

There seems to be some psychological advantage to doing it this way. By sort of forcing the user to tap "ok" to notifications in the first dialogue, it primes them to tap "allow notifications" in the generic Apple dialogue displayed immediately after.

这篇关于在询问通知权限时是否可以有自定义对话框消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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