检查用户是否安装了Facebook Messenger iOS 9 [英] Check if user has Facebook Messenger installed iOS 9

查看:1558
本文介绍了检查用户是否安装了Facebook Messenger 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 Scheme fb-messenger:// can be opened. canOpenURL returns a BOOL value indicating whether or not the URL’s scheme can be handled by some app installed on the device. If canOpenURL returns YES 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 your info.plist.

这篇关于检查用户是否安装了Facebook Messenger iOS 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆