0
我剛剛通過添加所有必需的Facebook框架,調整我的info.plist,並在我的應用程序委託中添加方法以允許用戶使用Facebook登錄。我甚至在我的分析數據庫上測試並驗證了這些新數據。好極了。如何使我的SLComposeViewController可用於服務類型(Facebook)iOS swift
現在,我試圖添加一個按鈕,如果用戶通過Facebook登錄到我的應用程序,可以將信息分享給用戶的新聞傳播。這是我有:
@IBAction func tellFriends(sender: AnyObject) {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) { // USER LOGGED IN USING FACEBOOK
let facebookSheet = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
facebookSheet.setInitialText("Share on Facebook")
self.presentViewController(facebookSheet, animated: true, completion: nil)
} else { // USER DID NOT USE FB TO LOG IN
let alert = UIAlertController(title: "Accounts", message: "Please login to a Facebook account to share.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
我得到的唯一結果是其他和我的警報控制器彈出。我驗證了我是通過Facebook登錄到應用程序的。我錯過了什麼?提前致謝。