iOS 远程通知
来源:互联网 发布:混血 知乎 编辑:程序博客网 时间:2024/05/19 22:47
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
- // Override point for customization after application launch.
- self.viewController = [[[ViewController alloc] init] autorelease];
- self.window.rootViewController = self.viewController;
- [self.window setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]];
- [self.window makeKeyAndVisible];
- /** 注册推送通知功能, */
- [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
- //判断程序是不是由推送服务完成的
- if (launchOptions) {
- NSDictionary* pushNotificationKey = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
- if (pushNotificationKey) {
- UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"推送通知"
- message:@"这是通过推送窗口启动的程序,你可以在这里处理推送内容"
- delegate:nil
- cancelButtonTitle:@"知道了"
- otherButtonTitles:nil, nil];
- [alert show];
- [alert release];
- }
- }
- return YES;
- }
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- NSString* token = [NSString stringWithFormat:@"%@",deviceToken];
- NSLog(@"apns -> 生成的devToken:%@", token);
- //把deviceToken发送到我们的推送服务器
- DeviceSender* sender = [[[DeviceSender alloc]initWithDelegate:self ]autorelease];
- [sender sendDeviceToPushServer:token ];
- }
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
- NSLog(@"apns -> 注册推送功能时发生错误, 错误信息:\n %@", err);
- }
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
- {
- NSLog(@"\napns -> didReceiveRemoteNotification,Receive Data:\n%@", userInfo);
- //把icon上的标记数字设置为0,
- application.applicationIconBadgeNumber = 0;
- if ([[userInfo objectForKey:@"aps"] objectForKey:@"alert"]!=NULL) {
- UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"**推送消息**"
- message:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]
- delegate:self
- cancelButtonTitle:@"关闭"
- otherButtonTitles:@"处理推送内容",nil];
- alert.tag = alert_tag_push;
- [alert show];
- }
0 0
- iOS 本地通知 远程通知
- iOS本地通知 远程通知
- iOS 远程推送通知
- iOS远程推送通知
- IOS远程推送通知
- iOS远程通知详解
- iOS 远程通知
- IOS远程推送通知
- iOS 远程推送通知
- iOS接收远程通知
- iOS远程通知相关
- iOS远程通知
- ios本地通知和远程通知
- iOS本地通知和远程通知
- ios本地通知和远程通知
- ios本地通知和远程通知
- iOS本地通知和远程通知
- IOS 本地通知和远程通知
- SQLite:注意查询条件中空格的影响
- 实验五 树和二叉树
- cocos2dx简单实现描边
- BOOST 1.56 简明配置方法,资源整理
- 自定义排序
- iOS 远程通知
- POJ2486---Apple Tree
- [Bug Fix]Messy Audio语音电话不清晰问题
- 浮点运算是怎么实现的?
- 我的博客开始更新
- C++句柄类
- copy, retain, assign , readonly , readwrite,strong,weak,nonatomic整理
- 手机回声消除原理
- 霍夫曼编码