简体   繁体   English

我可以在iOS中自定义推送通知外观吗?

[英]Can i customise push notification appearance in iOS?

I can't seems to find and control over push notification appearance. 我似乎找不到并控制推送通知的外观。 Is it so, or i am just missing something. 是这样,还是我只是想念一些东西。

Have a look at the following image 看看下面的图片

通知窗口屏幕截图

what i actually want to achieve is to put NSTextAttachment in these notification texts. 我真正想要实现的是将NSTextAttachment放在这些通知文本中。

As far as of now, i have gathered that this is something which can not be achieved because we don't have control over how iOS displays Push Notifications. 到目前为止,我已经意识到这是无法实现的,因为我们无法控制iOS如何显示“推送通知”。

But i just want to be absolutely sure about this. 但是我只想对此绝对确定。

iOS will parse notification payload for "Alert", "Badge", "Sound" & "Content-Available" and as if it got these param, it will show up the notification and ignore remaining parameters. iOS将解析“ Alert”,“ Badge”,“ Sound”和“ Content-Available”的通知有效负载,并且好像获得了这些参数一样,它将显示通知并忽略其余参数。

You can add up other parameters in payload, but that you can use in your app only not in notification tray ie you can not manipulate or say customise/style push notification view in notification tray because iOS do not allow to do so. 您可以在有效负载中添加其他参数,但是只能在通知托盘中不能在应用程序中使用,即您不能在通知托盘中操作或说自定义/样式推送通知视图,因为iOS不允许这样做。

Interactive Notifications: you can add action buttons or textfield to your notification those iOS have provided provision for, but as i said above, you cannot customise/style push notification . 交互式通知:您可以在iOS为其提供的通知中添加操作按钮或文本字段,但是正如我上面所说,您不能自定义/样式化推送通知。

CONCLUSION: which specifically in your case, you cannot add NSTextAttachment. 结论:具体而言,您不能添加NSTextAttachment。

According to this you article you can change it, I am not sure Apple added this provision recently or it existed before this post https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications?language=objc 根据您的这篇文章,您可以对其进行更改,我不确定苹果公司最近是否添加了此规定,或者该规定是否存在于这篇文章之前https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications?language=objc 在此处输入图片说明

Cannot be done. 无法完成。 iOS only lets you supply the content, not the style iOS仅允许您提供内容,而不能提供样式

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

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