IOS极光推送

来源:互联网 发布:淘宝特卖下载 编辑:程序博客网 时间:2024/05/17 01:31

    //极光推送

    if ([[UIDevicecurrentDevice].systemVersionfloatValue] >= 8.0) {

        //可以添加自定义categories

        [JPUSHServiceregisterForRemoteNotificationTypes:(UIUserNotificationTypeBadge |

                                                          UIUserNotificationTypeSound |

                                                          UIUserNotificationTypeAlert)

                                              categories:nil];

    } else {

        //categories 必须为nil

        [JPUSHServiceregisterForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |

                                                          UIRemoteNotificationTypeSound |

                                                          UIRemoteNotificationTypeAlert)

                                              categories:nil];

    }

    

    

    // Required

    //如需兼容旧版本的方式,请依旧使用[JPUSHService setupWithOption:launchOptions]方式初始化和同时使用pushConfig.plist文件声明appKey等配置内容。

    [JPUSHServicesetupWithOption:launchOptionsappKey:appKeychannel:channelapsForProduction:isProduction];






-(void) playSound

{

//    NSString *path = [[NSBundle mainBundle] pathForResource:@"shake_sound_male" ofType:@"wav"];

//    if (path) {

//        //注册声音到系统

//        AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path],&shake_sound_male_id);

//        AudioServicesPlaySystemSound(shake_sound_male_id);

//        //        AudioServicesPlaySystemSound(shake_sound_male_id);//如果无法再下面播放,可以尝试在此播放

//    }

//    

//    AudioServicesPlaySystemSound(shake_sound_male_id);   //播放注册的声音,(此句代码,可以在本类中的任意位置调用,不限于本方法中)

    

    NSDictionary *setDic = (NSDictionary *)[JGGchijiuhuaJGGhuoquJSONname:@"小二郎"];

    //01

    NSLog(@"获取结果%@",setDic);

    NSString *voice=[setDicobjectForKey:@"voice"];

    NSString *shock=[setDicobjectForKey:@"shock"];

    NSLog(@"dd:%@+++++%@",voice,shock);


    if ([voiceisEqualToString:@"1"]) {

        AudioServicesPlaySystemSound(1002);//系统声音http://blog.sina.com.cn/s/blog_49b531af0102e4lm.html

    }

    

    if ([shockisEqualToString:@"1"]) {

        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);  //系统震动

    }


}






- (void)applicationWillResignActive:(UIApplication *)application {

    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}


- (void)applicationDidEnterBackground:(UIApplication *)application {

    [[UIApplicationsharedApplication]setApplicationIconBadgeNumber:0];//用到极光推送新增

    

}


- (void)applicationWillEnterForeground:(UIApplication *)application {

    [application setApplicationIconBadgeNumber:0];//用到极光推送新增

    [application cancelAllLocalNotifications];//用到极光推送新增

}


- (void)applicationDidBecomeActive:(UIApplication *)application {

    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}


- (void)applicationWillTerminate:(UIApplication *)application {

    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}


//此处以下为极光推送用到的地方


- (void)application:(UIApplication *)application

didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

    // deviceToken转换成字符串,以便后续使用

    NSString *tokenToDevice = [deviceTokendescription];

    NSLog(@"description %@", tokenToDevice);

    [JPUSHServiceregisterDeviceToken:deviceToken];

}


- (void)application:(UIApplication *)application

didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {

    NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);

}


#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1

- (void)application:(UIApplication *)application

didRegisterUserNotificationSettings:

(UIUserNotificationSettings *)notificationSettings {

    [application registerForRemoteNotifications];

}


- (void)application:(UIApplication *)application

handleActionWithIdentifier:(NSString *)identifier

forLocalNotification:(UILocalNotification *)notification

  completionHandler:(void (^)())completionHandler {

}


- (void)application:(UIApplication *)application

handleActionWithIdentifier:(NSString *)identifier

forRemoteNotification:(NSDictionary *)userInfo

  completionHandler:(void (^)())completionHandler {

}

#endif


- (void)application:(UIApplication *)application

didReceiveRemoteNotification:(NSDictionary *)userInfo {

    [JPUSHServicehandleRemoteNotification:userInfo];

}


- (void)application:(UIApplication *)application

didReceiveRemoteNotification:(NSDictionary *)userInfo

fetchCompletionHandler:

(void (^)(UIBackgroundFetchResult))completionHandler {


    [JPUSHServiceresetBadge];

    [[UIApplicationsharedApplication]setApplicationIconBadgeNumber:0];


    //[self playSound];

    [selfinitWithMemberZiDingYiToPost];


    [JPUSHServicehandleRemoteNotification:userInfo];

    NSLog(@"收到通知:%@", [self logDic:userInfo]);

//    NSString *content=[[userInfo objectForKey:@"aps"]objectForKey:@"alert"];

//    [HUDProgress showWithTitle:[NSString stringWithFormat:@"收到通知:%@",content] type:HUDProgressTypeError];

//    //[HUDProgress showInView:self.window withTitle:[NSString stringWithFormat:@"收到通知:%@",[self logDic:userInfo]] type:HUDProgressTypeError];

//    completionHandler(UIBackgroundFetchResultNewData);

//    [self initWithMemberPuTongToPost];


    _content=[[userInfoobjectForKey:@"aps"]objectForKey:@"alert"];

    NSDictionary *extras = userInfo;

    _customizeField1 = [extrasvalueForKey:@"messageKey"];

 

    if (![[extrasvalueForKey:@"msgId"]isKindOfClass:[NSNullclass]]) {

        msgId = [extrasvalueForKey:@"msgId"];

    }

    

    if (![[extrasvalueForKey:@"sourceType"]isKindOfClass:[NSNullclass]]) {

        sourceType = [extrasvalueForKey:@"sourceType"];

    }

    

    if (![[extrasvalueForKey:@"targetId"]isKindOfClass:[NSNullclass]]) {

        targetId = [extrasvalueForKey:@"targetId"];

        

    }

    

    

    

    if([UIApplicationsharedApplication].applicationState ==UIApplicationStateActive)

    {  //此时app在前台运行,我的做法是弹出一个alert,告诉用户有一条推送,用户可以选择查看或者忽略

        if ([_customizeField1isEqualToString:@"10"]||[_customizeField1isEqualToString:@"11"]||[_customizeField1isEqualToString:@"12"]) {

            [selfplaySound];

           //应用正处理前台状态下,不会收到推送消息,因此在此处需要额外处理一下

            //if (!_alert) {

            _alert = [[UIAlertViewalloc]initWithTitle:@"收到推送消息"

                                                message:_content

                                               delegate:nil

                                      cancelButtonTitle:@"取消"

                                      otherButtonTitles:@"确定",nil];

            _alert.delegate=self;

            [_alertshow];

            //}

            

        }

        

        if ([_customizeField1isEqualToString:@"13"]){

            [HUDProgressshowWithTitle:[NSStringstringWithFormat:@"收到通知:%@",_content]type:HUDProgressTypeErrorafterDelay:2];

        }

        

    }else {

        //这里是app未运行或者在后台,通过点击手机通知栏的推送消息打开app时可以在这里进行处理,比如,拿到推送里的内容或者附加      字段(假设,推送里附加了一个url www.baidu.com),那么你就可以拿到这个url,然后进行跳转到相应店web页,当然,不一定必须是web页,也可以是你app里的任意一个controll,跳转的话用navigation或者模态视图都可以

        

        

        

        if ([_customizeField1isEqualToString:@"1"]) {

            LsOrderManagementViewController*orderManagementNotificationVC=[[LsOrderManagementViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:orderManagementNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            orderManagementNotificationVC.isOrderManagentNotificationPush=YES;

            orderManagementNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"2"]) {

            LsMyOrderViewController*orderNotificationVC=[[LsMyOrderViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:orderNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            orderNotificationVC.isOrderNotificationPush=YES;

            orderNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"3"]) {

            LsMyCouponViewController*CouponNotificationVC=[[LsMyCouponViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:CouponNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            CouponNotificationVC.isCouponNotificationPush=YES;

            CouponNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"4"]) {

            LsMyCashCouponViewController*CashCouponNotificationVC=[[LsMyCashCouponViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:CashCouponNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            CashCouponNotificationVC.isCashCouponNotificationPush=YES;

            CashCouponNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"5"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"6"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"7"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"8"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"9"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"10"]) {

            [selfplaySound];

            

            if ((sourceType.length>0)&&(targetId.length>0)) {

                //发布来源类型(0:平台、1App

                if ([sourceTypeisEqualToString:@"0"]) {//平台

                    

                    PostWebWebDetailController *postVc = [[PostWebWebDetailControlleralloc]init];

                    UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                    postVc.hidesBottomBarWhenPushed =YES;

                    postVc.postId =targetId;

                    postVc.msgId=msgId;

                    postVc.isMessageNotificationPush=YES;

                    [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

                }

                

                if ([sourceTypeisEqualToString:@"1"]) {//app

                    

                    PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

                    postVc.hidesBottomBarWhenPushed =YES;

                    postVc.postId =targetId;

                    postVc.msgId=msgId;

                    postVc.isMessageNotificationPush=YES;

                    UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                    [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

                    

                }

                

                

            }

            

            

        }elseif ([_customizeField1isEqualToString:@"11"]) {

            [selfplaySound];

            

            if (targetId.length>0){

                

                ShopingViewController *shopNav = [[ShopingViewControlleralloc]init];

                shopNav.hidesBottomBarWhenPushed=YES;

                shopNav.productId =targetId;

                shopNav.msgId=msgId;

                shopNav.isMessageNotificationPush=YES;

                UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:shopNav];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

            }

            

            

        }elseif ([_customizeField1isEqualToString:@"12"]) {

            [selfplaySound];

            

            if (targetId.length>0){

                

                ShopDeteilViewController *shopNav = [[ShopDeteilViewControlleralloc]init];

                

                shopNav.hidesBottomBarWhenPushed=YES;

                shopNav.compayid =targetId;

                shopNav.msgId=msgId;

                shopNav.isMessageNotificationPush=YES;

                UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:shopNav];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

            }

            

            

        }elseif ([_customizeField1isEqualToString:@"13"]) {

            [HUDProgressshowWithTitle:[NSStringstringWithFormat:@"收到通知:%@",_content]type:HUDProgressTypeErrorafterDelay:2];

        }


    }

    

    

//    if ([_customizeField1 isEqualToString:@"10"]||[_customizeField1 isEqualToString:@"11"]||[_customizeField1 isEqualToString:@"12"]) {

//        

//        // 应用正处理前台状态下,不会收到推送消息,因此在此处需要额外处理一下

//        //if (!_alert) {

//        _alert = [[UIAlertView alloc] initWithTitle:@"收到推送消息"

//                                            message:content

//                                           delegate:nil

//                                  cancelButtonTitle:@"取消"

//                                  otherButtonTitles:@"确定",nil];

//        _alert.delegate=self;

//        [_alert show];

//        //}

//        

//    }


    

    

}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    if (buttonIndex==1) {

        if ([_customizeField1isEqualToString:@"1"]) {

            LsOrderManagementViewController*orderManagementNotificationVC=[[LsOrderManagementViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:orderManagementNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            orderManagementNotificationVC.isOrderManagentNotificationPush=YES;

            orderManagementNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"2"]) {

            LsMyOrderViewController*orderNotificationVC=[[LsMyOrderViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:orderNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            orderNotificationVC.isOrderNotificationPush=YES;

            orderNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"3"]) {

            LsMyCouponViewController*CouponNotificationVC=[[LsMyCouponViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:CouponNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            CouponNotificationVC.isCouponNotificationPush=YES;

            CouponNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"4"]) {

            LsMyCashCouponViewController*CashCouponNotificationVC=[[LsMyCashCouponViewControlleralloc]init];

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:CashCouponNotificationVC];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            CashCouponNotificationVC.isCashCouponNotificationPush=YES;

            CashCouponNotificationVC.hidesBottomBarWhenPushed =YES;

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"5"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"6"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"7"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"8"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"9"]) {

            PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

            postVc.hidesBottomBarWhenPushed =YES;

            postVc.postId =targetId;

            postVc.isMessageNotificationPush=YES;

            UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

            [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

        }elseif ([_customizeField1isEqualToString:@"10"]) {

            if ((sourceType.length>0)&&(targetId.length>0)) {

                //发布来源类型(0:平台、1App

                if ([sourceTypeisEqualToString:@"0"]) {//平台

                    

                    PostWebWebDetailController *postVc = [[PostWebWebDetailControlleralloc]init];

                    UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                    postVc.hidesBottomBarWhenPushed =YES;

                    postVc.postId =targetId;

                    postVc.msgId=msgId;

                    postVc.isMessageNotificationPush=YES;

                    [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

                }

                

                if ([sourceTypeisEqualToString:@"1"]) {//app

                    

                    PostDetailViewController *postVc = [[PostDetailViewControlleralloc]init];

                    postVc.hidesBottomBarWhenPushed =YES;

                    postVc.postId =targetId;

                    postVc.msgId=msgId;

                    postVc.isMessageNotificationPush=YES;

                    UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:postVc];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                    [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

                    

                }

                

                

            }

            

            

        }elseif ([_customizeField1isEqualToString:@"11"]) {

            if (targetId.length>0){

                

                ShopingViewController *shopNav = [[ShopingViewControlleralloc]init];

                shopNav.hidesBottomBarWhenPushed=YES;

                shopNav.productId =targetId;

                shopNav.msgId=msgId;

                shopNav.isMessageNotificationPush=YES;

                UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:shopNav];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

            }

            

            

        }elseif ([_customizeField1isEqualToString:@"12"]) {

            if (targetId.length>0){

                

                ShopDeteilViewController *shopNav = [[ShopDeteilViewControlleralloc]init];

                

                shopNav.hidesBottomBarWhenPushed=YES;

                shopNav.compayid =targetId;

                shopNav.msgId=msgId;

                shopNav.isMessageNotificationPush=YES;

                UINavigationController * Nav = [[UINavigationControlleralloc]initWithRootViewController:shopNav];//这里加导航栏是因为我跳转的页面带导航栏,如果跳转的页面不带导航,那这句话请省去。

                [self.window.rootViewControllerpresentViewController:Navanimated:YEScompletion:nil];

            }

            

            

        }elseif ([_customizeField1isEqualToString:@"13"]) {

            [HUDProgressshowWithTitle:[NSStringstringWithFormat:@"收到通知:%@",_content]type:HUDProgressTypeErrorafterDelay:2];

        }

        

        

        

    }else{

    }

}


- (void)application:(UIApplication *)application

didReceiveLocalNotification:(UILocalNotification *)notification {

    [JPUSHServiceshowLocalNotificationAtFront:notificationidentifierKey:nil];

}


// log NSSet with UTF8

// if not ,log will be \Uxxx

- (NSString *)logDic:(NSDictionary *)dic {

    if (![diccount]) {

        returnnil;

    }

    NSString *tempStr1 =

    [[dic description]stringByReplacingOccurrencesOfString:@"\\u"

                                                 withString:@"\\U"];

    NSString *tempStr2 =

    [tempStr1 stringByReplacingOccurrencesOfString:@"\""withString:@"\\\""];

    NSString *tempStr3 =

    [[@"\""stringByAppendingString:tempStr2]stringByAppendingString:@"\""];

    NSData *tempData = [tempStr3dataUsingEncoding:NSUTF8StringEncoding];

    NSString *str =

    [NSPropertyListSerializationpropertyListFromData:tempData

                                     mutabilityOption:NSPropertyListImmutable

                                               format:NULL

                                     errorDescription:NULL];

    return str;

}




1 0
原创粉丝点击