简体   繁体   English

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

[英]List of URL Scheme Mappings for Apple (Mac and/or iPhone)

I am trying to find more about custom URL mapping Schemes associated with a certain app.我正在尝试查找有关与某个应用程序关联的自定义 URL 映射方案的更多信息。 I checked a few SO discussions but have not been able to conclude.我检查了一些 SO 讨论,但无法得出结论。 I have a few questions for URL Scheme Mapping,我有几个关于 URL Scheme Mapping 的问题,

  1. Is there a way (like a certain command or a file that stores this info) to get a list of URL Schemes and the applications they map to on a given Apple iPhone or Mac?有没有办法(比如某个命令或存储此信息的文件)来获取 URL Schemes 列表以及它们在给定的 Apple iPhone 或 Mac 上映射到的应用程序? (I am guessing the answer is no - based on https://stackoverflow.com/a/10951866/1165727 but I want to confirm since this answer is quite old). (我猜答案是否定的 - 基于https://stackoverflow.com/a/10951866/1165727但我想确认一下,因为这个答案已经很旧了)。

  2. Is running "strings" command on an app the only way to find out the URL schemes that are associated with the app?在应用程序上运行“字符串”命令是找出与应用程序关联的 URL 方案的唯一方法吗? (This is based on the comments to this answer - https://stackoverflow.com/a/5707825/1165727 ). (这是基于对此答案的评论 - https://stackoverflow.com/a/5707825/1165727 )。

  3. Is there a more complete list of URL Schemes than - http://wiki.akosma.com/IPhone_URL_Schemes是否有比 - http://wiki.akosma.com/IPhone_URL_Schemes更完整的 URL Schemes 列表

On OS X, you can use: 在OS X上,您可以使用:

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

That shows the dump of the Launch Services database, which includes URL schemes and their mappings to apps. 这显示了Launch Services数据库的转储,其中包括URL方案及其到应用程序的映射。

Here is a one-line script which uses Perl to parse the data from the LaunchServices database, based on the answer by Ken Thomases.这是一个单行脚本,它根据 Ken Thomases 的回答使用Perl解析来自 LaunchServices 数据库的数据。

/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'

Here is a few lines of the output:这是输出的几行:

命令输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM