微信登陆的回调设置

 

//#pragma mark - 微信登入回调

//-(void) onReq:(BaseReq*)req

//{

//    if([req isKindOfClass:[GetMessageFromWXReq class]])

//    {

//        GetMessageFromWXReq *temp = (GetMessageFromWXReq *)req;

//        

//        // 微信请求App提供内容, 需要app提供内容后使用sendRsp返回

//        NSString *strTitle = [NSString stringWithFormat:@"微信请求App提供内容"];

//        NSString *strMsg = [NSString stringWithFormat:@"openID: %@", temp.openID];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        alert.tag = 1000;

//        [alert show];

//    }

//    else if([req isKindOfClass:[ShowMessageFromWXReq class]])

//    {

//        ShowMessageFromWXReq* temp = (ShowMessageFromWXReq*)req;

//        WXMediaMessage *msg = temp.message;

//        

//        //显示微信传过来的内容

//        WXAppExtendObject *obj = msg.mediaObject;

//        

//        NSString *strTitle = [NSString stringWithFormat:@"微信请求App显示内容"];

//        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, 标题:%@ \n内容:%@ \n附带信息:%@ \n缩略图:%u bytes\n附加消息:%@\n", temp.openID, msg.title, msg.description, obj.extInfo, msg.thumbData.length, msg.messageExt];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

//    else if([req isKindOfClass:[LaunchFromWXReq class]])

//    {

//        LaunchFromWXReq *temp = (LaunchFromWXReq *)req;

//        WXMediaMessage *msg = temp.message;

//        

//        //从微信启动App

//        NSString *strTitle = [NSString stringWithFormat:@"从微信启动"];

//        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, messageExt:%@", temp.openID, msg.messageExt];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

//}

//

//-(void) onResp:(BaseResp*)resp

//{

//    if([resp isKindOfClass:[SendMessageToWXResp class]])

//    {

//        NSString *strTitle = [NSString stringWithFormat:@"发送媒体消息结果"];

//        NSString *strMsg = [NSString stringWithFormat:@"errcode:%d", resp.errCode];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

//    else if([resp isKindOfClass:[SendAuthResp class]])

//    {

//        SendAuthResp *temp = (SendAuthResp*)resp;

//        

//        NSString *strTitle = [NSString stringWithFormat:@"Auth结果"];

//        NSString *strMsg = [NSString stringWithFormat:@"code:%@,state:%@,errcode:%d",temp.code, temp.state, temp.errCode];

//        

//        //用户同意

//        if (0 == temp.errCode) {

//            //开始请求

//            [WXDataServer requestURL:@"https://api.weixin.qq.com/sns/oauth2/access_token"

//                          httpMethod:@"GET"

//                              params:[@{@"appid":kWXAppID,@"secret":kWXAppSecret,@"code":temp.code,@"grant_type":@"authorization_code"} mutableCopy]

//                                file:nil

//                             success:^(id data) {

//                                 NSLog(@"-------------------------success");

//                                 NSString *str = (NSString *)data;

//                                 NSLog(@"-------------------------str:%@",str);

//                             }

//                                fail:^(NSError *error) {

//                                    NSLog(@"-------------------------filed");

//                                    NSLog(@"111111111:%@",error);

//                                    NSLog(@"-------------------------filed");

//                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"请求失败,检查网络" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];

//                                    [alertView show];

//                                }

//             ];

//        }

//    }

//    else if ([resp isKindOfClass:[AddCardToWXCardPackageResp class]])

//    {

//        AddCardToWXCardPackageResp* temp = (AddCardToWXCardPackageResp*)resp;

//        NSMutableString* cardStr = [[NSMutableString alloc] init];

//        for (WXCardItem* cardItem in temp.cardAry) {

//            [cardStr appendString:[NSString stringWithFormat:@"cardid:%@ cardext:%@ cardstate:%lu\n",cardItem.cardId,cardItem.extMsg,cardItem.cardState]];

//        }

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"add card resp" message:cardStr delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

//}

 

#pragma mark - 微信登入回调

-(void) onReq:(BaseReq*)req

{

    NSLog(@"----------");

//    if([req isKindOfClass:[GetMessageFromWXReq class]])

//    {

//        GetMessageFromWXReq *temp = (GetMessageFromWXReq *)req;

//        

//        // 微信请求App提供内容, 需要app提供内容后使用sendRsp返回

//        NSString *strTitle = [NSString stringWithFormat:@"微信请求App提供内容"];

//        NSString *strMsg = [NSString stringWithFormat:@"openID: %@", temp.openID];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        alert.tag = 1000;

//        [alert show];

//    }

//    else if([req isKindOfClass:[ShowMessageFromWXReq class]])

//    {

//        ShowMessageFromWXReq* temp = (ShowMessageFromWXReq*)req;

//        WXMediaMessage *msg = temp.message;

//        

//        //显示微信传过来的内容

//        WXAppExtendObject *obj = msg.mediaObject;

//        

//        NSString *strTitle = [NSString stringWithFormat:@"微信请求App显示内容"];

//        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, 标题:%@ \n内容:%@ \n附带信息:%@ \n缩略图:%u bytes\n附加消息:%@\n", temp.openID, msg.title, msg.description, obj.extInfo, msg.thumbData.length, msg.messageExt];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

//    else if([req isKindOfClass:[LaunchFromWXReq class]])

//    {

//        LaunchFromWXReq *temp = (LaunchFromWXReq *)req;

//        WXMediaMessage *msg = temp.message;

//        

//        //从微信启动App

//        NSString *strTitle = [NSString stringWithFormat:@"从微信启动"];

//        NSString *strMsg = [NSString stringWithFormat:@"openID: %@, messageExt:%@", temp.openID, msg.messageExt];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

}

//

-(void) onResp:(BaseResp*)resp

{

    NSLog(@"----------onResp");

//    if([resp isKindOfClass:[SendMessageToWXResp class]])

//    {

//        NSString *strTitle = [NSString stringWithFormat:@"发送媒体消息结果"];

//        NSString *strMsg = [NSString stringWithFormat:@"errcode:%d", resp.errCode];

//        

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

//    else if([resp isKindOfClass:[SendAuthResp class]])

//    {

//        SendAuthResp *temp = (SendAuthResp*)resp;

//        

//        NSString *strTitle = [NSString stringWithFormat:@"Auth结果"];

//        NSString *strMsg = [NSString stringWithFormat:@"code:%@,state:%@,errcode:%d",temp.code, temp.state, temp.errCode];

//        

//        //用户同意

//        if (0 == temp.errCode) {

//            //开始请求

//            [WXDataServer requestURL:@"https://api.weixin.qq.com/sns/oauth2/access_token"

//                          httpMethod:@"GET"

//                              params:[@{@"appid":kWXAppID,@"secret":kWXAppSecret,@"code":temp.code,@"grant_type":@"authorization_code"} mutableCopy]

//                                file:nil

//                             success:^(id data) {

//                                 NSLog(@"-------------------------success");

//                                 NSString *str = (NSString *)data;

//                                 NSLog(@"-------------------------str:%@",str);

//                             }

//                                fail:^(NSError *error) {

//                                    NSLog(@"-------------------------filed");

//                                    NSLog(@"111111111:%@",error);

//                                    NSLog(@"-------------------------filed");

//                                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"请求失败,检查网络" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];

//                                    [alertView show];

//                                }

//             ];

//        }

//    }

//    else if ([resp isKindOfClass:[AddCardToWXCardPackageResp class]])

//    {

//        AddCardToWXCardPackageResp* temp = (AddCardToWXCardPackageResp*)resp;

//        NSMutableString* cardStr = [[NSMutableString alloc] init];

//        for (WXCardItem* cardItem in temp.cardAry) {

//            [cardStr appendString:[NSString stringWithFormat:@"cardid:%@ cardext:%@ cardstate:%lu\n",cardItem.cardId,cardItem.extMsg,cardItem.cardState]];

//        }

//        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"add card resp" message:cardStr delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

//        [alert show];

//    }

}

转载于:https://www.cnblogs.com/wskgjmhh/p/4610369.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值