Publishing docs

In-app update prompts (SDK)

View .md

worldstreet-store-updater lets an Android app check the WorldStreet Store for a newer APK, download it, check it, and open Android's installer. Apps installed from the store don't update on their own without it.

Install

npx expo install worldstreet-store-updater expo-application expo-file-system expo-intent-launcher @react-native-async-storage/async-storage

Add the install permission in app.json, then rebuild the APK:

{ "expo": { "android": { "permissions": ["REQUEST_INSTALL_PACKAGES"] } } }

Use

import AsyncStorage from "@react-native-async-storage/async-storage";
import { StoreUpdater, useStoreUpdate } from "worldstreet-store-updater";

export const updater = new StoreUpdater({
  packageName: "com.worldstreetgold.crypto", // the app's package name
  storage: AsyncStorage,
});

export function UpdateBanner() {
  const { check, progress, install, dismiss, dismissed, error } = useStoreUpdate(updater);
  if (!check?.updateAvailable || (dismissed && !check.mandatory)) return null;
  // Show check.latest.versionName and check.latest.notesMd,
  // a button that calls install(), progress (0 to 1) while downloading,
  // and a "Later" button that calls dismiss(), unless check.mandatory is true.
  return null;
}

The hook checks when the app opens and each time it returns to the foreground. An update is mandatory when the installed version is below the release's minimum supported version, which is set with --min-supported when publishing.

Crash reports for OTA rollouts

These let the store halt a bad OTA update automatically:

const prev = ErrorUtils.getGlobalHandler();
ErrorUtils.setGlobalHandler((e, fatal) => {
  if (fatal) void updater.reportCrash(e);
  prev(e, fatal);
});

Safety

Before opening the installer, the SDK checks each download's size and MD5 against what the store published. Android itself refuses an update signed with a different key from the installed app.