苹果(Mac和/或iPhone)的URL Scheme映射列表

4

我正在尝试了解与某个应用程序关联的自定义URL映射方案。我查看了一些SO讨论,但还没有得出结论。我有几个关于URL Scheme Mapping的问题:

  1. 是否有一种方法(例如特定命令或存储此信息的文件),可以获取给定苹果iPhone或Mac上URL Scheme和它们映射到的应用程序列表? (我猜答案是否定的-基于https://stackoverflow.com/a/10951866/1165727,但我想确认一下,因为这个答案相当古老)。

  2. 运行“strings”命令是发现与应用程序相关联的URL Scheme的唯一方法吗? (这基于对此答案的评论-https://dev59.com/O2025IYBdhLWcg3w76pq#5707825)。

  3. 是否有比http://wiki.akosma.com/IPhone_URL_Schemes更完整的URL Scheme列表?


1
  1. 不。
  2. 查看应用程序的 Info.plist 文件。
  3. 没有确定的列表。
- rmaddy
@rmaddy - 你提到的查看应用程序的 plist 而不是对着应用程序运行 strings 的方法非常有帮助。谢谢! - Y123
截至2019年12月16日,选项3中的链接已失效。 - leanne
2个回答

13

在 OS X 上,您可以使用:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump

这显示了启动服务数据库的转储,其中包括URL方案及其映射到应用程序的关系。


谢谢,这非常有帮助。 - Y123
这并不涵盖所有内容。此帖子上的回答提供了两个更多的选择来展示更多结果。例如,该命令没有显示您可以使用“dict:\”字典应用程序的内容。 - Clifford Fajardo

2
这里有一行使用Perl解析LaunchServices数据库数据的脚本,基于Ken Thomases的答案。
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | LC_ALL=C tr '\n' '\a' | perl -pe 's/(-{20}\aBundleClass)/\n\1/g' | perl -e 'sub trim {my $s = shift; $s =~ s/\a//g; $s =~ s/\"//g; $s =~ s/\{//g; $s =~ s/\}//g; $s =~ s/^\s+|\s+$//g; return $s}; sub trimCommas {my $s = shift; $s =~ s/,//g; return $s}; while ($line = <STDIN>) {if (index($line, "CFBundleURLTypes = ") != -1) {$urlTypesData = $line; $urlTypesData =~ s/^.*CFBundleURLTypes = .*?\((.*?)[^es] =.*$/\1/g; $urlTypesData =~ s/(^.*)\).*?$/\1/g; @urlTypes = split("}", $urlTypesData); if (trim($urlTypesData) ne "" && int(@urlTypes) > 1) {$name1 = $path = (split("CFBundleExecutable", $line))[0]; $name1 =~ s/.*name:(.*?)\a.*$/\1/g; $name2 = $line; $name2 =~ s/^.*CFBundleExecutable = (.*?)\;.*$/\1/g; $appName = ((index($name1, "(null)") == -1) ? trim($name1) : trim($name2)); $path =~ s/.*path:(.*?)\a.*$/\1/g; print $appName . "\f   " . "\033[38;5;173m(path: " . trim($path) . ")\033(B\033[m"; for ($i=0; $i<int(@urlTypes)-1; $i++) {$curUrlName = @urlTypes[$i]; if (index(@urlTypes[$i], "CFBundleURLName") != -1) {$curUrlName =~ s/^.*CFBundleURLName =(.*?);.*$/\1/} else {$curUrlName = "\e[3m[Blank]\e[0m"}; $schemesRaw = @urlTypes[$i]; $schemesRaw =~ s/^.*CFBundleURLSchemes =.*?\((.*?)\).*$/\1/g; @schemes = split(",", $schemesRaw); if (trimCommas(trim(@urlTypes[$i])) ne "") {print "\f\t" . trimCommas(trim($curUrlName)); for ($b=0; $b<int(@schemes); $b++) {print "\f\t\t" . trim(@schemes[$b])}}; print "\f"}}; print "\n"}}' | sort -uf | perl -pe 's/(\n)/\1\1\1/g; s/\f/\n/g'

以下是输出的几行内容:

命令输出


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