简体   繁体   English

具有丰富内容的iOS推送通知-我可以阻止通知被轻按吗?

[英]iOS Push Notification with Rich Content - Can I prevent a notification from being tappable?

I have a push notification with rich content. 我有一个内容丰富的推送通知。

Can I make it in such way that it is not tappable, ie, a single tap will not open the application. 我能否以无法点击的方式进行操作,即,一次点击将无法打开该应用程序。 It must be dragged down to rich content or 3D touched, or deleted from the notification center by swiping. 必须将其向下拖动到丰富的内容或进行3D触摸,或通过滑动从通知中心删除。

How should I indicate to the user to drag down (3D touch) in order to reveal rich content on notification? 我应如何指示用户向下拖动(3D触摸)以在通知中显示丰富内容?

No, a tap on a push notification will always open the notification in the app, and as far as I know there is no way in public API to override this behavior. 不,点击推送通知将始终在应用程序中打开通知,据我所知,公共API中没有任何方法可以覆盖此行为。 It does appear there is a private API to get the behavior you're looking for, as some iOS-generated (local, not push) notifications appear to do exactly what you're asking. 确实有一个私有API可以实现您正在寻找的行为,因为某些iOS生成的(本地而非推送)通知似乎完全可以满足您的要求。 If you can manage to uncover that, use at your own risk should Apple find out. 如果您能够设法发现问题,则Apple自行承担风险使用。

Now, as for possible solutions: I would consider implementing code on your app's delegate to respond appropriately when the notification is opened. 现在,作为可能的解决方案:我将考虑在您的应用程序的委托中实现代码,以便在打开通知时做出适当的响应。 For example, send the user to an appropriate location in the app when the app is launched from a notification…perhaps a view controller that shows the same content that would be shown as the rich notification content. 例如,当从通知启动应用程序时,将用户发送到应用程序中的适当位置……也许是视图控制器显示的内容与丰富的通知内容相同。 I don't know the exact use case, but the wording implies to me that if the app launches to its main interface, it could be confusing to a user. 我不知道确切的用例,但措辞对我而言意味着,如果该应用启动到其主界面,可能会使用户感到困惑。

It's impossible for me to tell you how exactly you wish to respond to notifications, so for more on responding appropriately when the app was launched from a push notification, see the following documentation from Apple: 对于我来说,不可能告诉您您希望如何准确地响应通知,因此,有关从推送通知启动应用程序时如何正确响应的更多信息,请参阅Apple的以下文档:

Hopefully from that you can find a suitable solution. 希望从中可以找到合适的解决方案。 But if that isn't an option, consider directly telling the user at some point to press firmly (or tap and hold, as many devices do not support 3D Touch) to view the content. 但是,如果不是这样,请考虑直接告诉用户在某个时候用力按下(或按住,因为许多设备不支持3D Touch)以查看内容。 You could do this during some onboarding process or, as an absolute last resort, in the notification itself. 您可以在某些入门过程中,或者绝对可以在通知本身中这样做。

Before proceeding down that route, though, understand that not all users know 3D Touch and/or this rich-content functionality even exists — even fewer use it regularly — and if they become confused, they may decide to clear the notification or outright disable your app's notifications. 不过,在继续之前,请了解并非所有用户都知道3D Touch和/或此丰富内容功能甚至存在-甚至很少有用户定期使用它-如果感到困惑,他们可能会决定清除通知或直接禁用您的应用的通知。 In general, it's also a bad idea to “teach” your user unfamiliar ways of using their device. 通常,“教”用户不熟悉的设备使用方式也是一个坏主意。 If a user is used to tapping on notifications, as many are, they will most likely tap on your notifications. 如果用户习惯于点击通知,那么他们很可能会点击您的通知。 It can be tough to break that muscle memory. 打破那种肌肉记忆可能很难。

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

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