我对swift非常陌生,我需要一些帮助。我想用每日背景提取更新AppDelegate中的Parse。奇怪的是这在模拟器上有效但在我的实际设备上不起作用。当我再次打开应用程序时,通知会触发。任何帮助,将不胜感激。
func application(application: UIApplication,
performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
// Do something
var rankCout = 1
var query = PFQuery(className: "Person")
query.orderByDescending("Score")
query.findObjectsInBackgroundWithBlock{
(objects: [AnyObject]!, error:NSError!)-> Void in
if error == nil
{
for object in objects
{
if ((object["Name"]) as NSString == (NSUserDefaults.standardUserDefaults().objectForKey("USERNAME")) as NSString)
{
var notification:UILocalNotification = UILocalNotification()
notification.alertBody = "TEST"
println("PUSH")
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}
}
}
}
}