2012-07-15 51 views
2

有没有办法让iOS的本地推送通知在OSX上工作?我有一个程序,即使程序关闭,我也希望从本地计算机收到预定的通知。我可以在OSX上使用iOS的本地推送通知吗

+0

我认为你知道刚才看你如何措辞这个问题的答案......话虽这么说,搜索“用户通知+山狮“,你应该找到更多的信息 – 2012-07-15 09:04:33

回答

-1
+0

这些通知立即发送,我认为该程序必须开放接收它们。 – Zone12 2012-07-15 10:52:37

+0

从mac开始,寻找通知,直到启动一个特定的应用程序(另一个通知的方式),让它们变得容易,无论如何还有NSNotificationSuspensionBehaviorHold 服务器保存所有匹配的通知,直到队列被填充(队列大小由服务器确定),服务器可以在该点刷新排队的通知。 – divol 2012-07-15 18:32:33

0

这是本地通知

- (void)scheduleNotificationWithItem:(ToDoItem *)item interval:(int)minutesBefore { 

    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar]; 

    NSDateComponents *dateComps = [[NSDateComponents alloc] init]; 

    [dateComps setDay:item.day]; 

    [dateComps setMonth:item.month]; 

    [dateComps setYear:item.year]; 

    [dateComps setHour:item.hour]; 

    [dateComps setMinute:item.minute]; 

    NSDate *itemDate = [calendar dateFromComponents:dateComps]; 

    [dateComps release]; 



    UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 

    if (localNotif == nil) 

     return; 

    localNotif.fireDate = [itemDate addTimeInterval:-(minutesBefore*60)]; 

    localNotif.timeZone = [NSTimeZone defaultTimeZone]; 



    localNotif.alertBody [email protected]"Local Notification"; 

    localNotif.alertAction = NSLocalizedString(@"View Details", nil); 



    localNotif.soundName = UILocalNotificationDefaultSoundName; 

    localNotif.applicationIconBadgeNumber = 1; 



    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:item.eventName forKey:ToDoItemKey]; 

    localNotif.userInfo = infoDict; 



    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 

    [localNotif release]; 

}