簡體   English   中英

Facebook Messenger無法使用Swift在iOS 9中打開URL

[英]Facebook Messenger can't open URL in iOS 9 with Swift

我在iOS 9上使用Facebook Messenger SDK,但共享無效。 即使我在我的iPhone上安裝了Facebook Messenger,它就像它不會那樣。

以下行將返回0:FBSDKMessengerSharer.messengerPlatformCapabilities()

我想提一下在iOS 8上一切正常。

如果您使用可以執行應用程序切換到Facebook應用程序的任何Facebook對話框(例如,登錄,共享,應用程序邀請等),您將需要更新應用程序的plist以處理對https://中的 canOpenURL描述的更改developer.apple.com/videos/wwdc/2015/?id=703

如果您使用iOS SDK 9.0重新編譯,如果您使用的是SDK v4.5或更早版本,請將以下內容添加到應用程序的plist中:

<key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fbapi20130214</string> <string>fbapi20130410</string> <string>fbapi20130702</string> <string>fbapi20131010</string> <string>fbapi20131219</string> <string>fbapi20140410</string> <string>fbapi20140116</string> <string>fbapi20150313</string> <string>fbapi20150629</string> <string>fbapi20160328</string> <string>fbauth</string> <string>fbauth2</string> <string>fb-messenger-api20140430</string> </array>

如果您從早於v4.6版本的版本使用FBSDKMessengerShareKit,也請添加

<string>fb-messenger-platform-20150128</string> <string>fb-messenger-platform-20150218</string> <string>fb-messenger-platform-20150305</string>

如果您使用的是v4.6.0或更高版本的SDK,則只需添加:

<key>LSApplicationQueriesSchemes</key> <array>      <string>fbapi</string>      <string>fb-messenger-api</string>       <string>fbauth2</string>        <string>fbshareextension</string> </array>

這將允許FacebookSDK集成正確識別已安裝的Facebook應用程序以執行應用程序切換。 如果您不使用iOS SDK 9.0重新編譯,您的應用程序將限制為50個不同的方案(調用tocanOpenURL之后返回NO)。

回答我自己的問題:在iOS 9中,URL方案的內容發生了一些變化,你必須為你的應用添加一個“白名單”的Facebook Messenger的URL方案。

您可以在此處找到更多詳細信息: iOS 9無法使用URL SCHEME打開Instagram應用程序

請在Appdelegate類中添加這些行

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

        return true
    }



    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

     return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
    }

 func applicationDidBecomeActive(application: UIApplication) {
        FBSDKAppEvents.activateApp()


    }

並確保您是否添加了這些信息.plist

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM