メインコンテンツにジャンプ

APIを更新するエンドポイント

GitHub

codeの例は、JavaScriptで次のようになります。プラグインにアップデートを送信する

interface AppInfos {
version_name: string
version_build: string
version_os: string
custom_id?: string
is_prod?: boolean
is_emulator?: boolean
plugin_version: string
platform: string
app_id: string
device_id: string
}
export const handler: Handler = async (event) => {
const body = JSON.parse(event.body || '{}') as AppInfos
const {
platform,
app_id,
version_os,
device_id,
version_name,
version_build,
plugin_version,
} = body
console.log('update asked', platform,
app_id,
version_os,
device_id,
version_name,
version_build,
plugin_version)
if (version_name === '1.0.0') {
return {
version: '1.0.1',
url: 'https://apiurl.com/mybuild_101.zip',
checksum: 'sha256_checksum_of_bundle',
}
}
else if (version_name === '1.0.1') {
return {
version: '1.0.2',
url: 'https://apiurl.com/mybuild_102.zip',
checksum: 'sha256_checksum_of_bundle',
}
}
else {
return {
message: 'Error version not found'
version: '',
url: '',
}
}
}

For 非暗号化のバンドルの場合、エンドポイントは次のようになります。

{
"version": "1.0.2",
"url": "https://apiurl.com/mybuild_102.zip",
"checksum": "sha256_checksum_of_bundle"
}

For 暗号化のバンドルの場合、セッションキーも含める必要があります。

{
"version": "1.0.2",
"url": "https://apiurl.com/mybuild_102.zip",
"checksum": "encrypted_checksum_from_encrypt_command",
"session_key": "ivSessionKey_from_encrypt_command"
}

And if no update or error, add the message key と、オプションで error:

{
"message": "Version not found",
"error": "The backend crashed",
"version": "1.0.2",
}
  • checksum: バンドル zip ファイルの SHA256 ハッシュで、整合性の検証用
  • session_key: エンコードされたバンドル専用 - この値は、encrypt コマンドによって返される ivSessionKey : バージョン識別子 (semver形式)
  • version: ダウンロード可能なバンドルの HTTPS URL バンドルの作成
  • url__CAPGO_KEEP_0__

バンドルを作成し、チェックサムを生成する方法を学ぶには、 Auto Update ドキュメントを参照してください.

暗号化されたバンドルについては、 Encrypted Bundles ドキュメントを参照してください 暗号化フローについての詳細な説明があります。

Update API エンドポイントから続けて

「Update API エンドポイントから続けて」セクション

Capacitor を使用している場合 Update API エンドポイント CI/CD 自動化を計画する場合、 Capacitor の @capgo/capacitor-updater を使用して接続してください ネイティブ機能の使用に於ける@capgo/capacitor-updaterの利用について Capgo CI/CD Capgo CI/CDの製品ワークフローについて Capgo Native Builds Capgo Native Buildsの製品ワークフローについて Capgo Integrations Capgo Integrationsの製品ワークフローについて CI/CD Integration CI/CD Integrationの実装詳細