qq iOS环境配置及调用
2016-06-12 14:02
483 查看
1.下载官方iOS sdk:地址:相关文档
2. 将iOS SDK中的TencentOpenAPI.framework和TencentOpenApi_IOS_Bundle.bundle文件拷贝到应用开发的目录下
3. 添加SDK依赖的系统库文件。分别是”Security.framework”, “libiconv.dylib”,“SystemConfiguration.framework”,“CoreGraphics.Framework”、“libsqlite3.dylib”、“CoreTelephony.framework”、“libstdc++.dylib”、“libz.dylib”。
4. 修改必要的工程配置属性。
在工程配置中的“Build Settings”一栏中找到“Linking”配置区,给“Other Linker Flags”配置项添加属性值“-fobjc-arc”。
5.在XCode中,选择你的工程设置项,选中“TARGETS”一栏,在“info”标签栏的“URL type”添加一条新的“URL scheme”,新的scheme = tencent + appid。如果您使用的是XCode3或者更低的版本,则需要在plist文件中添加。Demo中我们注册的appid是222222。如下图
另外在Xcode 6.0创建工程时,默认可能没有单独设置Bundle display name属性值。但是因为SDK需要用到Bundle display name的值,所以务必请检查确保这个属性存在,如果没有请添加上。
6.appdelegate中添加相应的代码:
头文件#import <TencentOpenAPI/TencentOAuth.h>
7.调用:
#import <TencentOpenAPI/TencentOAuth.h>
#import <TencentOpenAPI/TencentApiInterface.h>
#import <TencentOpenAPI/TencentMessageObject.h>
#import "TencentOpenAPI/QQApiInterface.h"
#import <TencentOpenAPI/TencentOAuthObject.h>
TencentSessionDelegate
接口调用文档:文档地址
关键代码如下:
2. 将iOS SDK中的TencentOpenAPI.framework和TencentOpenApi_IOS_Bundle.bundle文件拷贝到应用开发的目录下
3. 添加SDK依赖的系统库文件。分别是”Security.framework”, “libiconv.dylib”,“SystemConfiguration.framework”,“CoreGraphics.Framework”、“libsqlite3.dylib”、“CoreTelephony.framework”、“libstdc++.dylib”、“libz.dylib”。
4. 修改必要的工程配置属性。
在工程配置中的“Build Settings”一栏中找到“Linking”配置区,给“Other Linker Flags”配置项添加属性值“-fobjc-arc”。
5.在XCode中,选择你的工程设置项,选中“TARGETS”一栏,在“info”标签栏的“URL type”添加一条新的“URL scheme”,新的scheme = tencent + appid。如果您使用的是XCode3或者更低的版本,则需要在plist文件中添加。Demo中我们注册的appid是222222。如下图
另外在Xcode 6.0创建工程时,默认可能没有单独设置Bundle display name属性值。但是因为SDK需要用到Bundle display name的值,所以务必请检查确保这个属性存在,如果没有请添加上。
6.appdelegate中添加相应的代码:
头文件#import <TencentOpenAPI/TencentOAuth.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [TencentOAuth HandleOpenURL:url]; } - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [TencentOAuth HandleOpenURL:url]; }
7.调用:
#import <TencentOpenAPI/TencentOAuth.h>
#import <TencentOpenAPI/TencentApiInterface.h>
#import <TencentOpenAPI/TencentMessageObject.h>
#import "TencentOpenAPI/QQApiInterface.h"
#import <TencentOpenAPI/TencentOAuthObject.h>
TencentSessionDelegate
接口调用文档:文档地址
关键代码如下:
- (void)handleSendResult:(QQApiSendResultCode)sendResult { switch (sendResult) { case EQQAPIAPPNOTREGISTED: { UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"App未注册" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil]; [msgbox show]; break; } case EQQAPIMESSAGECONTENTINVALID: case EQQAPIMESSAGECONTENTNULL: case EQQAPIMESSAGETYPEINVALID: { UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送参数错误" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil]; [msgbox show]; break; } case EQQAPIQQNOTINSTALLED: { UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"未安装手Q" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil]; [msgbox show]; break; } case EQQAPIQQNOTSUPPORTAPI: { UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"API接口不支持" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil]; [msgbox show]; break; } case EQQAPISENDFAILD: { UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送失败" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil]; [msgbox show]; break; } case EQQAPIVERSIONNEEDUPDATE: { UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"当前QQ版本太低,需要更新" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil]; [msgbox show]; break; } default: { break; } } }
相关文章推荐
- 如果你想在 iOS 设备(iPhone/iPad/iTouch)上调试, 需要有 iOS 开发证书和
- iOS开发:仿支付宝界面拖拽按钮动画
- IOS 控件常识
- [iOS 字符串] 字符串后几位截取
- 离屏渲染学习笔记
- iOS监听模式之KVO、KVC的高阶应用
- iOS监听模式之KVO、KVC的高阶应用
- iOS编程(3)NavigationController
- CodingNet - Learning - 8
- iOS创建JSON字符串
- iOS开发:简易天气预报
- iOS NSExpression介绍
- nagios安装配置
- iOS国际化
- iOS中添加图片选择器的实现
- iOS 无法创建名字跟已删除相册同名的相册问题
- iOS 远程推送 总结
- iOS高级--流控制---标准控制符
- iOS培训日记——归档
- iOS 中KVC、KVO、NSNotification、delegate 总结及区别