將下載的SDK拖入工程中
然后倒入需要的系統(tǒng)庫(kù)
libUMSocial_Sdk_4.4.a liz.1.2.5.tbd libsqlite3.0.tbd libiconv.2.4.0.tbd libstdc++.6.0.9.tbd CoreTelephony.framework CoreGraphics.framework Security.framework SystemConfiguration.framework
注:以上是需要手動(dòng)導(dǎo)入的系統(tǒng)庫(kù),其中libUMSocial_Sdk_4.4.a
在UMSocial_Sdk_4.4目錄中,必須導(dǎo)入,不然編譯錯(cuò)誤瑟幕。
下面是完整的庫(kù)圖:
庫(kù)都確認(rèn)無(wú)誤后,開(kāi)始配置URL Schemes
微信:wxd9a39c7122aa6516
騰訊:QQ05FC5B14
騰訊:tencent100424468
新浪微博網(wǎng)頁(yè)版無(wú)需設(shè)置URL Schemes
info.plist配置
Bundle display name
要設(shè)置APP名,否則無(wú)法分享到QQ
然后配置IOS9白名單LSApplicationQueriesSchemes
<key>LSApplicationQueriesSchemes</key>
<array>
<!-- 微信 URL Scheme 白名單-->
<string>wechat</string>
<string>weixin</string>
<!-- 新浪微博 URL Scheme 白名單-->
<string>sinaweibohd</string>
<string>sinaweibo</string>
<string>sinaweibosso</string>
<string>weibosdk</string>
<string>weibosdk2.5</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>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>mqzoneopensdk</string>
<!-- 支付寶 URL Scheme 白名單-->
<string>alipay</string>
<string>alipayshare</string>
</array>
IOS9網(wǎng)絡(luò)請(qǐng)求
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
以上都配置完就可以寫(xiě)代碼了
AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// 友盟默認(rèn)網(wǎng)頁(yè)新浪微博分享
UMSocialData.setAppKey("569cb35867e58e430d000d48")
// 微信
UMSocialWechatHandler.setWXAppId("wxd930ea5d5a258f4f", appSecret:"db426a9829e4b49a0dcac7b4162da6b6", url:"http://www.umeng.com/social")
// QQ
UMSocialQQHandler.setQQWithAppId("100424468", appKey:"c7394704798a158208a74ab60104f0ba", url:"http://www.umeng.com/social")
return true
}
// QQ亿卤、微信返回當(dāng)前應(yīng)用時(shí)攔截獲取url和參數(shù)
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
let result = UMSocialSnsService.handleOpenURL(url)
if (result == false) {
//調(diào)用其他SDK,例如支付寶SDK等
}
return result
}
}
ViewController.swift
import UIKit
class ViewController: UIViewController,UMSocialUIDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
UMSocialSnsService.presentSnsIconSheetView(self, appKey: "569cb35867e58e430d000d48", shareText: "測(cè)試鹿霸、測(cè)試,http://baidu.com", shareImage: nil, shareToSnsNames: [UMShareToSina,UMShareToWechatSession,UMShareToQQ], delegate: self)
}
}