最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iPhone/iPad開(kāi)發(fā)通過(guò)LocalNotification實(shí)現(xiàn)iOS定時(shí)本地推送功能

 更新時(shí)間:2016年09月21日 14:53:18   投稿:lijiao  
這篇文章主要介紹了iPhone/iPad開(kāi)發(fā)之通過(guò)LocalNotification實(shí)現(xiàn)iOS定時(shí)本地推送功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

通過(guò)iOS的UILocalNotification Class可以實(shí)現(xiàn)本地app的定時(shí)推送功能,即使當(dāng)前app是后臺(tái)關(guān)閉狀態(tài)。 

可以實(shí)現(xiàn)諸如,設(shè)置app badgenum,彈出一個(gè)alert,播放聲音等等,實(shí)現(xiàn)很簡(jiǎn)單 

UILocalNotification *notification=[[UILocalNotification alloc] init];
 if (notification!=nil) {
  NSDate *now=[NSDate new];
  notification.fireDate=[now dateByAddingTimeInterval:15];
  notification.timeZone=[NSTimeZone defaultTimeZone];
  notification.alertBody=@"定時(shí)推送通知!";
  notification.soundName = @"default";
  [notification setApplicationIconBadgeNumber:22];
  [[UIApplication sharedApplication] scheduleLocalNotification:notification];
 }


 寫(xiě)了一個(gè)demo,大家直接看demo就一目了然了,很方便,在適當(dāng)場(chǎng)合使用還是蠻實(shí)用的~

源代碼鏈接:https://github.com/andypan1314/LocalNotificationTest 

iOS 設(shè)置每天下午4點(diǎn)推送本地通知

UILocalNotification *notification=[[UILocalNotification alloc] init];
 if (notification!=nil) {//判斷系統(tǒng)是否支持本地通知
  notification.fireDate = [NSDate dateWithTimeIntervalSince1970:16*60*60*24];//本次開(kāi)啟立即執(zhí)行的周期
  notification.repeatInterval=kCFCalendarUnitWeekday;//循環(huán)通知的周期
  notification.timeZone=[NSTimeZone defaultTimeZone];
  notification.alertBody=@"哇哇哇";//彈出的提示信息
  notification.applicationIconBadgeNumber=0; //應(yīng)用程序的右上角小數(shù)字
  notification.soundName= UILocalNotificationDefaultSoundName;//本地化通知的聲音
//notification.alertAction = NSLocalizedString(@"美女呀", nil); //彈出的提示框按鈕
  notification.hasAction = NO;
  [[UIApplication sharedApplication] scheduleLocalNotification:notification];
 }

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

南丹县| 祥云县| 长武县| 连城县| 新密市| 广丰县| 虎林市| 景泰县| 庆阳市| 乳山市| 陈巴尔虎旗| 清镇市| 武夷山市| 宿州市| 棋牌| 武胜县| 石台县| 都昌县| 平和县| 华池县| 衢州市| 广灵县| 横峰县| 都江堰市| 汤原县| 贵阳市| 平山县| 龙海市| 贺州市| 永昌县| 新平| 和龙市| 双牌县| 西安市| 连州市| 柞水县| 行唐县| 商都县| 北安市| 长汀县| 尤溪县|