序言
当你开始享受 Capgo 的更新系统时,就像我对我的应用程序一样,你会开始感到“如果我想要更多?”的感觉
我也感到了这种感觉,但由于我是 Capgo 的制造者,所以我能够查看一下
由于所有内容都是开源的,你也拥有这种权力:)
The next pain I got in the Capacitor app distribution process is to make other teammates test the updates!
With TestFlight, the issue is simple, bringing people into your team and making them understand how to get it is time-consuming!
And of course, each time you send to Apple you have a random review process by a bot who can take 5 min or 5 hours, you never know.
I got many times my presentation delayed by this…
And for Google this is even worse, the big mystery of my life, releasing a production version takes less than 2 hours, but releasing a close beta takes 1–2 days.
解决方案
为了解决这个问题,我在Capgo中创建了Channel系统。
npx @capgo/cli@latest bundle upload -c production 会更新到所有用户(如果设置为默认的生产渠道)
如果你这样做 npx @capgo/cli@latest bundle upload -c development 那么版本将落在一个不同的渠道上,这可以在__CAPGO_KEEP_0__中自动化 GitHub action.
__CAPGO_KEEP_0__
Super automatic Way
当您不想为频道设置创建自己的后端时,这可以很快实现。
只需允许其中一个频道自行设置即可。

And then add this in the code of your Ionic app, for best experience, use this after the user clicks on a button like “register for beta”
import { CapacitorUpdater } from '@capgo/capacitor-updater'
const deviceId = await CapacitorUpdater.setChannel({ channel: 'beta' })
Manual way
这可以用于您的内部团队,很快可以实现。 允许用户从应用程序中复制设备ID并将其发送给您,手动code将有助于您获取它:
import { CapacitorUpdater } from '@capgo/capacitor-updater'
const deviceId = await CapacitorUpdater.getDeviceId()
在应用程序中隐藏一个按钮,或者只向已连接的用户显示按钮,例如,通过角色。 admin 然后访问Web应用程序或原生应用程序__CAPGO_KEEP_0__,以应用程序管理员身份登录,选择您的应用程序,单击设备列表。
Then Go to the Web app or native app Capgo, connect as app admin, select your app, click on the device list.
请您的团队成员打开应用程序,等待30秒,然后打开关闭。 development__CAPGO_KEEP_0__
他应该获得您的版本。
自动方式
这对您的beta测试者来说可能很有用,这个实现起来更长一些。
与手动方式相同,您必须获得设备ID
import { CapacitorUpdater } from '@capgo/capacitor-updater'
const deviceId = await CapacitorUpdater.getDeviceId()
但这次您必须自动将其发送到您的后端,我让您决定如何做到这一点。
我只建议您将其存储在数据库中,这将使您的生活更轻松。
然后在您的后端,您必须将其发送到Capgo后端。以下是两个code示例:
NodeJS
import axios from 'axios'
await axios.post('https://api.capgo.app/device', {
app_id: 'YOUR_APP_ID',
device_id: 'DEVICE_ID',
channel: 'CHANNEL_NAME', // The name of the channel, or undefined if version_id provided
version_id: 'VERSION_NAME' // this is optional, if provide it will override the channel, that useful when you want to debug only one user.
}, {
headers: {
authorization: 'YOUR_API_KEY' // choose a key with 'write' or 'all' rights
}
})
Cloudflare
addEventListener('fetch', (event) => {
event.respondWith(
handleRequest(event.request).catch(
err => new Response(err.stack, { status: 500 })
)
)
})
async function handleRequest(request) {
const { pathname, method } = new URL(request.url)
const body = await request.json()
const newBody = JSON.stringify({
app_id: 'YOUR_APP_ID',
device_id: body.device_id,
channel: 'alpha'
})
const newUrl = new URL('https://api.capgo.app/device')
const options = {
headers: {
authorization: 'YOUR_API_KEY',
},
method: 'POST',
body: newBody
}
if (request.method === 'DELETE') {
// DELETE the channel link
options.method = 'DELETE'
return fetch(newUrl.toString(), options)
}
return fetch(newUrl.toString(), options)
}
并只将设备_id发送到部署的URL的请求体中,使用POST方法添加和DELETE方法删除。
在此配置后,尝试在您的应用程序中添加一个按钮以在频道中进行选择,并在Web应用程序中检查是否已设置。
您也可以发送 null 去除覆盖
如果您需要程序检查设备上的覆盖设置,请在同一URL上获取
import axios from 'axios'
const res = await axios.get('https://api.capgo.app/device?app_id=YOUR_APP_ID&device_id=DEVICE_ID', {
headers: {
authorization: 'YOUR_API_KEY' // choose a key with 'write' or 'all' rights
}
})
console.log('data', res.json())
从如何向一个用户或一组用户发送特定更新继续
如果您正在使用 向一个用户或一组用户发送特定更新 为计划通道路由和阶段性发布,连接它 通道 通道 通道 通道 通道 通道 Beta 测试解决方案 为 Beta 测试解决方案中的产品工作流程, 和 版本目标解决方案 为版本目标解决方案中的产品工作流程,。