2016-05-22 19 views
1

Ich versuche, Facebook Sharing SDK in meiner iOS App zu verwenden.Facebook Share iOS Swift

Ich folgte den Schritten auf der Facebook Developer Website. Aber ich habe ein Problem, das Problem ist, dass Facebook den App-Namen nicht auf Posts zeigt, die von meiner App veröffentlicht werden, wie Sie auf dem Screenshot unten sehen können.

enter image description here

und ich habe einige Fehler in den Protokollen:

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

plugin com.apple.share.Facebook.post invalidated

aber das Foto ohne Problem gemeinsam genutzt wird, ist das einzige Problem, dass es auf dem Beitrag geteilt nicht der App-Name ist.

Aber wenn ich einen ContentLink teile, sehe ich den App-Namen auf dem Post, es funktioniert nicht auf Fotos !!

hier ist mein Code in iOS zu teilen:

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) 

info.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> 

Beitrag mit App-Namen geteilt (es funktioniert auf Android)

enter image description here

+0

bitte Ihre info.plist Datei teilen –

Antwort

0

Fügen Sie Ihrer info.plist

die folgenden Elemente hinzu

+0

Ich habe bereits hinzugefügt, dass –

1

Warum verwenden Sie Social Framework nicht, um dies zu implementieren? Es ist sehr einfach zu implementieren und zeigt Text, URL, Foto an.

Sie müssen nur die folgenden Schritte durchführen: - 1) Goto App - Sozial Rahmen

3) In Ihrem View-Controller> Phasen beim Aufbau

2) Klicken Sie auf Link-Binary mit Bibliotheken und fügen <Social/Social.h> Import

4) In Ihrer Freigabe Aktion schreiben, den Code unten: -

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) 
} 

Sie Else den unten stehenden Link für die Integration folgen: -

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

Ihre App-Link diese beziehen anzuzeigen: -

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