本文章源码地址: https://github.com/zhonggaorong/QQLoginDemo

项目搭建参考:  (包含QQ登录源码下载 、 QQ sdk集成)

http://blog.csdn.net/zhonggaorong/article/details/51699623

分享第三方分享之QQ分享各种坑的总结:

1. 分享老是提示未注册QQ,解决办法就是在程序已启动,就向QQ进行授权。代码如下

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  2. [[TencentOAuth alloc] initWithAppId:TENCENT_CONNECT_APP_KEY andDelegate:self];
  3. return YES;
  4. }

QQ未注册错误代号 EQQAPIAPPNOTREGISTED

2. 分享的时候, 不跳转到QQ界面,解决办法就是在openurl中,添加如下代码:

  1. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation{
  2. /**
  3. 处理由手Q唤起的跳转请求
  4. \param url 待处理的url跳转请求
  5. \param delegate 第三方应用用于处理来至QQ请求及响应的委托对象
  6. \return 跳转请求处理结果,YES表示成功处理,NO表示不支持的请求协议或处理失败
  7. */
  8. if ([url.absoluteString hasPrefix:[NSString stringWithFormat:@"tencent%@",TENCENT_CONNECT_APP_KEY]]) {
  9. [QQApiInterface handleOpenURL:url delegate:self];
  10. return [TencentOAuth HandleOpenURL:url];
  11. }
  12. return YES;
  13. }

3. iOS9白名单的问题,没有吧QQ的相关白名单填完成。 完成的如下。

  1. <key>LSApplicationQueriesSchemes</key>
  2. <array>
  3. <string>mqqapi</string>
  4. <string>mqq</string>
  5. <string>mqqOpensdkSSoLogin</string>
  6. <string>mqqconnect</string>
  7. <string>mqqopensdkdataline</string>
  8. <string>mqqopensdkgrouptribeshare</string>
  9. <string>mqqopensdkfriend</string>
  10. <string>mqqopensdkapi</string>
  11. <string>mqqopensdkapiV2</string>
  12. <string>mqqopensdkapiV3</string>
  13. <string>mqzoneopensdk</string>
  14. <string>wtloginmqq</string>
  15. <string>wtloginmqq2</string>
  16. <string>mqqwpa</string>
  17. <string>mqzone</string>
  18. <string>mqzonev2</string>
  19. <string>mqzoneshare</string>
  20. <string>wtloginqzone</string>
  21. <string>mqzonewx</string>
  22. <string>mqzoneopensdkapiV2</string>
  23. <string>mqzoneopensdkapi19</string>
  24. <string>mqzoneopensdkapi</string>
  25. <string>mqzoneopensdk</string>
  26. </array>

进入正题:

分享的对象包含:

QQApiTextObject     文本对象

QQApiURLObject      URL对象类型

QQApiExtendObject   扩展数据类型

QQApiImageObject    图片对象

QQApiImageArrayForQZoneObject  图片数组对象 用于分享图片到空间,走写说说路径,是一个指定为图片类型的,当图片数组为空时,默认走文本写说说

QQApiVideoForQZoneObject      视频对象

QQApiWebImageObject           网络图片对象

QQApiFileObject               本地文件对象

QQApiAudioObject              音频URL对象

QQApiVideoObject        视频URL对象 :用于分享目标内容为视频的URL的对象

QQApiNewsObject       新闻URL对象

等等。

相关的分享对象的权限看下图:

分享的核心代码为: (分享 新闻URL对象为例子)

  1. /**
  2. 分享 新闻URL对象 。
  3. 获取一个autorelease的<code>QQApiAudioObject</code>
  4. @param url 音频内容的目标URL
  5. @param title 分享内容的标题
  6. @param description 分享内容的描述
  7. @param previewURL 分享内容的预览图像URL
  8. @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE
  9. */
  10. NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
  11. NSURL *preimageUrl = [NSURL URLWithString:@"http://www.sizzee.com/index.php/catalog/product/view/id/55730/s/10196171/?SID=au0lhpg54f11nenmrjvhsh0rq6?uk=Y3VzdG9tZXJfaWQ9Mjc0fHByb2R1Y3RfaWQ9NTU3MzA"];
  12. QQApiNewsObject* img = [QQApiNewsObject objectWithURL:url title:@"测试分享" description:[NSString stringWithFormat:@"分享内容------新闻URL对象分享 ------test"] previewImageURL:preimageUrl];
  13. //请求帮助类,分享的所有基础对象,都要封装成这种请求对象。
  14. SendMessageToQQReq* req = [SendMessageToQQReq reqWithContent:img];
  15. QQApiSendResultCode sent = [QQApiInterface sendReq:req];
  16. //通过自定义的qqdelegate来通知本controller,是否成功分享
  17. appdelegate.qqDelegate = self;
  18. NSLog(@"QQApiSendResultCode %d",sent);
  19. [self handleSendResult:sent];
  20. /*  QQApiSendResultCode 说明
  21. EQQAPISENDSUCESS = 0,                      操作成功
  22. EQQAPIQQNOTINSTALLED = 1,                   没有安装QQ
  23. EQQAPIQQNOTSUPPORTAPI = 2,
  24. EQQAPIMESSAGETYPEINVALID = 3,              参数错误
  25. EQQAPIMESSAGECONTENTNULL = 4,
  26. EQQAPIMESSAGECONTENTINVALID = 5,
  27. EQQAPIAPPNOTREGISTED = 6,                   应用未注册
  28. EQQAPIAPPSHAREASYNC = 7,
  29. EQQAPIQQNOTSUPPORTAPI_WITH_ERRORSHOW = 8,
  30. EQQAPISENDFAILD = -1,                       发送失败
  31. //qzone分享不支持text类型分享
  32. EQQAPIQZONENOTSUPPORTTEXT = 10000,
  33. //qzone分享不支持image类型分享
  34. EQQAPIQZONENOTSUPPORTIMAGE = 10001,
  35. //当前QQ版本太低,需要更新至新版本才可以支持
  36. EQQAPIVERSIONNEEDUPDATE = 10002,
  37. */
  38. }
  39. - (void)handleSendResult:(QQApiSendResultCode)sendResult
  40. {
  41. switch (sendResult)
  42. {
  43. case EQQAPIAPPNOTREGISTED:
  44. {
  45. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"App未注册" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  46. [msgbox show];
  47. break;
  48. }
  49. case EQQAPIMESSAGECONTENTINVALID:
  50. case EQQAPIMESSAGECONTENTNULL:
  51. case EQQAPIMESSAGETYPEINVALID:
  52. {
  53. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送参数错误" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  54. [msgbox show];
  55. break;
  56. }
  57. case EQQAPIQQNOTINSTALLED:
  58. {
  59. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"未安装手Q" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  60. [msgbox show];
  61. break;
  62. }
  63. case EQQAPIQQNOTSUPPORTAPI:
  64. {
  65. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"API接口不支持" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  66. [msgbox show];
  67. break;
  68. }
  69. case EQQAPISENDFAILD:
  70. {
  71. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送失败" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  72. [msgbox show];
  73. break;
  74. }
  75. case EQQAPIVERSIONNEEDUPDATE:
  76. {
  77. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"当前QQ版本太低,需要更新" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  78. [msgbox show];
  79. break;
  80. }
  81. default:
  82. {
  83. break;
  84. }
  85. }
  86. }

上面提到了分享。那么如何来监听分享是否成功呢。这就要回到我们的appdelegate里面。监听

  1. - (void)onResp:(QQBaseResp *)resp

appdelegate中的相关代码如下:

  1. **
  2. 处理来至QQ的响应
  3. */
  4. - (void)onResp:(QQBaseResp *)resp{
  5. NSLog(@" ----resp %@",resp);
  6. // SendMessageToQQResp应答帮助类
  7. if ([resp.class isSubclassOfClass: [SendMessageToQQResp class]]) {  //QQ分享回应
  8. if (_qqDelegate) {
  9. if ([_qqDelegate respondsToSelector:@selector(shareSuccssWithQQCode:)]) {
  10. SendMessageToQQResp *msg = (SendMessageToQQResp *)resp;
  11. NSLog(@"code %@  errorDescription %@  infoType %@",resp.result,resp.errorDescription,resp.extendInfo);
  12. [_qqDelegate shareSuccssWithQQCode:[msg.result integerValue]];
  13. }
  14. }
  15. }
  16. }

完整的代码如下

appdelegate.h

  1. //
  2. //  AppDelegate.h
  3. //  QQLoginDemo
  4. //
  5. //  Created by 张国荣 on 16/6/17.
  6. //  Copyright © 2016年 BateOrganization. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @protocol QQShareDelegate <NSObject>
  10. -(void)shareSuccssWithQQCode:(NSInteger)code;
  11. @end
  12. @interface AppDelegate : UIResponder <UIApplicationDelegate>
  13. @property (strong, nonatomic) UIWindow *window;
  14. @property (weak  , nonatomic) id<QQShareDelegate> qqDelegate;
  15. @end

appdelegate,m

  1. //
  2. //  AppDelegate.m
  3. //  QQLoginDemo
  4. //
  5. //  Created by 张国荣 on 16/6/17.
  6. //  Copyright © 2016年 BateOrganization. All rights reserved.
  7. //
  8. #import "AppDelegate.h"
  9. #import <TencentOpenAPI/QQApiInterface.h>
  10. #import <TencentOpenAPI/TencentOAuth.h>
  11. #define TENCENT_CONNECT_APP_KEY @"app id"
  12. @interface AppDelegate ()<QQApiInterfaceDelegate,TencentSessionDelegate>
  13. @end
  14. @implementation AppDelegate
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  16. // Override point for customization after application launch.
  17. //    [QQApiInterface ]
  18. [[TencentOAuth alloc] initWithAppId:TENCENT_CONNECT_APP_KEY andDelegate:self];
  19. //    NSLog(@"%@",oauth.appId);
  20. return YES;
  21. }
  22. - (void)applicationWillResignActive:(UIApplication *)application {
  23. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  24. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  25. }
  26. -(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{
  27. /**
  28. 处理由手Q唤起的跳转请求
  29. \param url 待处理的url跳转请求
  30. \param delegate 第三方应用用于处理来至QQ请求及响应的委托对象
  31. \return 跳转请求处理结果,YES表示成功处理,NO表示不支持的请求协议或处理失败
  32. */
  33. if ([url.absoluteString hasPrefix:[NSString stringWithFormat:@"tencent%@",TENCENT_CONNECT_APP_KEY]]) {
  34. [QQApiInterface handleOpenURL:url delegate:self];
  35. return [TencentOAuth HandleOpenURL:url];
  36. }
  37. return YES;
  38. }
  39. - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
  40. /**
  41. 处理由手Q唤起的跳转请求
  42. \param url 待处理的url跳转请求
  43. \param delegate 第三方应用用于处理来至QQ请求及响应的委托对象
  44. \return 跳转请求处理结果,YES表示成功处理,NO表示不支持的请求协议或处理失败
  45. */
  46. if ([url.absoluteString hasPrefix:[NSString stringWithFormat:@"tencent%@",TENCENT_CONNECT_APP_KEY]]) {
  47. [QQApiInterface handleOpenURL:url delegate:self];
  48. return [TencentOAuth HandleOpenURL:url];
  49. }
  50. return YES;
  51. }
  52. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation{
  53. /**
  54. 处理由手Q唤起的跳转请求
  55. \param url 待处理的url跳转请求
  56. \param delegate 第三方应用用于处理来至QQ请求及响应的委托对象
  57. \return 跳转请求处理结果,YES表示成功处理,NO表示不支持的请求协议或处理失败
  58. */
  59. if ([url.absoluteString hasPrefix:[NSString stringWithFormat:@"tencent%@",TENCENT_CONNECT_APP_KEY]]) {
  60. [QQApiInterface handleOpenURL:url delegate:self];
  61. return [TencentOAuth HandleOpenURL:url];
  62. }
  63. return YES;
  64. }
  65. /**
  66. 处理来至QQ的请求
  67. */
  68. - (void)onReq:(QQBaseReq *)req{
  69. NSLog(@" ----req %@",req);
  70. }
  71. /**
  72. 处理来至QQ的响应
  73. */
  74. - (void)onResp:(QQBaseResp *)resp{
  75. NSLog(@" ----resp %@",resp);
  76. // SendMessageToQQResp应答帮助类
  77. if ([resp.class isSubclassOfClass: [SendMessageToQQResp class]]) {  //QQ分享回应
  78. if (_qqDelegate) {
  79. if ([_qqDelegate respondsToSelector:@selector(shareSuccssWithQQCode:)]) {
  80. SendMessageToQQResp *msg = (SendMessageToQQResp *)resp;
  81. NSLog(@"code %@  errorDescription %@  infoType %@",resp.result,resp.errorDescription,resp.extendInfo);
  82. [_qqDelegate shareSuccssWithQQCode:[msg.result integerValue]];
  83. }
  84. }
  85. }
  86. }
  87. /**
  88. 处理QQ在线状态的回调
  89. */
  90. - (void)isOnlineResponse:(NSDictionary *)response{
  91. }
  92. @end

viewcontroller.h

  1. #import <UIKit/UIKit.h>
  2. @interface ViewController : UIViewController
  3. @end

viewcontroller.m

  1. #import "ViewController.h"
  2. #import <TencentOpenAPI/TencentOAuth.h>
  3. #import <TencentOpenAPI/TencentApiInterface.h>
  4. #import <TencentOpenAPI/QQApiInterfaceObject.h>
  5. #import <TencentOpenAPI/QQApiInterface.h>
  6. #import "AppDelegate.h"
  7. #define APP_ID @"app id"
  8. @interface ViewController ()<TencentSessionDelegate,QQShareDelegate>
  9. {
  10. TencentOAuth *_tencentOAuth;
  11. NSMutableArray *_permissionArray;   //权限列表
  12. AppDelegate *appdelegate;
  13. }
  14. @end
  15. @implementation ViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  19. self.view.backgroundColor = [UIColor whiteColor];
  20. }
  21. #pragma mark QQ登录
  22. - (IBAction)loginAction:(id)sender {
  23. _tencentOAuth=[[TencentOAuth alloc]initWithAppId:APP_ID andDelegate:self];
  24. //设置权限数据 , 具体的权限名,在sdkdef.h 文件中查看。
  25. _permissionArray = [NSMutableArray arrayWithObjects: kOPEN_PERMISSION_GET_SIMPLE_USER_INFO,nil];
  26. //登录操作
  27. [_tencentOAuth authorize:_permissionArray inSafari:NO];
  28. }
  29. /**
  30. * 登录成功后的回调
  31. */
  32. - (void)tencentDidLogin{
  33. /** Access Token凭证,用于后续访问各开放接口 */
  34. if (_tencentOAuth.accessToken) {
  35. //获取用户信息。 调用这个方法后,qq的sdk会自动调用
  36. //- (void)getUserInfoResponse:(APIResponse*) response
  37. //这个方法就是 用户信息的回调方法。
  38. [_tencentOAuth getUserInfo];
  39. }else{
  40. NSLog(@"accessToken 没有获取成功");
  41. }
  42. }
  43. /**
  44. * 登录失败后的回调
  45. * \param cancelled 代表用户是否主动退出登录
  46. */
  47. - (void)tencentDidNotLogin:(BOOL)cancelled{
  48. if (cancelled) {
  49. NSLog(@" 用户点击取消按键,主动退出登录");
  50. }else{
  51. NSLog(@"其他原因, 导致登录失败");
  52. }
  53. }
  54. /**
  55. * 登录时网络有问题的回调
  56. */
  57. - (void)tencentDidNotNetWork{
  58. NSLog(@"没有网络了, 怎么登录成功呢");
  59. }
  60. /**
  61. * 因用户未授予相应权限而需要执行增量授权。在用户调用某个api接口时,如果服务器返回操作未被授权,则触发该回调协议接口,由第三方决定是否跳转到增量授权页面,让用户重新授权。
  62. * \param tencentOAuth 登录授权对象。
  63. * \param permissions 需增量授权的权限列表。
  64. * \return 是否仍然回调返回原始的api请求结果。
  65. * \note 不实现该协议接口则默认为不开启增量授权流程。若需要增量授权请调用\ref TencentOAuth#incrAuthWithPermissions: \n注意:增量授权时用户可能会修改登录的帐号
  66. */
  67. - (BOOL)tencentNeedPerformIncrAuth:(TencentOAuth *)tencentOAuth withPermissions:(NSArray *)permissions{
  68. // incrAuthWithPermissions是增量授权时需要调用的登录接口
  69. // permissions是需要增量授权的权限列表
  70. [tencentOAuth incrAuthWithPermissions:permissions];
  71. return NO; // 返回NO表明不需要再回传未授权API接口的原始请求结果;
  72. // 否则可以返回YES
  73. }
  74. /**
  75. * [该逻辑未实现]因token失效而需要执行重新登录授权。在用户调用某个api接口时,如果服务器返回token失效,则触发该回调协议接口,由第三方决定是否跳转到登录授权页面,让用户重新授权。
  76. * \param tencentOAuth 登录授权对象。
  77. * \return 是否仍然回调返回原始的api请求结果。
  78. * \note 不实现该协议接口则默认为不开启重新登录授权流程。若需要重新登录授权请调用\ref TencentOAuth#reauthorizeWithPermissions: \n注意:重新登录授权时用户可能会修改登录的帐号
  79. */
  80. - (BOOL)tencentNeedPerformReAuth:(TencentOAuth *)tencentOAuth{
  81. return YES;
  82. }
  83. /**
  84. * 用户通过增量授权流程重新授权登录,token及有效期限等信息已被更新。
  85. * \param tencentOAuth token及有效期限等信息更新后的授权实例对象
  86. * \note 第三方应用需更新已保存的token及有效期限等信息。
  87. */
  88. - (void)tencentDidUpdate:(TencentOAuth *)tencentOAuth{
  89. NSLog(@"增量授权完成");
  90. if (tencentOAuth.accessToken
  91. && 0 != [tencentOAuth.accessToken length])
  92. { // 在这里第三方应用需要更新自己维护的token及有效期限等信息
  93. // **务必在这里检查用户的openid是否有变更,变更需重新拉取用户的资料等信息** _labelAccessToken.text = tencentOAuth.accessToken;
  94. }
  95. else
  96. {
  97. NSLog(@"增量授权不成功,没有获取accesstoken");
  98. }
  99. }
  100. /**
  101. * 用户增量授权过程中因取消或网络问题导致授权失败
  102. * \param reason 授权失败原因,具体失败原因参见sdkdef.h文件中\ref UpdateFailType
  103. */
  104. - (void)tencentFailedUpdate:(UpdateFailType)reason{
  105. switch (reason)
  106. {
  107. case kUpdateFailNetwork:
  108. {
  109. //            _labelTitle.text=@"增量授权失败,无网络连接,请设置网络";
  110. NSLog(@"增量授权失败,无网络连接,请设置网络");
  111. break;
  112. }
  113. case kUpdateFailUserCancel:
  114. {
  115. //            _labelTitle.text=@"增量授权失败,用户取消授权";
  116. NSLog(@"增量授权失败,用户取消授权");
  117. break;
  118. }
  119. case kUpdateFailUnknown:
  120. default:
  121. {
  122. NSLog(@"增量授权失败,未知错误");
  123. break;
  124. }
  125. }
  126. }
  127. #pragma mark 登录成功后,回调 - 返回对应QQ的相关信息
  128. /**
  129. * 获取用户个人信息回调
  130. * \param response API返回结果,具体定义参见sdkdef.h文件中\ref APIResponse
  131. * \remarks 正确返回示例: \snippet example/getUserInfoResponse.exp success
  132. *          错误返回示例: \snippet example/getUserInfoResponse.exp fail
  133. */
  134. - (void)getUserInfoResponse:(APIResponse*) response{
  135. //这里 与自己服务器进行对接,看怎么利用这获取到的个人信息。
  136. NSDictionary *dic = response.jsonResponse;
  137. NSLog(@" response %@",dic);
  138. }
  139. #pragma mark QQ分享
  140. - (IBAction)QQshareAction:(id)sender {
  141. /**
  142. 分享 新闻URL对象 。
  143. 获取一个autorelease的<code>QQApiAudioObject</code>
  144. @param url 音频内容的目标URL
  145. @param title 分享内容的标题
  146. @param description 分享内容的描述
  147. @param previewURL 分享内容的预览图像URL
  148. @note 如果url为空,调用<code>QQApi#sendMessage:</code>时将返回FALSE
  149. */
  150. NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
  151. NSURL *preimageUrl = [NSURL URLWithString:@"http://www.sizzee.com/index.php/catalog/product/view/id/55730/s/10196171/?SID=au0lhpg54f11nenmrjvhsh0rq6?uk=Y3VzdG9tZXJfaWQ9Mjc0fHByb2R1Y3RfaWQ9NTU3MzA"];
  152. QQApiNewsObject* img = [QQApiNewsObject objectWithURL:url title:@"测试分享" description:[NSString stringWithFormat:@"分享内容------新闻URL对象分享 ------test"] previewImageURL:preimageUrl];
  153. //请求帮助类,分享的所有基础对象,都要封装成这种请求对象。
  154. SendMessageToQQReq* req = [SendMessageToQQReq reqWithContent:img];
  155. QQApiSendResultCode sent = [QQApiInterface sendReq:req];
  156. //通过自定义的qqdelegate来通知本controller,是否成功分享
  157. appdelegate.qqDelegate = self;
  158. NSLog(@"QQApiSendResultCode %d",sent);
  159. [self handleSendResult:sent];
  160. /*  QQApiSendResultCode 说明
  161. EQQAPISENDSUCESS = 0,                      操作成功
  162. EQQAPIQQNOTINSTALLED = 1,                   没有安装QQ
  163. EQQAPIQQNOTSUPPORTAPI = 2,
  164. EQQAPIMESSAGETYPEINVALID = 3,              参数错误
  165. EQQAPIMESSAGECONTENTNULL = 4,
  166. EQQAPIMESSAGECONTENTINVALID = 5,
  167. EQQAPIAPPNOTREGISTED = 6,                   应用未注册
  168. EQQAPIAPPSHAREASYNC = 7,
  169. EQQAPIQQNOTSUPPORTAPI_WITH_ERRORSHOW = 8,
  170. EQQAPISENDFAILD = -1,                       发送失败
  171. //qzone分享不支持text类型分享
  172. EQQAPIQZONENOTSUPPORTTEXT = 10000,
  173. //qzone分享不支持image类型分享
  174. EQQAPIQZONENOTSUPPORTIMAGE = 10001,
  175. //当前QQ版本太低,需要更新至新版本才可以支持
  176. EQQAPIVERSIONNEEDUPDATE = 10002,
  177. */
  178. }
  179. - (void)handleSendResult:(QQApiSendResultCode)sendResult
  180. {
  181. switch (sendResult)
  182. {
  183. case EQQAPIAPPNOTREGISTED:
  184. {
  185. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"App未注册" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  186. [msgbox show];
  187. break;
  188. }
  189. case EQQAPIMESSAGECONTENTINVALID:
  190. case EQQAPIMESSAGECONTENTNULL:
  191. case EQQAPIMESSAGETYPEINVALID:
  192. {
  193. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送参数错误" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  194. [msgbox show];
  195. break;
  196. }
  197. case EQQAPIQQNOTINSTALLED:
  198. {
  199. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"未安装手Q" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  200. [msgbox show];
  201. break;
  202. }
  203. case EQQAPIQQNOTSUPPORTAPI:
  204. {
  205. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"API接口不支持" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  206. [msgbox show];
  207. break;
  208. }
  209. case EQQAPISENDFAILD:
  210. {
  211. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送失败" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  212. [msgbox show];
  213. break;
  214. }
  215. case EQQAPIVERSIONNEEDUPDATE:
  216. {
  217. UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"当前QQ版本太低,需要更新" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
  218. [msgbox show];
  219. break;
  220. }
  221. default:
  222. {
  223. break;
  224. }
  225. }
  226. }
  227. #pragma mark QQ分享回调代理
  228. /* 返回码 对照说明
  229. 0   成功
  230. -1  参数错误
  231. -2  该群不在自己的群列表里面
  232. -3  上传图片失败
  233. -4  用户放弃当前操作
  234. -5  客户端内部处理错误
  235. */
  236. -(void)shareSuccssWithQQCode:(NSInteger)code{
  237. NSLog(@"code %ld",(long)code);
  238. if (code == 0) {
  239. UIAlertView *aler = [[UIAlertView alloc]initWithTitle:@"警告" message:@"分享成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil nil];
  240. [aler show];
  241. }else{
  242. UIAlertView *aler = [[UIAlertView alloc]initWithTitle:@"警告" message:@"分享失败" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil nil];
  243. [aler show];
  244. }
  245. }
  246. - (void)didReceiveMemoryWarning {
  247. [super didReceiveMemoryWarning];
  248. // Dispose of any resources that can be recreated.
  249. }
  250. @end

大功告成。

iOS开发之第三方分享QQ分享,史上最新最全第三方分享QQ方式实现的更多相关文章

  1. 【腾讯Bugly干货分享】OCS——史上最疯狂的iOS动态化方案

    本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:https://mp.weixin.qq.com/s/zctwM2Wf8c6_sxT_0yZvXg 导语 在 ...

  2. iOS常用第三方库大全,史上最全第三方库收集

    下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UITableVie ...

  3. iOS开发——网络篇——NSURLSession,下载、上传代理方法,利用NSURLSession断点下载,AFN基本使用,网络检测,NSURLConnection补充

    一.NSURLConnection补充 前面提到的NSURLConnection有些知识点需要补充 NSURLConnectionDataDelegate的代理方法有一下几个 - (void)conn ...

  4. 【IOS开发笔记01】学生管理系统(上)

    端到端的机会 虽然现在身处大公司,但是因为是内部创业团队,产品.native.前端.服务器端全部坐在一起开发,大家很容易做零距离交流,也因为最近内部有一个前端要转岗过来,于是手里的前端任务好像可以抛一 ...

  5. XMPPFrameWork IOS 开发(四)消息和好友上下线

    原始地址:XMPPFrameWork IOS 开发(四) 消息 //收到消息 - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XM ...

  6. IOS开发之实现App消息推送(最新)

    好久没有写过博客啦,今天就由本菜鸟给大家做一个简单的IOSApp消息推送教程吧!一切从0开始,包括XCode6, IOS8, 以及苹果开发者中心最新如何注册应用,申请证书以及下载配置概要文件,相信很多 ...

  7. 从零开始学ios开发(十七):Storyboards(上)

    在开始这章之前,先做个说明,从这篇开始,我所使用的xcode更新成了最新的版本,版本是4.6.1(4H512),如下: 大家可以打开自己电脑上的App Store,然后搜索xcode,第一个出现的就是 ...

  8. ios开发之网络数据的下载与上传

    要实现网络数据的下载与上传,主要有三种方式 > NSURLConnection  针对少量数据,使用“GET”或“POST”方法从服务器获取数据,使用“POST”方法向服务器传输数据; > ...

  9. iOS开发进阶 - 使用shell脚本自动打包上传到fir.im上-b

    用fir.im测试已经好长时间了,感觉每次打包上传都很麻烦,想着是不是可以用脚本自动打包,在网上搜了一下确实有,下面总结一下如何使用脚本自动打包上传到fir.im,以及打包过程中遇到的问题和解决办法 ...

随机推荐

  1. JQ插件开发方法

    由于项目原因,不得不写个JQ侧滑插件来满足需求.. 先引用两篇博文,待测试了 再写怎么做.. http://blog.csdn.net/business122/article/details/8278 ...

  2. poj 2689 大范围内素数筛选

    /** 给定一定范围求其内的素数 注意: **/ #include <iostream> #include <math.h> #include <cstring> ...

  3. Java和Android开发IDE---IntelliJ IDEA使用技巧(转)

    以前一直使用的是Eclipse,听别人介绍说IDEA非常不错,也为了以后转Android studio铺垫下.就开始尝试用idea来开发. 这篇文章主要学习了idea的使用技巧. IDEA 全称 In ...

  4. 解决android加载图片时内存溢出问题

    尽量不要使用setImageBitmap或setImageResource或BitmapFactory.decodeResource来设置一张大图,因为这些函数在完成decode后,最终都是通过jav ...

  5. getline函数

    在我的印象中,getline函数常常出如今自己的视野里,模糊地记得它常常常使用来读取字符串 .可是又对它的參数不是非常了解,今天又用到了getline函数,如今来细细地总结一下: 首先要明确设计get ...

  6. Cocos2d-x3.0游戏实例之《别救我》第四篇——乱入的主角

    好了,前面说了那么多废话,最终要进入正题了(等等,敢情前面你都是在耍我们么?) 笨木头花心贡献,啥?花心?不呢,是用心~ 转载请注明,原文地址: http://www.benmutou.com/blo ...

  7. jQuery 插件 flexslider 初步使用

    发现了个不错的 jQuery 幻灯片插件 flexslider,有 接近 3000 Star,应该说是很靠谱的,下面是简单使用教程. 引入代码 所有代码都可以在 flexlslider 的 Githu ...

  8. java web分享ppt大纲 -- servlet包

     概述 servlet相关代码所在包: javax.servlet javax.servlet.http 常用的功能模块 Servlet,filter,listener 常用的相关类: servlet ...

  9. iOS面试题04-runtime

    runtime/KVO等面试题 1.KVO内部实现原则 回答:1>KVO是基于runtime机制实现的 2>当某个类的对象第一次被观察时,系统就会在运行期动态地创建该类的一个派生类,在这个 ...

  10. 支持iOS9 Universal links遇到的问题

    记录为iOS9上的APP支持Universal links遇到的一些问题. 在Web服务器上传apple-app-site-association文件 必须支持HTTPS获取配置文件 文件名后不加.j ...