Skip to content

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

@swarna456

Description

@swarna456

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions