我的iOS应用程序有一个共享扩展,用户也可以上传附件。
URLSession
URLSessionConfiguration.background
. 上传完成后,我想向用户展示一些成功的用户界面,并为此选择了一个通知。所以现在在我的完成区,我正在做类似的事情:
let content = UNMutableNotificationContent()
content.body = "Success"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.5, repeats: false)
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
let center = UNUserNotificationCenter.current()
center.add(request)
print("This line is never called")
正如你在我的示例代码中所看到的,这个应用程序被贴上了广告
center.add(request)
. 这个方法就是永远不会完成?!?当调用它时,我在主线程上,但也尝试了其他线程。。。结果总是一样的
有人知道为什么吗?