Facebook 已弃用用于检查用户是否安装了 Messenger 应用程序的方法 [FBSDKMessengerSharer messengerPlatformCapabilities]
。在警告消息中,它说:
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
我想删除此方法,但还没有找到任何其他选项来替换此代码(如果用户未安装 Messenger 应用程序,该按钮将被禁用):
if (![FBSDKMessengerSharer messengerPlatformCapabilities]) {
[self.inviteFriendsButton setEnabled:NO];
[self.inviteFriendsButton setAlpha:0.5f];
}
还有其他方法吗?或者,作为新的 iOS 要求,我应该避免使用此 if
?先感谢您。
最佳答案
您需要使用 canOpenURL
来查看自定义 URL 方案 fb-messenger://
是否可以打开。 canOpenURL
返回一个 BOOL
值,指示 URL 的方案是否可以由安装在设备上的某些应用处理。如果 canOpenURL
返回 YES
,则应用程序存在于设备上。
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];
}
此外,从 iOS 9 开始,您必须在 info.plist
中包含 LSApplicationQueriesSchemes
。
关于ios - 检查用户是否安装了 Facebook Messenger iOS 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32713306/