Check if user has Facebook Messenger installed iOS 9

前端 未结 4 663
日久生厌
日久生厌 2020-12-17 02:44

Facebook has deprecated the method [FBSDKMessengerSharer messengerPlatformCapabilities] that is used to check if the user has Messenger app installed. In the w

4条回答
  •  鱼传尺愫
    2020-12-17 02:53

    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.

提交回复
热议问题