0
我是iOS和Swift的新手。我正在我的應用程序中實施遠程通知。一切正常,當應用程序處於活動狀態或在後臺。但是,當應用程序終止時,我的通知不會顯示出來。我所得到的只是通知的警報聲。應用終止時的遠程通知
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if #available(iOS 10.0, *){
}else{
let notification = UILocalNotification()
notification.alertTitle = "my Title"
notification.alertBody = "My Message"
notification.category = "customCategory"
notification.soundName = UILocalNotificationDefaultSoundName
application.scheduleLocalNotification(notification)
}
}
你可以建議我一些例子?並且在應用程序啓動時調用didFinishLaunchingWithOptions方法。它是如何幫助我在應用程序未運行時顯示通知的? –