Lewati ke konten

Using the capacitor updater with self-hosted capgo

Konten ini belum tersedia dalam bahasa Anda.

What this tutorial will cover?

This tutorial will show how to use capacitor updater in a dev environment with self hosted capgo

Requirements

  1. Cloned capgo

Getting started

To use the capacitor updater with self-hosted capgo edit the capacitor.config.ts from your app directory and set it like this:

const config: CapacitorConfig = {
appId: 'com.demo.app',
appName: 'demoApp',
webDir: 'dist',
bundledWebRuntime: false,
plugins: {
CapacitorUpdater : {
statsUrl: "http://localhost:54321/functions/v1/stats",
channelUrl: "http://localhost:54321/functions/v1/channel_self",
updateUrl: "http://localhost:54321/functions/v1/updates"
},
},
};

This will enable you to use local capgo in development. However, by default, this is not enough.

In Android enabling plaintext communication is required as by default SSL is disabled in local. This can be achived by modifying AndroidManifest.xml and adding android:usesCleartextTraffic="true" in the application tag A full example of this change can be seen here

Since by default, Android does not allow http capgo has implemented a check for http here This code might not be always here, but for now a change to this line is required to get updates working
This line should look something like this:

if (!signedURL || (signedURL.startsWith('http://') || signedURL.startsWith('https://'))) {

There also could be a problem that prevents the android app from connecting. If you do not see any requests being send to edge functions run

Terminal window
adb reverse tcp:54321 tcp:54321