根据bundleID查询App信息

根据bundleID查询App信息_第1张图片

Overview 概述

已知App的bundleID, 怎样查询应用信息.

Solution 解决方法

使用AppStore官方的接口, 即 iTunes Search API, 具体是 http://itunes.apple.com/lookup, 虽然官方已不推荐使用 bundleId 参数, 但目前(2023.04.04)依旧有效. 以iOS预置应用"电话"为例, 请求如下:

// 请求
http://itunes.apple.com/lookup?bundleId=com.apple.mobilephone&country=CN
{
    "resultCount": 1,
    "results": [
        {
            "features": [],
            "isGameCenterEnabled": false,
            "advisories": [],
            "supportedDevices": [
                "iPhone5-iPhone5",
                "iPhone5c-iPhone5c",
                "iPhone5s-iPhone5s",
                "iPhone6-iPhone6",
                "iPhone6Plus-iPhone6Plus",
                "iPhone6s-iPhone6s",
                "iPhone6sPlus-iPhone6sPlus",
                "iPhoneSE-iPhoneSE",
                "iPhone7-iPhone7",
                "iPhone7Plus-iPhone7Plus",
                "iPhone8-iPhone8",
                "iPhone8Plus-iPhone8Plus",
                "iPhoneX-iPhoneX",
                "iPhoneXS-iPhoneXS",
                "iPhoneXSMax-iPhoneXSMax",
                "iPhoneXR-iPhoneXR",
                "Watch4-Watch4",
                "iPhone11-iPhone11",
                "iPhone11Pro-iPhone11Pro",
                "iPhone11ProMax-iPhone11ProMax",
                "iPhoneSESecondGen-iPhoneSESecondGen",
                "iPhone12Mini-iPhone12Mini",
                "iPhone12-iPhone12",
                "iPhone12Pro-iPhone12Pro",
                "iPhone12ProMax-iPhone12ProMax",
                "iPhone13Pro-iPhone13Pro",
                "iPhone13ProMax-iPhone13ProMax",
                "iPhone13Mini-iPhone13Mini",
                "iPhone13-iPhone13",
                "iPhoneSEThirdGen-iPhoneSEThirdGen",
                "iPhone14-iPhone14",
                "iPhone14Plus-iPhone14Plus",
                "iPhone14Pro-iPhone14Pro",
                "iPhone14ProMax-iPhone14ProMax"
            ],
            "ipadScreenshotUrls": [],
            "appletvScreenshotUrls": [],
            "artworkUrl60": "https://is4-ssl.mzstatic.com/image/thumb/Purple126/v4/4a/a7/06/4aa70602-bf5f-3e17-d33c-7a0cd91bfee6/AppIcon-0-0-1x_U007emarketing-0-0-0-10-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/60x60bb.jpg",
            "artworkUrl512": "https://is4-ssl.mzstatic.com/image/thumb/Purple126/v4/4a/a7/06/4aa70602-bf5f-3e17-d33c-7a0cd91bfee6/AppIcon-0-0-1x_U007emarketing-0-0-0-10-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/512x512bb.jpg",
            "artworkUrl100": "https://is4-ssl.mzstatic.com/image/thumb/Purple126/v4/4a/a7/06/4aa70602-bf5f-3e17-d33c-7a0cd91bfee6/AppIcon-0-0-1x_U007emarketing-0-0-0-10-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/100x100bb.jpg",
            "artistViewUrl": "https://apps.apple.com/cn/developer/apple/id284417353?mt=12&uo=4",
            "screenshotUrls": [
                "https://is3-ssl.mzstatic.com/image/thumb/PurpleSource115/v4/bb/2d/99/bb2d990d-96e4-feb0-1e11-b445d86cdcad/2e91e072-7287-4443-a057-8e5aaa3daff1_iPhone_6s_Plus___InCall@3x.png/392x696bb.png",
                "https://is1-ssl.mzstatic.com/image/thumb/PurpleSource115/v4/d9/3f/1b/d93f1bed-8bcb-46f9-bc8e-0ac8efae33dc/a13e7222-c50c-4a95-9da9-0f2c8e81ccc0_iPhone_6s_Plus___Favorites@3x.png/392x696bb.png"
            ],
            "kind": "software",
            "isVppDeviceBasedLicensingEnabled": true,
            "releaseNotes": "Bug Fixes and Feature Enhancements",
            "description": "使用“电话” App 拨打和接听电话。\n\n• 电话、FaceTime 音频通话和 FaceTime 视频通话汇于一处。\n• “个人收藏”提供轻点一下即可给最重要的联系人打电话和发信息的快捷方式。\n• “最近通话”显示最近来去电和未接来电。\n• “通讯录”可让您访问联系信息,涵盖电话号码、电子邮件地址以及生日和纪念日。\n• 即使您跳转到其他 App,通话也会保持接通状态,因此处理多任务变得十分轻松。\n• 最多可与 5 人进行电话会议。*\n• Visual Voicemail 提供语音留言的转写文字。将 Visual Voicemail 信息存储为备忘录、语音备忘录,或者使用“信息”、“邮件”或“隔空投送”进行共享。*\n• 自定语音信箱应答语。\n• 信息回复让您在无法接电话时轻点一下即可轻松发送回复。可使用建议回复,或者创建您自定的信息回复。\n• 如果此时无法接听电话,“稍后提醒我”可帮您记住回电。\n• 让 Siri 拨打电话、回电以及检查语音信箱。\n• “静音未知来电”为您提供将未知号码的来电自动发送到语音信箱的选项。您的电话只有在通讯录、最近去电以及“Siri 建议”中的对象来电时才会响铃。\n• 已阻止的联系人可让您识别不想要的来电者,并屏蔽来自这些号码的电话和 FaceTime 通话。\n• 各式各样的铃声和振动可让您为特定联系人选取不同提醒。 \n• “无线局域网通话”可让您通过无线局域网连接拨打或接听电话,以便您可以在蜂窝网络未覆盖或覆盖较差的区域与他人保持联系。*\n• iPhone 12 系列及后续机型支持 5G 蜂窝网络服务。**\n• “来电播报”为您提供来电时听取来电者姓名或电话号码的选项,即使您未在查看设备也可听取。\n• “拨号助理”会在拨号时自动确定正确的国际或本地电话前缀。\n• “呼叫等待”可允许他人在您正进行另一个通话时呼叫您。*\n• “呼叫转移”将呼叫您号码的来电转接到您指定的另一个号码。*\n• 通话中继为您提供在 iPad、iPod touch 和 Mac 上拨打和接听电话的选项。\n• 外部音频支持为您提供在设备扬声器和蓝牙耳机或附近扬声器(如 HomePod)之间切换的选项。从 HomePod 发起通话或者通过 HomePod 转移现有通话的音频。\n\nApple Watch 功能:\n• 直接从手腕上拨打和接听电话。 \n• 听到来电铃声或感觉到来电振动时,将来电发送到语音信箱、使用 iPhone 接听来电,或者发送信息。\n• 在通话期间调整通话音量、使用数字小键盘或甚至是将通话切换到 iPhone。\n• 听取语音留言。\n• 让 Siri 呼叫通讯录中的联系人。\n\n* 需要运营商支持\n** 需要运营商支持和 5G 套餐",
            "sellerName": "Apple Distribution International",
            "genreIds": [
                "6002"
            ],
            "releaseDate": "2021-10-25T07:00:00Z",
            "currency": "CNY",
            "trackId": 1146562108,
            "trackName": "电话",
            "primaryGenreName": "Utilities",
            "primaryGenreId": 6002,
            "bundleId": "com.apple.mobilephone",
            "currentVersionReleaseDate": "2021-12-14T23:29:12Z",
            "minimumOsVersion": "10.0",
            "trackCensoredName": "电话",
            "languageCodesISO2A": [
                "AR",
                "CA",
                "HR",
                "CS",
                "DA",
                "NL",
                "EN",
                "FI",
                "FR",
                "DE",
                "EL",
                "HE",
                "HI",
                "HU",
                "ID",
                "IT",
                "JA",
                "KO",
                "MS",
                "NB",
                "PL",
                "PT",
                "RO",
                "RU",
                "ZH",
                "SK",
                "ES",
                "SV",
                "TH",
                "ZH",
                "TR",
                "UK",
                "VI"
            ],
            "fileSizeBytes": "2104320",
            "formattedPrice": "免费",
            "contentAdvisoryRating": "4+",
            "averageUserRatingForCurrentVersion": 3.079959999999999809006112627685070037841796875,
            "userRatingCountForCurrentVersion": 1801,
            "averageUserRating": 3.079959999999999809006112627685070037841796875,
            "trackViewUrl": "https://apps.apple.com/cn/app/%E7%94%B5%E8%AF%9D/id1146562108?uo=4",
            "trackContentRating": "4+",
            "version": "2.1",
            "wrapperType": "software",
            "price": 0.00,
            "artistId": 284417353,
            "artistName": "Apple",
            "genres": [
                "工具"
            ],
            "userRatingCount": 1801
        }
    ]
}

Notes 注意点

country参数

country参数是必要的(Required), 格式是ISO-2A country code, 官方的注释如下:

The two-letter country code for the store you want to search. The search uses the default store front for the specified country. For example: US. The default is US. See http://en.wikipedia.org/wiki/ ISO_3166-1_alpha-2 for a list of ISO Country Codes.

lang参数

lang被标记为非必要参数, 可以用来指定 language, 我非常不推荐使用它, 因为它很可能在某个地区给你带来bug, 官方注释如下:

The language, English or Japanese, you want to use when returning search results. Specify the language using the five-letter codename. For example: en_us. The default is en_us (English).

官方给出的示例是: en_us, ja_jp, 但实际上是有问题的 !

  • 测试URL
    // AR是阿根廷, es_AR是西班牙语(阿根廷), 通过 *UserDefaults.standard.object(forKey: "AppleLanguages")* 返回
    http://itunes.apple.com/lookup?bundleId=com.apple.mobilephone&country=AR&lang=es_AR
    
    es_AR是通过 UserDefaults.standard.object(forKey: “AppleLanguages”) 返回.
  • 结果
    {
    	"errorMessage": "Invalid value(s) for key(s): [language]",
    	"queryParameters": {
        	"output": "json",
        	"callback": "A javascript function to handle your search results",
        	"country": "ISO-2A country code",
        	"limit": "The number of search results to return",
        	"term": "A search string",
        	"lang": "ISO-2A language code"
    	}
    }
    
    此时, 将 es_AR 改为 es, 即可正常返回 json 数据, 与 Apple 官方描述相茅盾 !

你可能感兴趣的:(iOS开发,ios,iTunes,Swift,Search,API)