iOS 集成 QQ,微信,新浪微博
微信 基於https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=1417694084&token=&lang=zh_CN
1.下載微信SDK組件
SDK文件包括 libWeChatSDK.a,WXApi.h,WXApiObject.h 三個。
請前往“資源下載頁”下載最新SDK包
2. SDK文件添加到工程中
iOS SDK目錄結構
iOS SDK包中帶有四個文件:
- libWeChatSDK.a
- WXApi.h
- WXApiObject.h
注意TencentOpenAPI.framework和TencentOpenApi_IOS_Bundle.bundle必須放到應用的資源的根目錄下,否則會出現資源無法加載的問題
3. 添加依賴的系統庫文件。
在XCode中,選擇你的工程設置項,選中“TARGETS”一欄,
選擇“Build Phases”一欄。
點擊Link Binary With Libraried,選擇”+”
分別是
- SystemConfiguration.framework
- libz.tbd
- libsqlite3.0.tbd
- libc++
- Security.framework,
- CoreTelephony.framework
- CFNetwork.framework
4. 添加一條新的“URL scheme”
在XCode中,選擇你的工程設置項,選中“TARGETS”一欄,
選擇“info”一欄。
添加一條新的“URL scheme”
新的identifler=wechat
新的scheme = wx + appid。
5.建立SSL白名單並添加到你的app的plsit中
<key>NSAppTransportSecurity</key>
<dict>
<!-- 配置允許 http的任意網絡Begin-->
<key>NSAllowsArbitraryLoads</key>
<true/>
<!-- 配置允許 http的任意網絡End-->
<key>NSExceptionDomains</key>
<dict>
<!-- 集成微信、QQ、Qzone、騰訊微博授權對應的HTTP白名單-->
<key>qq.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<!-- 騰訊授權-->
<!-- 集成新浪微博對應的HTTP白名單-->
<key>sina.com.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>sinaimg.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>sinajs.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>sina.cn</key>
<dict>
<!-- 適配iOS10 -->
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>weibo.cn</key>
<dict>
<!-- 適配iOS10 -->
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>weibo.com</key>
<dict>
<!-- 適配iOS10 -->
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<!-- 新浪微博-->
</dict>
</dict>
6.對應用跳轉的支持 (SSO等)
如果你需要用到微博的相關功能,如登陸,分享等。並且需要實現跳轉到微博的功能,在iOS9系統中就需要在你的app的plist中添加下列鍵值對。否則在canOpenURL函數執行時,就會返回NO。瞭解詳情請至https://developer.apple.com/videos/wwdc/2015/?id=703
<key>LSApplicationQueriesSchemes</key>
<array>
<!-- 新浪 URL Scheme 白名單-->
<string>sinaweibohd</string>
<string>sinaweibo</string>
<string>weibosdk</string>
<string>weibosdk2.5</string>
<!-- 微信 URL Scheme 白名單-->
<string>wechat</string>
<string>weixin</string>
<!-- QQ、Qzone URL Scheme 白名單-->
<string>mqqapi</string>
<string>mqq</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqconnect</string>
<string>mqqopensdkdataline</string>
<string>mqqopensdkgrouptribeshare</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkapi</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV3</string>
<string>mqqopensdkapiV4</string>
<string>mqzoneopensdk</string>
<string>wtloginmqq</string>
<string>wtloginmqq2</string>
<string>mqqwpa</string>
<string>mqzone</string>
<string>mqzonev2</string>
<string>mqzoneshare</string>
<string>wtloginqzone</string>
<string>mqzonewx</string>
<string>mqzoneopensdkapiV2</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapi</string>
<string>mqqbrowser</string>
<string>mttbrowser</string>
<!-- 支付寶 URL Scheme 白名單-->
<string>alipay</string>
<string>alipayshare</string>
</array>