iOS 本地通知

// 代碼如下,是轉載別處的,別處也是轉載其他地方的,就未寫明出處了。發現在xcode 5.1 的模擬器上可以測試,在xcode 6 上的模擬器就出不來,浪費了我不少的時間。

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

    if (notification!=nil) {

        NSLog(@">> support local notification");

        NSDate *now=[NSDate new];

        notification.fireDate=[now dateByAddingTimeInterval:3];

        notification.timeZone=[NSTimeZone defaultTimeZone];

        notification.alertBody=@"該去吃晚飯了!";

        [[UIApplication sharedApplication]   scheduleLocalNotification:notification];

    }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章