Skip to content

Commit

Permalink
chore: flexible updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Yizack committed Oct 20, 2023
1 parent d69b414 commit 48671d5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':capacitor-toast')
implementation project(':capawesome-capacitor-app-update')

}

Expand Down
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ project(':capacitor-status-bar').projectDir = new File('../node_modules/.pnpm/@c

include ':capacitor-toast'
project(':capacitor-toast').projectDir = new File('../node_modules/.pnpm/@capacitor+toast@5.0.6_@capacitor+core@5.5.0/node_modules/@capacitor/toast/android')

include ':capawesome-capacitor-app-update'
project(':capawesome-capacitor-app-update').projectDir = new File('../node_modules/.pnpm/@capawesome+capacitor-app-update@5.0.1_@capacitor+core@5.5.0/node_modules/@capawesome/capacitor-app-update/android')
1 change: 1 addition & 0 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default {
await CONFIG.load();
await CAPACITOR.setStatusBar(true);
await CAPACITOR.startFlexibleUpdate();
if (CAPACITOR.isAndroid()) {
const { $router } = useNuxtApp();
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@capacitor/splash-screen": "^5.0.6",
"@capacitor/status-bar": "^5.0.6",
"@capacitor/toast": "^5.0.6",
"@capawesome/capacitor-app-update": "^5.0.1",
"@commitlint/cli": "^17.8.0",
"@commitlint/config-conventional": "^17.8.0",
"@nuxt/eslint-config": "^0.2.0",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions utils/capacitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Dialog } from "@capacitor/dialog";
import { Network } from "@capacitor/network";
import { Browser } from "@capacitor/browser";
import { Clipboard } from "@capacitor/clipboard";
import { AppUpdate } from "@capawesome/capacitor-app-update";

const error_conexion = { error: true, error_key: "error_conexion" };
const error_response = { error: true, error_key: "error" };
Expand Down Expand Up @@ -107,6 +108,16 @@ class CapacitorPlugins {
onBack (callback = () => {}) {
App.addListener("backButton", ({ canGoBack }) => callback(canGoBack));
}

async startFlexibleUpdate () {
const result = await AppUpdate.getAppUpdateInfo();
if (result.updateAvailability !== AppUpdateAvailability.UPDATE_AVAILABLE) {
return;
}
if (result.flexibleUpdateAllowed) {
await AppUpdate.startFlexibleUpdate();
}
}
}

export const CAPACITOR = new CapacitorPlugins();

0 comments on commit 48671d5

Please sign in to comment.