如何在iPhone应用程序中以编程方式打开LinkedIn公司网址?

3
我想通过编程从我的iPhone应用程序打开LinkedIn公司网址并跳转到LinkedIn应用程序。我使用以下代码,但不起作用,请帮忙...
string = [NSString stringWithFormat:@"linkedin://company/COMPANY_ID"];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]]; 

有没有人可以帮我解决这个问题? - Divya Bhaloidiya
有没有人解决了这个问题? - Divya Bhaloidiya
4个回答

3
以下内容适用于当前LinkedIn应用程序,发布日期截至目前。
NSString *string = [NSString stringWithFormat:@"linkedin://company/%@", companyID];
NSURL *url = [NSURL URLWithString:string];
[[UIApplication sharedApplication] openURL:url];

这将打开LinkedIn应用程序,如果尚未登录,则提示登录,并显示给定公司ID的公司页面。

刚刚确认这对我有效。在iOS 8.3设备上使用LinkedIn应用程序版本8.8.1。您需要使用数字公司ID。您可以通过访问https://www.linkedin.com/company/<companyID>并查看是否显示公司个人资料页面来确认您是否拥有正确的编号。 - Nicholas Harlen
你可以通过查看个人资料页面的源代码并搜索companyId=来找到要使用的公司ID。 - Nicholas Harlen
2023年找不到companyId - ANDYNVT

2
将您的代码替换为以下内容:
     NSString *string = [NSString stringWithFormat:@"http://www.linkedin.com/your_companyName/Your_COMPANY_ID"];//if dyanmic then pass it as a parameter.

     NSURL *url = [NSURL URLWithString:string];

     [[UIApplication sharedApplication] openURL:url];

0

0
你误用了格式,我认为你想要的效果应该是这样做的:
string = [NSString stringWithFormat:@"linkedin://%@/%@", company, COMPANY_ID];

假设公司和COMPANY_ID是您在其他地方声明的一些字符串。

我正在使用任何公司ID,比如123456,来替代"COMAPNY_ID"。但是对于公司来说,这并不起作用。即字符串= [NSString stringWithFormat:@"linkedin://company/xxxxxxx"]; 这里的xxxxxxx是公司ID。 - Divya Bhaloidiya
string = [NSString stringWithFormat:@"linkedin://company/%@", COMPANY_ID];试试这个。 - johnyu
尝试过了,但问题仍然存在。 - Divya Bhaloidiya
那么该行应该是: string = [NSString stringWithFormat:@"linkedin://profile/%@", 公司ID]; - johnyu
这些操作有没有成功?我只能打开应用程序,但是没有被重定向到公司页面。 - Vlad Manolache
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接