gpt4 book ai didi

ios - UNNotificationServiceExtension 有时不运行

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:31:11 24 4
gpt4 key购买 nike

我正在开发一个使用 UNNotificationServiceExtension 的应用程序。大多数时候(大约 90%),我的扩展程序运行正确,与后端建立连接,然后显示通知。但似乎有时扩展程序根本不运行,系统会在通知中显示原始消息。为什么会这样?所有通知肯定包含设置为 1 的可变内容键。

最佳答案

我在实现 UNNotificationServiceExtension 时遇到了同样的问题。我的问题是加载额外内容的时间限制

Here is the link

Your extension has a limited amount of time (no more than 30 seconds) to modify the content and execute the contentHandler block. If you do not execute that block in a timely manner, the system calls your extension’s serviceExtensionTimeWillExpire() method to give you one last chance to execute the block. If you do not, the system presents the notification’s original content to the user.

如果你想确保是同一个问题,你可以实现下面的方法并以某种方式更改内容

func serviceExtensionTimeWillExpire()

通过添加 UNNotificationServiceExtension 存活的秒数,我发现有时系统甚至不会给你那 30 秒。

关于ios - UNNotificationServiceExtension 有时不运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46991122/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com