linkedin.github.com icon indicating copy to clipboard operation
linkedin.github.com copied to clipboard

[iOS] While passing the LinkedIn profile url to open the LinkedIn profile in LinkedIn app, it's opening in web

Open swarna456 opened this issue 1 year ago • 0 comments

I want to open the profile of LinkedIn in LinkedIn app if app is installed otherwise in web. So, I added the code like this:

if let linkedIn = "https://www.linkedin.com/in/prakashiyerleadershipcoach" {
                            guard let linkedInAppURL =  URL(string: "linkedin:\(linkedIn)")
                            else { fatalError(Localize.validUrlExpectedMsg) }
 UIApplication.shared.open(linkedInURL, options: [:], completionHandler: nil)
                        }

Always it's redirecting to web only even if the app is installed.

I tried to resolve this issue using deep linking

let linkedIn = "https://www.linkedin.com/in/prakashiyerleadershipcoach"
            guard let linkedInAppURL =  URL(string: "linkedin://profile/prakashiyerleadershipcoach")
            else { fatalError("Invalid linkedInAppURL") }
            guard let linkedInWebURL = URL(string: (linkedIn.removingPercentEncoding)!)
            else { fatalError("Invalid linkedInWebURL") }
            if UIApplication.shared.canOpenURL(linkedInAppURL) {
                UIApplication.shared.open(linkedInAppURL)
                print("linkedinnnnn == \(linkedInAppURL)")
            } else {
                UIApplication.shared.open(linkedInWebURL, options: [:], completionHandler: nil)
                print("linkedinnnnn == \(linkedInWebURL)")
            }
}

Added LSApplicationQueriesSchemes in info.plist file

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>linkedin</string>
    </array>

Now while clicking on link profile page is opening in app if app is installed otherwise opening in web. But this is not the official URL schemes provided by linkedIn. I need the permanent solution for that. Can anyone help me in that. Thanks in advance!

swarna456 avatar Feb 26 '24 09:02 swarna456