• 《友盟推送调到指定界面》


      给大家讲一点常识,友盟推送分生产环境和开发环境。用手机刷上去的就是开发环境, 发布到苹果商店就是生产环境,没发布前怎么模拟呢, 用普通账号打的ad hoc 包, 用企业账号打的ad hoc 包或者enterprise包都可以测试生产环境。

      开发环境下, 你把APP删掉,重新调试上来,就会生成一个新的device_token了!

      

      收到通知的时候APP的状态可能是未启动、前台活跃(任何界面)、后台等三种。

    • 未启动时,点击通知栏启动App, 会在didFinishLaunchingWithOptions方法里收到通知内容。
    • 剩下两种会在didReceiveRemoteNotification方法里收到通内容。

      

    当App在前台或后台的时候的处理逻辑

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

    {

        self.notifyDic = userInfo;

         [UMessage setAutoAlert:NO];

        [UMessage didReceiveRemoteNotification:userInfo];

        for (NSString *key in userInfo) {

            NSLog(@"%@---%@-----%@",key,[userInfo objectForKey:key],userInfo);

        }

        

        

        

    /*

        CHTabBarViewController *tabbarUm = (CHTabBarViewController *)self.window.rootViewController;

        CHMyInsurancePolicyViewController *twoNav = [[CHMyInsurancePolicyViewController alloc]init];

        twoNav.tuisong = @"song";

        UINavigationController * nav1 = tabbarUm.viewControllers[0];

        

        [nav1 pushViewController:twoNav animated:YES];

    */

        

        if([UIApplication sharedApplication].applicationState == UIApplicationStateActive)

        {

            

            CHTabBarViewController *tabbarUm = (CHTabBarViewController *)self.window.rootViewController;

            CHMyInsurancePolicyViewController *twoNav = [[CHMyInsurancePolicyViewController alloc]init];

            twoNav.tuisong = @"song";

            UINavigationController * nav1 = tabbarUm.viewControllers[0];

            

            UIAlertController *alertCon = [UIAlertController alertControllerWithTitle:@"车易" message:[userInfo[@"aps"] objectForKey:@"alert"] preferredStyle:UIAlertControllerStyleAlert];

            

            UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *action) {

                // 点击按钮后的方法直接在这里面写

                

                if ([[userInfo objectForKey:@"keyWord"]isEqualToString:@"order"]) {

                    [nav1 pushViewController:twoNav animated:YES];

                }else{

                    

                    CHHealthyMeViewController *chC = [[CHHealthyMeViewController alloc]init];

                    

                    [nav1 pushViewController:chC animated:YES];

                    

                }

                //[nav1 pushViewController:twoNav animated:YES];

                

                

            }];

            

            [alertCon addAction:okAction];

            

            [tabbarUm.viewControllers[0] presentViewController:alertCon animated:YES completion:nil];

        }else{

            

            CHTabBarViewController *tabbarUm = (CHTabBarViewController *)self.window.rootViewController;

            CHMyInsurancePolicyViewController *twoNav = [[CHMyInsurancePolicyViewController alloc]init];

            twoNav.tuisong = @"song";

            UINavigationController * nav1 = tabbarUm.viewControllers[0];

            

            if ([[userInfo objectForKey:@"keyWord"]isEqualToString:@"order"]) {

            [nav1 pushViewController:twoNav animated:YES];

            }else{

                

            CHHealthyMeViewController *chC = [[CHHealthyMeViewController alloc]init];

            

            [nav1 pushViewController:chC animated:YES];

                

            }

    }

    }

     

    当程序未启动的时候

    我这里是在applicationdelegate里面写一个属性 didFinishLaunchingWithOptions 方法里面写:

     NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

        if(userInfo){//推送信息

            self.notifyDic = userInfo;//[userInfo copy]

        }

    在首页处理

    viewdidload 判断用户是否接到通知

    {

        AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate;

        //可以根据他是否为空来判断是否有通知

        [self getPushInfo:app.notifyDic];

    {

    // 推送处理

    -(void)getPushInfo:(NSDictionary *)notidic

    {

        

        NSString *  pushName = [[notidic objectForKey:@"aps"] objectForKey:@"alert"];

        NSLog(@"0-0-0--%@",pushName);

        if (pushName) {

            

        CHMyInsurancePolicyViewController *Con = [[CHMyInsurancePolicyViewController alloc]init];

        Con.navigationItem.hidesBackButton = YES;

            

            if ([[notidic objectForKey:@"keyWord"]isEqualToString:@"order"]) {

                [self.navigationController pushViewController:Con animated:YES];

            }else{

                

                CHHealthyMeViewController *chC = [[CHHealthyMeViewController alloc]init];

                

                [self.navigationController pushViewController:chC animated:YES];

                

            }

            

        }

    }

     
  • 相关阅读:
    git 的分支体系命令汇总
    git命令行学习思路总结
    angular1.5版本的自我认识
    我最想去的公司啊 -- 幸福面试两小时
    【转】【Asp.Net MVC】asp.net mvc Model验证总结及常用正则表达式
    时间被序列化后的页面显示的问题
    JS组件Bootstrap实现弹出框和提示框效果代码
    Bootstrap组件之导航条
    Bootstrap学习笔记(四)-----Bootstrap每天必学之表单
    Bootstrap学习笔记(三)-----Bootstrap每天必学之表格
  • 原文地址:https://www.cnblogs.com/walkingzmz/p/5382024.html
Copyright © 2020-2023  润新知