ui本地通知不起作用

时间:2016-01-22 02:12:20

标签: ios swift2 uilocalnotification

我将本地通知设置为从应用程序启动后的1秒开始,然后在那个时间每天开始,由于某种原因它正在运行,我甚至没有收到初始通知,有人可以帮助我吗? Code Screenshot

1 个答案:

答案 0 :(得分: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!")
}