Open link to Facebook page from iOS app

前端 未结 8 1105
孤独总比滥情好
孤独总比滥情好 2020-11-30 18:29

I want to redirect user to my App\'s Facebook page, so I have the following code:

[[UIApplication sharedApplication] openURL:
    [NSURL URLWithString: @\"ht         


        
8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 18:59

    Swift 2.3

    For code you can use this example:

    Note: If you can't find the facebook profile id can you use the follow site to do it (https://findmyfbid.com/)

    func goFacebook() {
        let profileID = "" //Here put profile id Example:'62260589592'
        let facebookURL = NSURL(string: "fb://profile/\(profileID)")!
    
        if UIApplication.sharedApplication().canOpenURL(facebookURL) {
            UIApplication.sharedApplication().openURL(facebookURL)
        } else {
            UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/PageName")!)
        }
    }
    

    For Info.plist you need set the follow parameters:

    Note: For open the Info.plist on Source Mode

    -Go to Info.plist file and click right

    -Select "Open As"

    -Select "Source Code"

    -Put code above of another

    LSApplicationQueriesSchemes
    
     fb
     fbapi
     fbauth2
     fbshareextension
     fb-messenger-api
    
    

提交回复
热议问题