我的iOS应用程序中有一个NotificationService扩展,用于修改文本和下载附件。
只要屏幕解锁,这样就可以正常工作。屏幕锁定时,不会调用服务扩展,并且通知显示为默认状态且没有消息。
我的iPhone 7s运行11.2.5。有没有其他人遇到过这个问题并且有相同的解决方案?
答案 0 :(得分:1)
检查您在Payload中传递的文件的大小。因为我们下载内容的时间有限。对于文件大小,请参阅https://developer.apple.com/documentation/usernotifications/unnotificationattachment。
谢谢, 希望它有所帮助。
答案 1 :(得分:1)
Turns out the issue was with the NotificationService Extension not having access to the keychain when the device was locked! duh... feel like an idiot :)
I set the kSecAttrAccessible to kSecAttrAccessibleAfterFirstUnlock while creating the key pair and problem was solved.
[keyDict setObject:(__bridge id)kSecAttrAccessibleAfterFirstUnlock forKey:(__bridge id)kSecAttrAccessible];
So my assumption that OS was not initiating the service extension was incorrect.