iOS定時通知
#pragma mark 添加本地通知 -(void)addLocalNotification{//定義本地通知對象 UILocalNotification *notification=[[UILocalNotification alloc]init]; //設置調用時間 notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:10.0];//通知觸發的時間,10s以后 notification.repeatInterval=2;//通知重復次數 //notification.repeatCalendar=[NSCalendar currentCalendar];//當前日歷,使用前最好設置時區等信息以便能夠自動同步時間 //設置通知屬性 notification.alertBody=@"最近添加了諸多有趣的特性,是否立即體驗?"; //通知主體 notification.applicationIconBadgeNumber=1;//應用程序圖標右上角顯示的消息數 notification.alertAction=@"打開應用"; //待機界面的滑動動作提示 notification.alertLaunchImage=@"Default";//通過點擊通知打開應用時的啟動圖片,這里使用程序啟動圖片 //notification.soundName=UILocalNotificationDefaultSoundName;//收到通知時播放的聲音,默認消息聲音 notification.soundName=@"msg.caf";//通知聲音(需要真機才能聽到聲音) //設置用戶信息 notification.userInfo=@{@"id":@1,@"user":@"Kenshin Cui"};//綁定到通知上的其他附加信息 //調用通知 [[UIApplication sharedApplication] scheduleLocalNotification:notification];
}</pre>
本文由用戶 bx52 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!