gpt4 book ai didi

ios - Facebook 分享 iOS Swift

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:06:04 24 4
gpt4 key购买 nike

我正在尝试在我的 iOS 应用中使用 Facebook 共享 SDK。

我遵循了 Facebook 开发者网站中的步骤。但我有一个问题,问题是 Facebook 没有在我的应用程序发布的帖子上显示应用程序名称,如下面的屏幕截图所示。

enter image description here

我在日志中有一些错误:

-canOpenURL: failed for URL: "fbapi20150629:/" - error: "This app is not allowed to query for scheme fbapi20150629"

plugin com.apple.share.Facebook.post invalidated

但是照片分享没有任何问题,唯一的问题是分享的帖子上没有应用名称。

但是在分享 ContentLink 时,我在帖子上看到了应用程序名称,它不适用于照片!!

这是我在 iOS 中分享的代码:

let image = UIImage(data:imageData!)
let content: FBSDKSharePhotoContent = FBSDKSharePhotoContent()
let photo: FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = image
photo.userGenerated = true
content.photos = [photo]
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: nil)

信息.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>fr_FR</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>NSAppTransportSecurity</key>

<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIAppFonts</key>
<array>
<string>master_of_break.otf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb100967589******</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>100967589******</string>
<key>FacebookDisplayName</key>
<string>Athéna</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
</dict>
</plist>

帖子与应用名称共享(适用于 Android)

enter image description here

最佳答案

为什么不使用 Social Framework 来实现它?它很容易实现并显示文本、url、照片。

您只需按照以下步骤操作:-1)转到您的应用程序->构建阶段

2) 点击 Link Binary with Libraries 并添加 Social framework

3) 在您的 View Controller 中导入 <Social/Social.h>

4) 在您的分享操作中编写以下代码:-

if  SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook)
{
let fbShare = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
fbShare.setInitialText("Swift programming")
fbShare.addURL(NSURL(string: filePath))
fbShare.addImage(UIImage(named:"ImageName"))

self.presentViewController(fbShare, animated: true, completion: nil)
}

否则您可以点击以下链接进行集成:-

http://www.theappguruz.com/blog/facebook-integration-using-swift

要显示您的应用链接,请引用:-

https://developers.facebook.com/docs/applinks/ios

关于ios - Facebook 分享 iOS Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37376556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com