检查用户是否安装了Facebook Messenger iOS 9 [英] Check if user has Facebook Messenger installed iOS 9
问题描述
Facebook已经弃用了用于检查用户是否安装了Messenger应用程序的方法 [FBSDKMessengerSharer messengerPlatformCapabilities]
。在警告消息中,它说:
messengerPlatformCapabilities已被弃用:从iOS 9开始已弃用。如果使用此功能,则必须配置您的plist如
Facebook has deprecated the method
[FBSDKMessengerSharer messengerPlatformCapabilities]
that is used to check if the user has Messenger app installed. In the warning message, it says:messengerPlatformCapabilities is deprecated: This is deprecated as of iOS 9. If you use this, you must configure your plist as described in https://developers.facebook.com/docs/ios/ios9
I would like to remove this method, but haven't found any other option to replace this code (that makes a button disabled if user hasn't Messenger app installed):
if (![FBSDKMessengerSharer messengerPlatformCapabilities]) { [self.inviteFriendsButton setEnabled:NO]; [self.inviteFriendsButton setAlpha:0.5f]; }
Is there any other method? Or, as new iOS requirements I should avoid using this
if
? Thank you in advance.解决方案You will want to use
canOpenURL
to see if the Custom URL Schemefb-messenger://
can be opened.canOpenURL
returns aBOOL
value indicating whether or not the URL’s scheme can be handled by some app installed on the device. IfcanOpenURL
returnsYES
then the application is present on the device.if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb-messenger://"]]) { // Installed [self.inviteFriendsButton setEnabled:YES]; [self.inviteFriendsButton setAlpha:1.0]; } else { // NOT Installed [self.inviteFriendsButton setEnabled:NO]; [self.inviteFriendsButton setAlpha:0.5]; }
Also, starting at iOS 9 you must include
LSApplicationQueriesSchemes
in yourinfo.plist
.这篇关于检查用户是否安装了Facebook Messenger iOS 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!