我设置了本地通知,从应用程序启动的时间开始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