跳过主要内容
替代方案

如何向用户发送特定更新

允许用户尝试beta版本,而无需TestFlight或Google Beta过程,只需在Ionic应用中添加一个按钮,他们就可以开始了!

文章来源

马丁·多纳迪厄

作者

瓦莱里亚

审阅者

乔丹

编辑

如何向用户发送特定更新

序言

当你开始享受Capgo的更新系统时,像我一样,对你的应用程序,你会开始感受到“如果我想要更多?”的感觉

我也感受到这个感觉,但由于我是Capgo的制作者,我可以进行查看!

由于所有内容都是开源的,你也拥有这个权力:)

在Capacitor应用程序分发过程中,我遇到的下一个痛点是让其他团队成员测试更新!

使用TestFlight,这个问题变得简单,带入你的团队并让他们了解如何获取它的时间是浪费的!

当然,每次你发送到Apple时,你都会有一个随机的机器人审查过程,可能花5分钟或5小时,你永远不知道。

我多次因为这个原因而推迟了我的演讲…

而对于Google来说,这甚至更糟糕,我的生活中最大的谜团是,发布生产版本只需要不到2小时,但发布闭源beta版本需要1-2天。

解决方案

为了解决这个问题,我在Capgo中创建了Channel系统。

npx @capgo/cli@latest bundle upload -c production 会更新到所有用户(如果设置为生产渠道默认)

If you do, then the version will be sent to a different channel, this can be automatized in __CAPGO_KEEP_0__ action npx @capgo/cli@latest bundle upload -c development then you have 2 ways to let users get the updates from the channel GitHub action.

This can be useful when you don’t want to create your own backend for channel set, this is fast to implement.

With that one, the only thing you need to do is allow one of your channels to be self to set.

Allow set self in __CAPGO_KEEP_0__

And then add this in the __CAPGO_KEEP_0__ of your Ionic app, for best experience, use this after the user clicks on a button like “register for beta”

Allow set self in Capgo

This can be useful for your internal team, this is fast to implement. Allow users to copy their deviceID from your app and send it to you manually, this code will help you to get it:

import { CapacitorUpdater } from '@capgo/capacitor-updater'

const deviceId = await CapacitorUpdater.setChannel({ channel: 'beta' })

Hide a button somewhere in your app, or show the button to only connected users with a

If you do, then the version will be sent to a different channel, this can be automatized in code action

import { CapacitorUpdater } from '@capgo/capacitor-updater'

const deviceId = await CapacitorUpdater.getDeviceId()

then you have 2 ways to let users get the updates from the channel admin 例如角色。

然后前往 Web 应用程序或原生应用程序 Capgo, 以应用程序管理员身份登录,选择您的应用程序,单击设备列表。

然后在搜索栏中输入设备 ID,单击找到的一项,然后单击 Channel 链接,选择 development请您的同事再次打开应用程序,等待 30 秒,然后打开关闭。

他应该获得您的版本。

自动方式

这对您的 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())

继续阅读如何向一个用户或一组用户发送特定更新

如果您正在使用 如何向一个用户或一组用户发送特定更新 来规划频道路由和阶段性发布,请将其与 频道 context 发布渠道 发布渠道 发布渠道 测试解决方案 测试解决方案的产品工作流程 版本目标解决方案 版本目标解决方案的产品工作流程 文章来源

实时更新Capacitor应用

当一个web层bug处于活跃状态时,通过Capgo将修复推送到应用商店,而不是等待几天的审批。用户在后台接收更新,而原生变化仍然在正常的审批路径中。

Martin 为您提供人性化的支持

立即开始

最新博客

Capgo 为您提供创建真正专业的移动应用所需的最佳见解