Facebook Messenger可以';t使用Swift在iOS 9中打开URL

Facebook Messenger可以';t使用Swift在iOS 9中打开URL,ios,facebook,swift,ios9,messenger,Ios,Facebook,Swift,Ios9,Messenger,我正在iOS 9上使用Facebook Messenger SDK,但共享将不起作用。即使我的iPhone上安装了Facebook Messenger,它也会表现得好像不存在一样 以下行将返回0: FBSDKMessengerSharer.Messenger平台功能() 我想说的是,在iOS 8上,一切都正常运行。回答我自己的问题:在iOS 9中,URL方案的情况发生了一些变化,你必须为你的应用程序添加Facebook Messenger的URL方案作为“白名单” 您可以在此处找到更多详细信息:

我正在iOS 9上使用Facebook Messenger SDK,但共享将不起作用。即使我的iPhone上安装了Facebook Messenger,它也会表现得好像不存在一样

以下行将返回0: FBSDKMessengerSharer.Messenger平台功能()


我想说的是,在iOS 8上,一切都正常运行。

回答我自己的问题:在iOS 9中,URL方案的情况发生了一些变化,你必须为你的应用程序添加Facebook Messenger的URL方案作为“白名单”


您可以在此处找到更多详细信息:

请在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>
NSAppTransportSecurity
NSAllowsArbitraryLoads

如果您使用任何Facebook对话框(例如,登录、共享、应用邀请等)执行应用程序切换到Facebook应用程序,您需要更新应用程序的plist以处理中所述的对CanopenUrl的更改

如果使用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>
LSApplicationQueriesSchemes fbapi20130214 fbapi20130410 fbapi20130702 fbapi20131010 fbapi20131219 fbapi20140410 fbapi20140116 fbapi20150313 fbapi20150629 fbapi20160328 fbauth fbauth2 fb-messenger-api20140430
如果您使用的FBSDKMessengerShareKit版本早于v4.6版本,请同时添加

<string>fb-messenger-platform-20150128</string> <string>fb-messenger-platform-20150218</string> <string>fb-messenger-platform-20150305</string>
fb-messenger-platform-20150128 fb-messenger-platform-20150218 fb-messenger-platform-20150305
如果您使用的是SDK的v4.6.0或更高版本,则只需添加:

<key>LSApplicationQueriesSchemes</key> <array>      <string>fbapi</string>      <string>fb-messenger-api</string>       <string>fbauth2</string>        <string>fbshareextension</string> </array>
LSApplicationQueriesSchemes fbapi fb messenger api fbauth2 fbshareextension
这将允许FacebookSDK集成正确识别已安装的Facebook应用程序以执行应用程序切换。如果您不使用iOS SDK 9.0重新编译,您的应用程序将被限制为50个不同的方案(之后调用CanOpenURL返回否)