[英]LinkedIn open url company in iOS (URL Scheme)
I need to open in the LinkedIn app a company url from my iOS app in Swift. 我需要在LinkedIn应用程序中从Swift中的iOS应用程序打开公司网址。 I have tried to do that with
URL Scheme
, but I haven't achieved it. 我曾尝试使用
URL Scheme
做到这一点,但尚未实现。
This code open the LinkedIn app, but not in the url I need: 这段代码打开LinkedIn应用程序,但不在我需要的URL中:
UIApplication.sharedApplication().openURL(NSURL(string: "linkedin://profile/xxx_id_company_xxx")!)
Can anyone help me? 谁能帮我?
It seems the correct format is "linkedin://companyName/companyId" 看来正确的格式是“ linkedin:// companyName / companyId”
See this SO question: How can open LinkedIn Comapny Url in iPhone app programmatically? 看到这样的问题: 如何以编程方式在iPhone应用程序中打开LinkedIn Comapny Url?
This linkedin company url scheme is working for me 这个linkedin公司的网址方案为我工作
This objective c code trys to open linkedin company page in linkedin app and fall backs to a modal webview presenting company web page. 此目标C代码尝试在linkedin应用程序中打开linkedin公司页面,并回退到模式化Webview展示公司网页。
/* 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. 您可以在linkedin上公司页面的源代码中找到“公司ID”。 Search for "company-id" or "companyId", it is in a hidden input field.
搜索“ company-id”或“ companyId”,它在隐藏的输入字段中。
Swift 4 斯威夫特4
In your info.plist under LSApplicationQueriesSchemes add 在LSApplicationQueriesSchemes下的info.plist中添加
<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)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.