代码非常简单:
func application(u application:uiapplication,didFinishLaunchingWithOptions LaunchOptions:[uiapplicationLaunchOptionsky:any]?)->胸部{
unusernotificationCenter.current().requestauthorization(选项:[.alert、.sound、.badge],completionHandler:(已授予,错误)位于
如果!授予{
打印(“不允许”)。
}
})
let content=unmutablenotificationContent()。
content.title=“警报”
content.sound=unnotificationsound.default()。
let trigger=untimeIntervalNotificationContriger(时间间隔:20,重复:假)
let request=unnotificationrequest(标识符:“test”,内容:内容,触发器:触发器)
unUserNotificationCenter.current().add(请求,WithCompletionHandler:nil)
返回true
}
它在iOS 11上运行良好,如下所示:
![](“https://i.stack.imgur.com/ozhs9.png”alt=“enter)
但在iOS 10上,警报不显示。
在iOS 10和iOS 11上,声音确实出现。
我的Xcode版本是9.2(9c40b)
如有任何帮助,我们将不胜感激。
它在iOS 11上运行良好,如下所示:
![enter image description here](https://i.stack.imgur.com/ozHs9.png)
但在iOS 10上,警报不显示。
在iOS 10和iOS 11上,声音确实出现了。
我的Xcode版本是9.2(9c40b)
感谢您的帮助。