iOS中的LinkedIn打开url公司(URL Scheme)

时间:2021-09-26 22:10:06

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.

我需要在LinkedIn应用程序中打开我在Swift中的iOS应用程序中的公司URL。我试过用URL Scheme做到这一点,但我还没有实现。

This code open the LinkedIn app, but not in the url I need:

此代码打开LinkedIn应用程序,但不在我需要的网址中:

UIApplication.sharedApplication().openURL(NSURL(string: "linkedin://profile/xxx_id_company_xxx")!)

Can anyone help me?

谁能帮我?

3 个解决方案

#1


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?

#2


This linkedin company url scheme is working for me

这个linkedin公司网址计划正在为我工​​作

  • linkedin://company?id={company-id}

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. Search for "company-id" or "companyId", it is in a hidden input field.

您可以在linkedin公司页面的源代码中找到您的“公司ID”。搜索“company-id”或“companyId”,它位于隐藏的输入字段中。

#3


Swift 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)
}

#1


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?

#2


This linkedin company url scheme is working for me

这个linkedin公司网址计划正在为我工​​作

  • linkedin://company?id={company-id}

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. Search for "company-id" or "companyId", it is in a hidden input field.

您可以在linkedin公司页面的源代码中找到您的“公司ID”。搜索“company-id”或“companyId”,它位于隐藏的输入字段中。

#3


Swift 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)
}