Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 5 IOS facebook共享对话框未显示在我的应用程序上_Ios_Swift_Facebook_Fbsdksharedialog - Fatal编程技术网

Swift 5 IOS facebook共享对话框未显示在我的应用程序上

Swift 5 IOS facebook共享对话框未显示在我的应用程序上,ios,swift,facebook,fbsdksharedialog,Ios,Swift,Facebook,Fbsdksharedialog,我有一个星期的时间尝试在facebook上显示shareDialog,但没有任何效果, 我的登录按钮工作正常,我在安卓系统中的工作正常,但IOs不工作,我已经从Facebook安装了SDK,我将所有文件夹都放到了项目中,但似乎没有任何效果,我已经完成了facebookSDK的迁移 我做的不对,这是我的AppDelegate.swift: import UIKit import FBSDKCoreKit @UIApplicationMain class AppDelegate: UIRespon

我有一个星期的时间尝试在facebook上显示shareDialog,但没有任何效果, 我的登录按钮工作正常,我在安卓系统中的工作正常,但IOs不工作,我已经从Facebook安装了SDK,我将所有文件夹都放到了项目中,但似乎没有任何效果,我已经完成了facebookSDK的迁移

我做的不对,这是我的AppDelegate.swift:

import UIKit
import FBSDKCoreKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // Override point for customization after application launch.

        ApplicationDelegate.shared.application(
            application,
            didFinishLaunchingWithOptions: launchOptions
        )
        return true
    }

    func application(
        _ app: UIApplication,
        open url: URL,
        options: [UIApplication.OpenURLOptionsKey : Any] = [:]
    ) -> Bool {
        return ApplicationDelegate.shared.application(
            app,
            open: url,
            options: options
        )
    }
    func applicationDidBecomeActive(_ application: UIApplication) {
        AppEvents.activateApp()
    }



    // MARK: UISceneSession Lifecycle

    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }

    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }


}
导入UIKit
导入FBSDKCoreKit
@UIApplicationMain
类AppDelegate:UIResponder、UIApplicationLegate{
func应用程序(
_应用程序:UIApplication,
didFinishLaunchingWithOptions launchOptions:[UIApplication.launchOptions键:任意]?
)->布尔{
//应用程序启动后自定义的覆盖点。
ApplicationLegate.shared.application(
应用
didFinishLaunchingWithOptions:启动选项
)
返回真值
}
func应用程序(
_app:UIApplication,
打开url:url,
选项:[UIApplication.OpenURLOptionsKey:Any]=[:]
)->布尔{
返回applicationelegate.shared.application(
应用程序,
打开:url,
选项:选项
)
}
func applicationIDBecomeActive(u应用程序:UIApplication){
AppEvents.activateApp()
}
//MARK:UISceneSession生命周期
func应用程序(uApplication:UIApplication,用于连接的配置SceneSession:UISceneSession,选项:UIScene.ConnectionOptions)->UISceneConfiguration{
//在创建新场景会话时调用。
//使用此方法可以选择配置以创建新场景。
返回UISceneConfiguration(名称:“默认配置”,会话角色:ConnectionSceneSession.role)
}
func应用程序(application:UIApplication,didDiscardSceneSessions sceneSessions:Set){
//当用户放弃场景会话时调用。
//如果在应用程序未运行时丢弃了任何会话,则将在application:didFinishLaunchingWithOptions后不久调用该会话。
//使用此方法释放特定于被丢弃场景的任何资源,因为它们不会返回。
}
}
这是ViewController.swift:

import UIKit
import FBSDKLoginKit
import FBSDKShareKit


class ViewController: UIViewController {

    @IBAction func ShareButton(_ sender: Any) {
        let alert = UIAlertController(title : "Comparte", message:"Comparte con amigos", preferredStyle: .actionSheet)

        let actionOne = UIAlertAction(title: "Comparte en facebook", style: .default) { (UIAlertAction) in

            let sharePhoto = SharePhoto()
            sharePhoto.imageURL = URL(string: "https://www.hola.com/imagenes/actualidad/20171204102954/adelanto-portada-revista-hola/0-514-626/adelanto-hola1-t.jpg")

            let content = SharePhotoContent()
            content.photos = [sharePhoto]

            self.showShareDialog(content)

        }
        alert.addAction(actionOne)

       self.present(alert, animated: true, completion: nil)

    }

    override func viewDidLoad() {
        super.viewDidLoad()

        let loginButton = FBLoginButton(permissions: [ .publicProfile ])
        loginButton.center = view.center

        view.addSubview(loginButton)
        // Do any additional setup after loading the view.
    }

     func showShareDialog<C: SharingContent>(_ content: C, mode: ShareDialog.Mode = ShareDialog.Mode.automatic) {
        let dialog = ShareDialog(fromViewController: self, content: content, delegate: self as? SharingDelegate)
            dialog.mode = mode

            dialog.show()
    }

     func sharer(_ sharer: Sharing, didCompleteWithResults results: [String: Any]) {
        print("success")

        let title = "Share Success"
        let message = "Thank You"
        let alertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
        self.present(alertController, animated: true, completion: nil)


    }

    func sharer(_ sharer: Sharing, didFailWithError error: Error) {
        print("error")

        let title = "Share Failed"
        let message = "Something went wrong. Please try again"
        let alertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertController.Style.actionSheet)
        self.present(alertController, animated: true, completion: nil)
    }

    func sharerDidCancel(_ sharer: Sharing) {
        print("canceled")

        let title = "Share Cancelled"
        let message = "Share on Facebook was Cancelled"
        let alertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
        self.present(alertController, animated: true, completion: nil)
    }


}
```

导入UIKit
导入FBSDKLoginKit
导入FBSDKShareKit
类ViewController:UIViewController{
@iAction func ShareButton(\发送方:任意){
let alert=UIAlertController(标题:“比较”,消息:“比较朋友”,首选样式:。操作表)
让actionOne=UIAlertAction(标题:“比较facebook”,样式:。默认值){(UIAlertAction)在
让sharePhoto=sharePhoto()
sharePhoto.imageURL=URL(字符串:https://www.hola.com/imagenes/actualidad/20171204102954/adelanto-portada-revista-hola/0-514-626/adelanto-hola1-t.jpg")
让内容=SharePhotoContent()
content.photos=[sharePhoto]
self.showShareDialog(内容)
}
alert.addAction(actionOne)
self.present(警报、动画:true、完成:nil)
}
重写func viewDidLoad(){
super.viewDidLoad()
让loginButton=FBLoginButton(权限:[.publicProfile])
loginButton.center=view.center
view.addSubview(登录按钮)
//加载视图后执行任何其他设置。
}
func showShareDialog(u内容:C,模式:ShareDialog.mode=ShareDialog.mode.automatic){
let dialog=ShareDialog(fromViewController:self,content:content,delegate:self-as?SharingDelegate)
dialog.mode=模式
dialog.show()
}
func sharer(sharer:Sharing,didCompleteWithResults:[字符串:任意]){
打印(“成功”)
让title=“分享成功”
让消息=“谢谢”
让alertController=UIAlertController.init(标题:标题,消息:消息,首选样式:UIAlertController.Style.alert)
self.present(alertController,动画:true,完成:nil)
}
func sharer(sharer:共享,错误:错误){
打印(“错误”)
let title=“共享失败”
let message=“出现问题,请重试”
让alertController=UIAlertController.init(标题:标题,消息:消息,首选样式:UIAlertController.Style.actionSheet)
self.present(alertController,动画:true,完成:nil)
}
func SharerDicCancel(sharer:Share){
打印(“已取消”)
让title=“取消共享”
let message=“Facebook上的共享已取消”
让alertController=UIAlertController.init(标题:标题,消息:消息,首选样式:UIAlertController.Style.alert)
self.present(alertController,动画:true,完成:nil)
}
}
```

制作一个问题我找到了一些答案,所以我通过链接内容的共享对话框来制作,问题在于内容的创建,我解决了链接内容的问题,我将尝试其他类型的内容,并向您展示如何制作,同时,这是正确内容的正确代码,记住这是斯威夫特5

let content = ShareLinkContent()

        let api = "https://developers.facebook.com"
        let endpoint = "/"
        let url = URL(string: api + endpoint)
        content.contentURL = url!

        let dialog = ShareDialog(fromViewController: self, content: content, delegate: self as? SharingDelegate)
        dialog.mode = mode
        print(dialog.canShow)
        dialog.show()

但这并不能解决问题,因为我想分享一段视频,而不仅仅是一个链接。你找到解决方案了吗?