NSString *yourXMLDate = @"08:00" ;
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"HH:mm"];
NSDate *inputDate = [inputFormatter dateFromString:yourXMLDate];
//創建一個本地推送
UILocalNotification *noti = [[[UILocalNotification alloc] init] autorelease];
if (noti) {
//設置推送時間
noti.fireDate = inputDate;
//設置時區
noti.timeZone = [NSTimeZone defaultTimeZone];
//設置重複間隔
noti.repeatInterval = NSWeekdayCalendarUnit;
//推送聲音
noti.soundName = UILocalNotificationDefaultSoundName;
//內容
noti.alertBody = @"推送內容";
//顯示在icon上的紅色圈中的數子
noti.applicationIconBadgeNumber = 1;
//設置userinfo 方便在之後需要撤銷的時候使用
NSDictionary *infoDic = [NSDictionary dictionaryWithObject:@"name" forKey:@"key"];
noti.userInfo = infoDic;
//添加推送到uiapplication
UIApplication *app = [UIApplication sharedApplication];
[app scheduleLocalNotification:noti];
}
本地消息推送
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
如何截取字符串裏面的所有數字
bloues
2020-02-24 02:34:41
兩個ViewController間傳值--回傳
bloues
2020-02-24 02:34:41
MBProgressHUD的使用-ios
bloues
2020-02-24 02:34:41
CALayer和CCLayer
bloues
2020-02-24 02:34:41
return/enter鍵退出鍵盤
bloues
2020-02-24 02:34:41
響應操作與內存之間的關係
bloues
2020-02-24 02:34:41
如何截取字符串裏面的所有數字
bloues
2020-02-24 02:34:41
兩個ViewController間傳值--回傳
bloues
2020-02-24 02:34:41
MBProgressHUD的使用-ios
bloues
2020-02-24 02:34:41
CALayer和CCLayer
bloues
2020-02-24 02:34:41
iOS圖片拉伸/適應
bloues
2020-02-24 02:34:41
return/enter鍵退出鍵盤
bloues
2020-02-24 02:34:41
響應操作與內存之間的關係
bloues
2020-02-24 02:34:41