百度云推送客户端配置IOs

来源:互联网 发布:什么时候开始有的网络 编辑:程序博客网 时间:2024/06/05 19:28

先配置好百度开发文档中的东西,一下实现一个在回调中获取连接,跳转。


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

{

   self.userInfo = userInfo;

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

    //页面激活的状态下 (不在后台)

   if (application.applicationState ==UIApplicationStateActive) {

        //有链接的时候就是资讯   @“urls”这个是自己服务器添加的字段

       if(nil!=[userInfoobjectForKey:@"urls"])

        {

           UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"资讯新闻"

                                                               message:alert

                                                              delegate:self

                                                     cancelButtonTitle:@"稍后"

                                                     otherButtonTitles:@"立即查看",nil];

            [alertViewshow];

            

        }else

        {

           UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"新消息"

                                                               message:alert

                                                              delegate:self

                                                     cancelButtonTitle:@"我知道了"

                                                     otherButtonTitles:nil];

            [alertViewshow];

        }

    }

    //在后台的时候

   else

    {

       if(nil!=[userInfoobjectForKey:@"urls"])

        {

            [[NSNotificationCenterdefaultCenter] postNotificationName:@"url"object:niluserInfo:userInfo];

            

        }

    }

    [application setApplicationIconBadgeNumber:0];

    

    [BPushhandleNotification:userInfo];


}

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

{

   if(buttonIndex==1)

    {

         [[NSNotificationCenterdefaultCenter] postNotificationName:@"url"object:niluserInfo:self.userInfo];

    }

}



在VC中 

 [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(openAction:)name:@"url"object:nil];

-(void)openAction:(NSNotification *)notify

{

           //跳转的指定页面

}


原创粉丝点击