[英]Facebook Messenger can't open URL in iOS 9 with Swift
I am using Facebook Messenger SDK on iOS 9 but sharing will not work. 我在iOS 9上使用Facebook Messenger SDK,但共享无效。 Even if I have Facebook Messenger installed on my iPhone it acts like it wouldn't be there. 即使我在我的iPhone上安装了Facebook Messenger,它就像它不会那样。
The following line will return 0: FBSDKMessengerSharer.messengerPlatformCapabilities() 以下行将返回0:FBSDKMessengerSharer.messengerPlatformCapabilities()
I want to mention that everything worked correctly on iOS 8. 我想提一下在iOS 8上一切正常。
If you use any of the Facebook dialogs (eg, Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, you will need to update your application's plist to handle the changes to canOpenURLdescribed in https://developer.apple.com/videos/wwdc/2015/?id=703 . 如果您使用可以执行应用程序切换到Facebook应用程序的任何Facebook对话框(例如,登录,共享,应用程序邀请等),您将需要更新应用程序的plist以处理对https://中的 canOpenURL描述的更改developer.apple.com/videos/wwdc/2015/?id=703 。
If you're recompiling with iOS SDK 9.0, add the following to your application's plist if you're using a version of the SDK v4.5 or older: 如果您使用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>
If you're using FBSDKMessengerShareKit from versions older than the v4.6 release, also add 如果您从早于v4.6版本的版本使用FBSDKMessengerShareKit,也请添加
<string>fb-messenger-platform-20150128</string> <string>fb-messenger-platform-20150218</string> <string>fb-messenger-platform-20150305</string>
If you're using v4.6.0 or higher of the SDK, you only need to add: 如果您使用的是v4.6.0或更高版本的SDK,则只需添加:
<key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array>
This will allow the FacebookSDK integration to properly identify installed Facebook apps to perform an app switch. 这将允许FacebookSDK集成正确识别已安装的Facebook应用程序以执行应用程序切换。 If you are not recompiling with iOS SDK 9.0, your app is limited to 50 distinct schemes (calls tocanOpenURL afterwards return NO). 如果您不使用iOS SDK 9.0重新编译,您的应用程序将限制为50个不同的方案(调用tocanOpenURL之后返回NO)。
Answering my own question: Things with URL schemes have changed a little bit in iOS 9, you have to add Facebook Messenger's URL scheme in kind of a 'whitelist' for your app. 回答我自己的问题:在iOS 9中,URL方案的内容发生了一些变化,你必须为你的应用添加一个“白名单”的Facebook Messenger的URL方案。
You can find more details here: iOS 9 not opening Instagram app with URL SCHEME 您可以在此处找到更多详细信息: iOS 9无法使用URL SCHEME打开Instagram应用程序
Please add these lines in your Appdelegate Class 请在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()
}
And make sure whether you have added these info .plist 并确保您是否添加了这些信息.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.