• 微信登陆的回调设置


     

    //#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: %@, 标题:%@ 内容:%@ 附带信息:%@ 缩略图:%u bytes 附加消息:%@ ", 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 ",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: %@, 标题:%@ 内容:%@ 附带信息:%@ 缩略图:%u bytes 附加消息:%@ ", 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 ",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];

    //    }

    }

  • 相关阅读:
    定位练习
    解决 java.lang.RuntimeException: Unable to start activity ComponentInfo{...}
    开发日志09
    Could not resolve all artifacts for configuration ':classpath'.
    本周总结
    AutoCompleteTextView自动补全(开发日志08)
    实现地图的建议搜索并显示 SuggestionSearch
    SuggestionSearch(开发日志07)
    android studio 查看函数的解释及说明
    初步确定页面(开发日志06)
  • 原文地址:https://www.cnblogs.com/wskgjmhh/p/4610369.html
Copyright © 2020-2023  润新知