在 iOS9.0 以上版本中,需要 LSApplicationQueriesSchemes
以使用 canOpenURL
。如果您想启用向 LINE 的分享,请将 line
添加到 LSApplicationQueriesSchemes
<key>LSApplicationQueriesSchemes</key>
<array>
<string>line</string>
</array>
SNSData
let data = SNSShareData {
$0.text = "text"
$0.images = [image]
$0.urls = [url]
}
data.post(.Twitter) { result in
switch result {
case .Success(let posted):
print(posted ? "Posted!!" : "Canceled!!")
case .Failure(let e):
print(e)
}
}
如果用户发布了分享数据,并通过 completion closure 返回结果 Success
。否则,如果取消或其他错误发生,返回结果 Failure
。
克隆此存储库,然后将 SNSShare.swift
添加到您的 Xcode 项目中。