应用未运行时推送通知

时间:2016-01-14 11:44:35

标签: ios swift notifications uilocalnotification

如何在应用未运行时推送通知?

我的代码:

var localNotification:UILocalNotification = UILocalNotification()

localNotification.fireDate = NSDate(timeIntervalSinceNow: 5)
localNotification.alertBody = "You have received \(Int(msg)) new messages"
localNotification.timeZone = NSTimeZone.defaultTimeZone()
localNotification.applicationIconBadgeNumber++
//play a sound
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.alertAction = "View"

UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

当我的iOS应用关闭时,他没有检查并显示新通知?谁可以帮我解决这个问题?

有人知道我是否可以在应用关闭时启动计时器。如果有新消息调用该函数来推送本地通知,计时器将每5分钟检查一次

0 个答案:

没有答案