iOS 第三方登錄褐墅、分享拆檬、支付管理工具類

· 轉(zhuǎn)載請標(biāo)明出處:http://www.reibang.com/p/5ea1a0d9ee8a

1、登錄:微信妥凳、QQ竟贯、Sina,分享:微信逝钥、QQ屑那、Sina,支付:微信支付晌缘,支付寶支付齐莲;
2、集成一起的初衷是源于分享一直是原生寫的磷箕,登錄用友盟之類的选酗,回調(diào)這塊覺得麻煩,就統(tǒng)一集成了岳枷,統(tǒng)一回調(diào) URL:


appDelegate.m

3芒填、代碼結(jié)構(gòu)介紹:


4、開始項(xiàng)目
4.1空繁、第一步導(dǎo)入第三方 SDK 到項(xiàng)目殿衰,然后配置 info.plist,和 URL Schemes;QQ 和Wechat 注冊應(yīng)用一定要審核通過才有登錄能力盛泡,Sina 要設(shè)置 bundleID(bundleid 和項(xiàng)目不一樣登錄會(huì)報(bào)錯(cuò)) 和回調(diào) URL 才能正常登錄闷祥,添加私有庫;


01

cpmmand + v 到自己項(xiàng)目中

URL Schemes

1251534A-C395-41EB-95A6-2C3A96DA3388.png

4.2傲诵、QQ凯砍、WeChat、Sina 注冊應(yīng)用在 APPdelegate.m中的

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    [[YZThirdManager thirdManager] registerApp:@"微博 APPID" WithType:YZRegisterTypeSina];
    [[YZThirdManager thirdManager] registerApp:@"微信 APPID" WithType:YZRegisterTypeWechat];
    [[YZThirdManager thirdManager] registerApp:@"QQ APPID" WithType:YZRegisterTypeQQ];
    
    return YES;
}

4.3拴竹、YZThirdManager ?這個(gè)工具類主要做的就是分享悟衩、登錄、支付集成在一起栓拜,統(tǒng)一回到 URL座泳,代碼如下:

/********************
第三方管理工具類:
1惠昔、微信分享、登錄挑势、支付
2镇防、微博分享、登錄
3薛耻、QQ分享营罢、登錄
4、支付寶支付饼齿。
********************/
#import <Foundation/Foundation.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import "WXApi.h"
#import "WeiboSDK.h"
#import <AlipaySDK/AlipaySDK.h>

/** 分享后的跳轉(zhuǎn)鏈接 */
extern NSString * const Share_URL;
/** 分享標(biāo)題 */
extern NSString * const Share_title;
/** 分享內(nèi)容 */
extern NSString * const Share_desc;
/** 分享顯示的圖片 */
extern NSString * const Share_imageData;

/**
 分享類型
 */
typedef NS_ENUM(NSInteger, YZShareType) {
    YZShareTypeWechatSession,   // 分享到微信好友
    YZShareTypeWechatTimeLine,  // 分享到微信朋友圈
    YZShareTypeQQ,              // 分享到QQ
    YZShareTypeSina             // 分享到sina微博
};

/**
 注冊類型
 */
typedef NS_ENUM(NSInteger, YZRegisterType) {
    YZRegisterTypeWechat,       // 微信
    YZRegisterTypeQQ,           // QQ
    YZRegisterTypeSina          // sina微博
};

/**
 登錄類型
 */
typedef NS_ENUM(NSInteger, YZOAuthType) {
    YZOAuthTypeWechat,       // 微信
    YZOAuthTypeQQ,           // QQ
    YZOAuthTypeSina          // sina微博
};

/**
 協(xié)議
 */
@protocol YZThirdManagerDelegate <NSObject>

@optional

#pragma mark 第三方登錄回調(diào)
/**
 WeChat 登錄成功

 @param userDict WeChat 用戶信息
 */
- (void)wechat_loginSuccess:(NSDictionary *)userDict;

/**
 Sina 登錄成功

 @param userDict Sina 用戶信息
 */
- (void)sina_loginSuccess:(NSDictionary *)userDict;

/**
 QQ 登錄成功

 @param userDict  QQ 用戶信息
 */
- (void)tencent_loginSuccess:(NSDictionary *)userDict;

#pragma mark 第三方分享回調(diào)

/**
 微信分享后收到微信的響應(yīng)
 分享是否成功 需要判斷 errCode 屬性 WXErrCode
 
 @param response 響應(yīng)消息
 */
- (void)wechat_shareDidReceiveResponse:(BaseResp *)response;
/**
 QQ分享后收到QQ的響應(yīng)
 分享是否成功 需要判斷 result 屬性, QQApiSendResultCode
 
 @param response 響應(yīng)消息
 */
- (void)tencent_shareDidReceiveResponse:(SendMessageToQQResp *)response;
/**
 微博分享后收到微博的響應(yīng)
 分享是否成功 需要判斷 statusCode 碼 WeiboSDKResponseStatusCode
 
 @param response 響應(yīng)消息
 */
- (void)sina_shareDidReceiveResponse:(WBBaseResponse *)response;

#pragma mark 支付回調(diào)

/**
 微信支付后收到微信的響應(yīng),支付是否成功需要判斷 errCode 屬性 WXErrCode
 
 @param response 響應(yīng)消息
 */
- (void)wechat_PayDidReceiveResponse:(PayResp *)response;

/**
 支付寶支付收到支付寶的響應(yīng)蝙搔,支付是否成功需要判斷 resultDic的key resultStatus = 9000 成功
 
 @param resultDic 結(jié)果信息
 */
- (void)aliPay_DidReceiveResponse:(NSDictionary *)resultDic;

@end

@interface YZThirdManager : NSObject <WXApiDelegate,WeiboSDKDelegate,TencentSessionDelegate, QQApiInterfaceDelegate>

@property (nonatomic, weak) id<YZThirdManagerDelegate> third_delegate;

+ (instancetype)thirdManager;

/**
 注冊應(yīng)用
 
 @param appid 微信和QQ請傳入appid,微博傳入appkey
 @param type  分享類型
 */
- (void)registerApp:(NSString *)appid WithType:(YZRegisterType)type;

/**
 分享到第三方,示例:@{Share_URL:@"http://www.baidu.com",Share_title:@"測試分享",Share_imageData:UIImageJPEGRepresentation(img,1),Share_desc:@"文本內(nèi)容"};

 @param dict 分享的內(nèi)容
 @param type 分享的類型
 */
- (void)shareWithDictionary:(NSDictionary *)dict shareType:(YZShareType)type;

/**
 第三方登錄

 @param type 登錄的類型
 */
- (void)thirdLoginWithOAuthType:(YZOAuthType)type;

/**
 第三方 URL 回調(diào)
 */
- (void)handleOpenURL:(NSURL *)url;

/**
 微信支付缕溉,order 的 key 是按照 PayReq 的屬性設(shè)置

 @param order 訂單信息
 */
- (void)thirdPayWechat:(NSDictionary *)order;

/**
 支付寶支付

 @param sign 簽名字符串
 */
- (void)thirdAliPaySign:(NSString *)sign;

@end

//
//  YZThirdManager.m
//  ECGoudeli
//
//  Created by Leaf on 2017/8/10.
//  Copyright ? 2017年 Leaf. All rights reserved.
//

/** 下面信息是需要去對應(yīng)第三方開發(fā)平臺(tái)注冊應(yīng)用獲得 */
#define WX_APP_ID           @"微信 APP_ID"
#define WX_APP_AppSecret    @"微信 AppSecret"

#define QQ_APP_ID           @"QQ APP_ID"
#define QQ_APP_KEY          @"QQ APP_KEY"

#define WB_APP_KEY          @"微博 APP_KEY"
#define WB_APP_Secret       @"微博 APP_Secret"
#define WB_REDIRECT_URL     @"http://www.sina.com"


NSString * const Share_URL       = @"url";
NSString * const Share_title     = @"title";
NSString * const Share_desc      = @"desc";
NSString * const Share_imageData = @"imageData";


#import "YZThirdManager.h"

@interface YZThirdManager ()<NSURLSessionDelegate>
{
    TencentOAuth    *_tencentOAuth;
    NSMutableArray  *_permissionArray; // QQ 需要的權(quán)限
    
    NSData   *_imageData;
    NSString *_title;
    NSString *_description;
    NSString *_urlString;
}

@property (nonatomic, strong) AFHTTPSessionManager *manager;
@end

@implementation YZThirdManager

+ (instancetype)thirdManager {
    static id instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[self alloc] init];
    });
    return instance;
}

// 注冊第三方
- (void)registerApp:(NSString *)appid WithType:(YZRegisterType)type {
    switch (type) {
        case YZRegisterTypeWechat:
            [WXApi registerApp:appid];
            break;
            
        case YZRegisterTypeQQ:
            _tencentOAuth = [[TencentOAuth alloc]initWithAppId:appid andDelegate:self];
            break;
            
        case YZRegisterTypeSina:
            [WeiboSDK registerApp:appid];
            break;
    }
}

#pragma mark - Share: Wechat & Sina & QQ
- (void)shareWithDictionary:(NSDictionary *)dict shareType:(YZShareType)type {
    _title       = dict[Share_title];
    _urlString   = dict[Share_URL];
    _description = dict[Share_desc];
    _imageData   = dict[Share_imageData];
    
    if (type == YZShareTypeQQ) {
        [self shareToQQ];
        
    }else if (type == YZShareTypeWechatSession || type == YZShareTypeWechatTimeLine){
        [self shareToWeChatWithWechatType:type];
        
    }else if (type == YZShareTypeSina){
        [self shareToWeibo];
    }
}

/**
 分享到wechat
 
 @param wechatType 分享到微信的類型
 */
- (void)shareToWeChatWithWechatType:(YZShareType)wechatType{
    SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
    
    WXMediaMessage *message = [WXMediaMessage message];
    
    if (_urlString.length) {
        WXWebpageObject *web = [WXWebpageObject object];
        web.webpageUrl = _urlString;
        message.mediaObject = web;
    } else {
        WXImageObject *image = [WXImageObject object];
        image.imageData = _imageData;
        message.mediaObject = image;
        req.bText = NO;
    }
    
    message.title = _title ?: @"";
    message.description = _description?:@"";
    // 微信分享圖片大小不能超過 32K
    
    [message setThumbImage:[UIImage imageWithData:_imageData]];
    
    // 分享給好友
    if (wechatType == YZShareTypeWechatSession) {
        req.scene = WXSceneSession;
    }
    // 分享到朋友圈
    if (wechatType == YZShareTypeWechatTimeLine) {
        
        message.title = _description;
        req.scene = WXSceneTimeline;
    }
    req.message = message;
    [WXApi sendReq:req];
}

/**
 *  分享到微博
 */
-(void)shareToWeibo{
    WBMessageObject *message = [WBMessageObject message];
    WBImageObject *imageObject = [WBImageObject object];
    
    imageObject.imageData = _imageData;
    message.imageObject = imageObject;
    
    message.text = [NSString stringWithFormat:@"%@%@",_title,_urlString] ;
    
    WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest requestWithMessage:message authInfo:nil access_token:nil];
    request.userInfo = nil;
    [WeiboSDK sendRequest:request];
}

/**
 *  分享到QQ
 */
-(void)shareToQQ{
    NSURL *url = [NSURL URLWithString:_urlString];
    QQBaseReq *request = nil;
    if (_urlString.length) {
        QQApiNewsObject *news = [QQApiNewsObject objectWithURL:url title:_title description:_description previewImageData:_imageData];
        request = [SendMessageToQQReq reqWithContent:news];
    } else {
        QQApiImageObject *image = [[QQApiImageObject alloc] initWithData:_imageData previewImageData:_imageData title:_title description:_description];
        request = [SendMessageToQQReq reqWithContent:image];
    }
    
    [QQApiInterface sendReq:request];
    
}

#pragma mark - OAuth: wechat & QQ & sina

-(void)thirdLoginWithOAuthType:(YZOAuthType)type {
    
    if (type == YZOAuthTypeQQ) {
        _permissionArray = [NSMutableArray arrayWithArray:@[/** 移動(dòng)端獲取用戶信息 */
                                                            kOPEN_PERMISSION_GET_SIMPLE_USER_INFO,
                                                            ]];
        [_tencentOAuth authorize:_permissionArray inSafari:NO];
    }else if (type == YZOAuthTypeWechat) {
        SendAuthReq *req = [[SendAuthReq alloc] init];
        req.scope = @"snsapi_userinfo";
        req.state = @"App";
        [WXApi sendReq:req];
        
    }else if (type == YZOAuthTypeSina) {
        WBAuthorizeRequest *request = [WBAuthorizeRequest request];
        //回調(diào)地址與 新浪微博開放平臺(tái)中 我的應(yīng)用  --- 應(yīng)用信息 -----高級應(yīng)用    -----授權(quán)設(shè)置 ---應(yīng)用回調(diào)中的url保持一致就好了
        request.redirectURI = WB_REDIRECT_URL;
        [WeiboSDK sendRequest:request];
        
    }
}

#pragma mark - WXApiDelegate & QQApiInterfaceDelegate & WeiboSDKDelegate

/*
 1、處理來至QQ的響應(yīng)
 2吃型、處理來至微信的響應(yīng)
 */
- (void)onResp:(BaseResp *)resp {
    if ([resp isKindOfClass:[BaseResp class]]) {
        // 處理來自微信的響應(yīng)
        if ([resp isKindOfClass:[SendAuthResp class]]) {
            if (resp.errCode == WXSuccess) {
                SendAuthResp *resp2 = (SendAuthResp *)resp;
                [self getWechatOpenidAndToken:resp2.code];
                
            }else{
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"登錄失敗" message:[NSString stringWithFormat:@"%@",resp.errStr] delegate:self cancelButtonTitle:nil otherButtonTitles:@"確定", nil];
                [alert show];
            }
        }else if ([resp isKindOfClass:[SendMessageToWXResp class]]) {
            DebugLog(@"微信分享了");
            if ([self.third_delegate respondsToSelector:@selector(wechat_shareDidReceiveResponse:)]) {
                [self.third_delegate wechat_shareDidReceiveResponse:resp];
            }
            
        }else if ([resp isKindOfClass:[PayResp class]]) {
            DebugLog(@"微信支付");
            if ([self.third_delegate respondsToSelector:@selector(wechat_PayDidReceiveResponse:)]) {
                [self.third_delegate wechat_PayDidReceiveResponse:(PayResp *)resp];
            }
        }
        
    }else if ([resp isKindOfClass:[QQBaseResp class]]) {
        // 處理來自QQ的響應(yīng)
        
        if ([resp isKindOfClass:[SendMessageToQQResp class]]) {
            DebugLog(@"share:QQ分享");
            if ([self.third_delegate respondsToSelector:@selector(tencent_shareDidReceiveResponse:)]) {
                [self.third_delegate tencent_shareDidReceiveResponse:(SendMessageToQQResp *)resp];
            }
        }
    }
}

/*
 1证鸥、處理來至QQ的請求
 2、處理來至微信的請求
 */
- (void)onReq:(BaseReq *)req {
    if ([req isKindOfClass:[BaseReq class]]) {
        // 處理來自微信的請求
        
    }else if ([req isKindOfClass:[QQBaseReq class]]) {
        // 處理來自QQ的請求
        
    }
}

/**
 處理QQ在線狀態(tài)的回調(diào)
 */
- (void)isOnlineResponse:(NSDictionary *)response{
    
}

/**
 收到一個(gè)來自微博客戶端程序的請求
 */
- (void)didReceiveWeiboRequest:(WBBaseRequest *)request{
    DebugLog(@"request %@",request);
}

/**
 收到一個(gè)來自微博客戶端程序的響應(yīng)
 */
- (void)didReceiveWeiboResponse:(WBBaseResponse *)response{
    
    if ([response isKindOfClass:[WBSendMessageToWeiboResponse class]]) {
        DebugLog(@"share:微博分享");
        if ([self.third_delegate respondsToSelector:@selector(sina_shareDidReceiveResponse:)]) {
            [self.third_delegate sina_shareDidReceiveResponse:response];
        }
        
    }else if ([response isKindOfClass:[WBAuthorizeResponse class]]) {
        DebugLog(@"微博登錄");
        if (response.statusCode == WeiboSDKResponseStatusCodeSuccess) {
            NSString *uid = [(WBAuthorizeResponse *)response userID];
            NSString *token = [(WBAuthorizeResponse *)response accessToken];
            [self getSinaUserInfo:uid token:token];
            
        }else {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"登錄失敗" message:[NSString stringWithFormat:@"statusCode: %zd",response.statusCode] delegate:self cancelButtonTitle:nil otherButtonTitles:@"確定", nil];
            [alert show];
        }

    }
}

#pragma mark - TencentLoginDelegate
//委托
- (void)tencentDidLogin
{
    [_tencentOAuth getUserInfo];
}

- (void)getUserInfoResponse:(APIResponse *)response
{
    if (response.retCode == URLREQUEST_SUCCEED) {
        NSDictionary *userDict = @{@"third_id"    : [_tencentOAuth openId],
                                   @"third_name"  : [response.jsonResponse valueForKeyPath:@"nickname"],
                                   @"third_image" : [response.jsonResponse valueForKeyPath:@"figureurl_qq_2"],
                                   @"access_token": [_tencentOAuth accessToken]};
        
        if ([self.third_delegate respondsToSelector:@selector(tencent_loginSuccess:)]) {
            [self.third_delegate tencent_loginSuccess:userDict];
        }
        DebugLog(@"userDict %@",userDict);
    } else {
        DebugLog(@"登錄失敗!");
    }
}

- (void)tencentDidLogout {
    
}

/**
 * 登錄失敗后的回調(diào)
 * param cancelled 代表用戶是否主動(dòng)退出登錄
 */
- (void)tencentDidNotLogin:(BOOL)cancelled {
    
}

- (void)tencentDidNotNetWork {
    
}

#pragma mark - 獲取第三方用戶信息
// 獲取 Sina 的用戶信息
- (void)getSinaUserInfo:(NSString *)uid token:(NSString *)token {
    NSString *urlStr =[NSString stringWithFormat:@"https://api.weibo.com/2/users/show.json?uid=%@&access_token=%@&source=%@",uid,token,WB_APP_KEY];
    __weak typeof(self) weakself = self;
    [self.manager GET:urlStr parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *userDict = @{
                                   @"third_id" :   [dic valueForKeyPath:@"idstr"],
                                   @"third_name" : [dic valueForKeyPath:@"screen_name"],
                                   @"third_image": [dic valueForKeyPath:@"avatar_hd"],
                                   @"access_token":token
                                   };
        if ([weakself.third_delegate respondsToSelector:@selector(sina_loginSuccess:)]) {
            [weakself.third_delegate sina_loginSuccess:userDict];
        }
    
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        DebugLog(@"error %@",error);
    }];
}

//通過 appid  secret 認(rèn)證code . 來發(fā)送獲取 access_token的請求
- (void)getWechatOpenidAndToken:(NSString *)code {
    NSString *urlStr = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=authorization_code",WX_APP_ID,WX_APP_AppSecret,code];
    
    __weak typeof(self) weakself = self;
    [self.manager GET:urlStr parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        /*
         access_token   接口調(diào)用憑證
         expires_in     access_token接口調(diào)用憑證超時(shí)時(shí)間勤晚,單位(秒)
         refresh_token  用戶刷新access_token
         openid         授權(quán)用戶唯一標(biāo)識
         scope          用戶授權(quán)的作用域枉层,使用逗號(,)分隔
         unionid        當(dāng)且僅當(dāng)該移動(dòng)應(yīng)用已獲得該用戶的userinfo授權(quán)時(shí),才會(huì)出現(xiàn)該字段
         */
        NSString* accessToken=[dic valueForKey:@"access_token"];
        NSString* openID=[dic valueForKey:@"openid"];
        [weakself getWechatUserInfo:accessToken openid:openID];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        DebugLog(@"error %@",error.localizedFailureReason);
    }];
}

// 通過 access_token 獲取微信用戶信息
- (void)getWechatUserInfo:(NSString *)token openid:(NSString *)openid {
    NSString *urlStr = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/userinfo?access_token=%@&openid=%@",token,openid];
    __weak typeof(self) weakself = self;
    [self.manager GET:urlStr parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dic = (NSDictionary *)[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *userDict = @{
                               @"way"       :   @"1",                       // 登錄方式:微信
                               @"openid"    :   openid,                     // 用戶唯一標(biāo)識
                               @"headimgurl":   dic[@"headimgurl"],         // 頭像URL
                               @"nickname"  :   dic[@"nickname"],           // 昵稱
                               @"sex"       :   [dic[@"sex"] stringValue],  // 性別
                               @"country"   :   dic[@"country"],            // 國家
                               @"province"  :   dic[@"province"],           // 省份
                               @"city"      :   dic[@"city"],               // 城市
                               @"language"  :   dic[@"language"]            // 語言
                               };
        if ([weakself.third_delegate respondsToSelector:@selector(wechat_loginSuccess:)]) {
            [weakself.third_delegate wechat_loginSuccess:userDict];
        }
        DebugLog(@"userDict = %@",userDict);
    }failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        DebugLog(@"error %ld",(long)error.code);
    }];
}

#pragma mark - Wechat Pay & AliPay

- (void)thirdPayWechat:(NSDictionary *)order {
    
    PayReq *payOrder = [[PayReq alloc] init];
    payOrder.openID = [order objectForKey:@"openID"];
    payOrder.partnerId = [order objectForKey:@"partnerId"];
    payOrder.prepayId = [order objectForKey:@"prepayId"];
    payOrder.package = [order objectForKey:@"package"];
    payOrder.nonceStr = [order objectForKey:@"nonceStr"];
    payOrder.timeStamp = (UInt32)[[order objectForKey:@"timeStamp"] integerValue];
    payOrder.sign = [order objectForKey:@"sign"];
    
    if (![WXApi sendReq:payOrder]) {
        
        DebugLog(@"支付出錯(cuò)赐写,請稍后再試");
    }
}

- (void)thirdAliPaySign:(NSString *)sign {
    __weak typeof(self) weakself = self;
    [[AlipaySDK defaultService] payOrder:sign fromScheme:@"com.kyx.eduParents" callback:^(NSDictionary *resultDic) {
        [weakself didReceiveAliPayRequest:resultDic];
    }];
}

#pragma mark - Private

- (void)didReceiveAliPayRequest:(NSDictionary *)resultDic {
    if ([self.third_delegate respondsToSelector:@selector(aliPay_DidReceiveResponse:)]) {
        [self.third_delegate aliPay_DidReceiveResponse:resultDic];
    }
}

#pragma mark - 第三方請求結(jié)果URL回調(diào)

-(void)handleOpenURL:(NSURL *)url {
    __weak typeof(self) weakself = self;
    if ([url.scheme isEqualToString:WX_APP_ID]) {
        [WXApi handleOpenURL:url delegate:self];
        
    } else if ([url.scheme isEqualToString:[NSString stringWithFormat:@"tencent%@",QQ_APP_ID]]) {
        [QQApiInterface handleOpenURL:url delegate:self];
        [TencentOAuth HandleOpenURL:url];
        
    }else if ([url.scheme isEqualToString:[NSString stringWithFormat:@"wb%@",WB_APP_KEY]]) {
        [WeiboSDK handleOpenURL:url delegate:self];
        
    } else if ([url.host isEqualToString:@"safepay"]) {
        
        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
            // 處理支付寶支付結(jié)果
            [weakself didReceiveAliPayRequest:resultDic];
        }];
    } else if ([url.host isEqualToString:@"alipayclient"]) {
        
        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
            // 處理支付寶支付結(jié)果
            [weakself didReceiveAliPayRequest:resultDic];
        }];
    }
}

#pragma mark - 懶加載

-(AFHTTPSessionManager *)manager {
    if (_manager == nil) {
        _manager = [AFHTTPSessionManager manager];
        _manager.requestSerializer = [AFJSONRequestSerializer serializer];//請求
        _manager.responseSerializer = [AFHTTPResponseSerializer serializer];//響應(yīng)
        _manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/json", @"text/json",@"text/plain", nil];
    }
    return _manager;
}

@end

5鸟蜡、登錄成功通過代理回調(diào)返回用戶信息出來:

6、上面的 YZThirdManager 類的代碼已經(jīng)貼出來了挺邀,如果要demo揉忘,下面回復(fù)郵箱地址

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市端铛,隨后出現(xiàn)的幾起案子泣矛,更是在濱河造成了極大的恐慌,老刑警劉巖禾蚕,帶你破解...
    沈念sama閱讀 211,123評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件您朽,死亡現(xiàn)場離奇詭異,居然都是意外死亡换淆,警方通過查閱死者的電腦和手機(jī)哗总,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,031評論 2 384
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來产舞,“玉大人魂奥,你說我怎么就攤上這事∫酌ǎ” “怎么了耻煤?”我有些...
    開封第一講書人閱讀 156,723評論 0 345
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我哈蝇,道長棺妓,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,357評論 1 283
  • 正文 為了忘掉前任炮赦,我火速辦了婚禮怜跑,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘吠勘。我一直安慰自己性芬,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,412評論 5 384
  • 文/花漫 我一把揭開白布剧防。 她就那樣靜靜地躺著植锉,像睡著了一般。 火紅的嫁衣襯著肌膚如雪峭拘。 梳的紋絲不亂的頭發(fā)上俊庇,一...
    開封第一講書人閱讀 49,760評論 1 289
  • 那天,我揣著相機(jī)與錄音鸡挠,去河邊找鬼辉饱。 笑死,一個(gè)胖子當(dāng)著我的面吹牛拣展,可吹牛的內(nèi)容都是我干的彭沼。 我是一名探鬼主播,決...
    沈念sama閱讀 38,904評論 3 405
  • 文/蒼蘭香墨 我猛地睜開眼瞎惫,長吁一口氣:“原來是場噩夢啊……” “哼溜腐!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起瓜喇,我...
    開封第一講書人閱讀 37,672評論 0 266
  • 序言:老撾萬榮一對情侶失蹤挺益,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后乘寒,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體望众,經(jīng)...
    沈念sama閱讀 44,118評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,456評論 2 325
  • 正文 我和宋清朗相戀三年伞辛,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了烂翰。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,599評論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡蚤氏,死狀恐怖甘耿,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情竿滨,我是刑警寧澤佳恬,帶...
    沈念sama閱讀 34,264評論 4 328
  • 正文 年R本政府宣布捏境,位于F島的核電站,受9級特大地震影響毁葱,放射性物質(zhì)發(fā)生泄漏垫言。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,857評論 3 312
  • 文/蒙蒙 一倾剿、第九天 我趴在偏房一處隱蔽的房頂上張望筷频。 院中可真熱鬧,春花似錦前痘、人聲如沸凛捏。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,731評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽葵袭。三九已至,卻和暖如春乖菱,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背蓬网。 一陣腳步聲響...
    開封第一講書人閱讀 31,956評論 1 264
  • 我被黑心中介騙來泰國打工窒所, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人帆锋。 一個(gè)月前我還...
    沈念sama閱讀 46,286評論 2 360
  • 正文 我出身青樓吵取,卻偏偏與公主長得像,于是被迫代替她去往敵國和親锯厢。 傳聞我的和親對象是個(gè)殘疾皇子皮官,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,465評論 2 348

推薦閱讀更多精彩內(nèi)容