Reputation: 35
I need to open in the LinkedIn app a company url from my iOS app in Swift. I have tried to do that with URL Scheme
, but I haven't achieved it.
This code open the LinkedIn app, but not in the url I need:
UIApplication.sharedApplication().openURL(NSURL(string: "linkedin://profile/xxx_id_company_xxx")!)
Can anyone help me?
Upvotes: 1
Views: 5027
Reputation: 31
Swift 4
In your info.plist under LSApplicationQueriesSchemes add
<string>linkedin</string>, then in your code just add
let webURL = URL(string: "https://www.linkedin.com/in/yourName-yourLastName-yourID/")!
let appURL = URL(string: "linkedin://profile/yourName-yourLastName-yourID")!
if UIApplication.shared.canOpenURL(appURL) {
UIApplication.shared.open(appURL, options: [:], completionHandler: nil)
} else {
UIApplication.shared.open(webURL, options: [:], completionHandler: nil)
}
Upvotes: 3
Reputation: 1
This linkedin company url scheme is working for me
This objective c code trys to open linkedin company page in linkedin app and fall backs to a modal webview presenting company web page.
/* try to open linkedin app with company url */
if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"linkedin://company?id=2589010"]]) {
/* Unable to open linked app, present web page with url @"https://www.linkedin.com/company/sesli-sozluk" */
...
}
You can find your "company id" in the source code of your company page on linkedin. Search for "company-id" or "companyId", it is in a hidden input field.
Upvotes: 0
Reputation: 3955
It seems the correct format is "linkedin://companyName/companyId"
See this SO question: How can open LinkedIn Comapny Url in iPhone app programmatically?
Upvotes: 0