我設置了本地通知,從應用程序啓動的時間開始1秒,然後在那個時間的每一天,由於某種原因它正在工作,我甚至沒有收到初始通知,有人可以請幫我? Code Screenshotui本地通知不起作用
0
A
回答
0
你加這個代碼
let userNotificationTypes : UIUserNotificationType = [.Alert, .Badge, .Sound]
let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
application.registerUserNotificationSettings(settings)
到您的AppDelegate
小號didFinishLaunching功能?
而這種代碼在你AppDelegate
作出處理:
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
print("local notification received!")
}
+0
是的,我說,但它仍然不工作 –
+0
它打印出「本地通知收到」,但沒有通知彈出,請幫助 –
+0
沒關係它的工作,謝謝很多:) –
它的工作或者不工作? – kb920