ios - Facebook 分享 iOS Swift
<p><p>我正在尝试在我的 iOS 应用中使用 Facebook 分享 SDK。</p>
<p>我按照 Facebook 开发者网站中的步骤进行操作。但我有一个问题,问题是 Facebook 没有在我的应用发布的帖子上显示应用名称,如下面的屏幕截图所示。</p>
<p> <a href="/image/VWd0V.png" rel="noreferrer noopener nofollow"><img src="/image/VWd0V.png" alt="enter image description here"/></a> </p>
<p>我在日志中有一些错误:</p>
<blockquote>
<p>-canOpenURL: failed for URL: "fbapi20150629:/" - error: "This app is not allowed to query for scheme fbapi20150629"</p>
<p>plugin com.apple.share.Facebook.post invalidated</p>
</blockquote>
<p>但是照片分享没有任何问题,唯一的问题是分享的帖子上没有应用名称。</p>
<p>但在分享 ContentLink 时,我在帖子上看到了应用名称,但它不适用于照片!!</p>
<p>这是我在 iOS 中分享的代码:</p>
<pre><code>let image = UIImage(data:imageData!)
let content: FBSDKSharePhotoContent = FBSDKSharePhotoContent()
let photo: FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = image
photo.userGenerated = true
content.photos =
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: nil)
</code></pre>
<p>info.plist:</p>
<pre><code><?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>
</code></pre>
<p>帖子与应用名称共享(适用于 Android)</p>
<p> <a href="/image/2eqbJ.png" rel="noreferrer noopener nofollow"><img src="/image/2eqbJ.png" alt="enter image description here"/></a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>为什么不使用 Social Framework 来实现呢?它很容易实现和显示文本、url、照片。 </p>
<p>您只需按照以下步骤操作:-
1) 转到您的应用程序 -> 构建阶段 </p>
<p>2) 点击 Link Binary with Libraries 并添加 Social framework </p>
<p>3) 在您的 ViewController 中导入 <code><Social/Social.h></code></p>
<p>4) 在您的分享操作中编写以下代码:-</p>
<pre><code>ifSLComposeViewController.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)
}
</code></pre>
<p>否则,您可以按照以下链接进行集成:-</p>
<p> <a href="http://www.theappguruz.com/blog/facebook-integration-using-swift" rel="noreferrer noopener nofollow">http://www.theappguruz.com/blog/facebook-integration-using-swift</a> </p>
<p>要显示您的应用链接,请引用:-</p>
<p> <a href="https://developers.facebook.com/docs/applinks/ios" rel="noreferrer noopener nofollow">https://developers.facebook.com/docs/applinks/ios</a> </p></p>
<p style="font-size: 20px;">关于ios - Facebook 分享 iOS Swift,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37376556/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37376556/
</a>
</p>
页:
[1]