码迷,mamicode.com
首页 > 移动开发 > 详细

iOS关于本地推送

时间:2014-11-30 15:25:17      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   os   on   div   log   cti   代码   

?

不多说 直接上代码
?

NSDate *now = [NSDate date];
    UILocalNotification *reminderNotification = [[UILocalNotification alloc] init];
    //  本地消息的时间间隔
    [reminderNotification setFireDate: [now dateByAddingTimeInterval: 10]];
    //  重复间隔 会在1分钟后重复提醒,并在提醒后的下句指定时间再次提醒 即使App退出 依然会提醒 骚扰必备....
    [reminderNotification setRepeatInterval: NSCalendarUnitSecond];
    //  时区
    [reminderNotification setTimeZone: [NSTimeZone localTimeZone]];
    //  本地推送的消息内容
    [reminderNotification setAlertBody: @"本地推送测试"];
    //  在锁屏时,会显示"滑动来"+Action内容 无此句则为默认:滑动查看
    [reminderNotification setAlertAction: @"启动"];
    //  推送时的声音
    [reminderNotification setSoundName: UILocalNotificationDefaultSoundName];
    //  增加应用图标badge
    [reminderNotification setApplicationIconBadgeNumber: 1];
    //设置随Notification传递的参数
    NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"reminder", @"notificationId", nil];
    reminderNotification.userInfo = infoDict;
    //  注册本地推送
    [[UIApplication sharedApplication] scheduleLocalNotification: reminderNotification];


?

iOS关于本地推送

标签:blog   io   ar   os   on   div   log   cti   代码   

原文地址:http://www.cnblogs.com/jz319/p/4133070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!