本地推送
2014-11-04 16:29
351 查看
对于iOS来说有两种推送
#1.远程推送
#2.本地推送
接下来主要将的是本地推送
#3.响应点击通知栏回掉 From Appdelegate.m
#1.远程推送
#2.本地推送
接下来主要将的是本地推送
-(void)joinNotificationPush { UILocalNotification *localNotification=[[UILocalNotification alloc]init]; if (localNotification) { /*设置1秒后相应通知*/ NSDate *pushDate=[NSDate dateWithTimeIntervalSinceNow:1]; localNotification.fireDate=pushDate; /*设置时区*/ localNotification.timeZone=[NSTimeZone defaultTimeZone]; /*设置重复推送的类型*/ localNotification.repeatInterval=kCFCalendarUnitDay; /*设置推送声音类型*/ localNotification.soundName=UILocalNotificationDefaultSoundName; /*设置推送的内容*/ localNotification.alertBody =@"XXX 你妈妈 叫你回家吃饭!"; /*设置推送时的图片*/ localNotification.alertLaunchImage=[NSString stringWithFormat:@"3"]; /*设置应用头标红色徽章次数*/ localNotification.applicationIconBadgeNumber=10; /* 设置通知表示*/ NSDictionary *userInfoDic=[NSDictionary dictionaryWithObject:@"LGW" forKey:@"GW"]; localNotification.userInfo=userInfoDic; /*判断当前通知已存在*/ UIApplication *app=[UIApplication sharedApplication]; BOOL stauts=YES; for (UILocalNotification *localNotificate in app.scheduledLocalNotifications) { if (localNotification.userInfo==localNotificate.userInfo) { stauts=NO; } } if (stauts) { [app scheduleLocalNotification:localNotification]; } } } /*取消通知根据本地通知标识*/ -(void)cancelNotificationPush { UIApplication *app=[UIApplication sharedApplication]; NSArray *notificationary=[app scheduledLocalNotifications]; for (UILocalNotification *location in notificationary) { NSDictionary *dic=[location userInfo]; if (dic) { NSString *key=[dic objectForKey:@"GW"]; if ([key isEqualToString:@"LGW"]) { [app cancelLocalNotification:location]; break; } } } }
#3.响应点击通知栏回掉 From Appdelegate.m
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { NSLog(@"deviceToken didReceive"); }
相关文章推荐
- OSC本地库推送到远程库
- Android利用极光推送获取到消息并缓存至本地
- android本地推送(退出app后依然可以)
- unity3d 之本地推送
- cocos2dx 本地推送通知的实现
- IOS本地推送即IOS备忘提醒实现
- 本地通知和远程推送
- ios推送:本地通知UILocalNotification
- 本地推送UILocalNotification
- 本地定时推送
- SWIFT推送之本地推送(UILocalNotification)
- iPhone/iPad开发通过LocalNotification实现iOS定时本地推送功能
- ios推送:本地通知UILocalNotification
- ios本地推送
- SWIFT推送之本地推送(UILocalNotification)-1
- IOS-推送消息(本地推送)
- 本地推送的实现
- ios 远程推送和本地推送
- iOS开发——在特定时间、任意时间做本地推送UILocalNotification
- Swift 本地推送通知UILocalNotification