Facebook has deprecated the method [FBSDKMessengerSharer messengerPlatformCapabilities]
that is used to check if the user has Messenger app installed. In the w
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
.
Since the release of the Facebook SDK v4.6.0 they use fb-messenger-api
as their URL scheme.
Swift 2.3
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "fb-messenger-api://")!) {
// Installed
} else {
// Not installed
}
Source: https://developers.facebook.com/docs/ios/ios9
In my case I needed to know whether to show a button users could press to share content on messenger. This worked for my case, and it also checks whether the messenger app is installed.
-(BOOL) canShareViaMessenger {
[[[FBSDKMessageDialog alloc] init] canShow]
}
For those using Swift 3, use this:
UIApplication.shared.canOpenURL(URL(string: "fb-messenger-api://")!)