2012-07-15 21 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]; 

}