expo-cafebazaar-updater
v0.1.0
Published
Cafe Bazaar in-app updater for Expo (Android)
Maintainers
Readme
expo-cafebazaar-updater
Expo module for Cafe Bazaar in-app updates on Android, wrapping the official BazaarUpdater SDK.
Checks whether an update is available, opens Bazaar to install it, and can prompt the user to enable Bazaar auto-update.
Requirements
- Android only. The JS API no-ops on iOS and web.
- Expo SDK 53+ (config plugin uses
android.extraMavenRepos). - Cafe Bazaar 26.2.0+ on the device. Download Bazaar
- The app package name and signing key must match the listing already published on Cafe Bazaar. Otherwise Bazaar will not treat this build as your store app.
Installation
npx expo install expo-cafebazaar-updaterAdd the config plugin so prebuild injects JitPack and Android 11+ package visibility for Bazaar:
{
"expo": {
"plugins": ["expo-cafebazaar-updater"]
}
}Then regenerate native Android (skip --clean unless you intend to wipe android/):
npx expo prebuild --platform androidIf you do not use the plugin, add JitPack yourself, for example with expo-build-properties:
{
"expo": {
"plugins": [
[
"expo-build-properties",
{
"android": {
"extraMavenRepos": ["https://jitpack.io"],
"manifestQueries": {
"package": ["com.farsitel.bazaar"]
}
}
}
]
]
}
}Usage
import CafeBazaarUpdater from 'expo-cafebazaar-updater';
if (!CafeBazaarUpdater.isAvailable) {
// iOS, web, or the native module is not linked
}
const autoUpdate = await CafeBazaarUpdater.getAutoUpdateState();
// { state: 'ENABLED' | 'DISABLED' | 'NOT_SUPPORTED', error?: string }
if (autoUpdate.state === 'DISABLED') {
await CafeBazaarUpdater.enableAutoUpdate();
}
const update = await CafeBazaarUpdater.getLastUpdateState();
if (update.status === 'NEED_UPDATE') {
await CafeBazaarUpdater.updateApplication();
}Named exports are also available:
import {
isAvailable,
getAutoUpdateState,
enableAutoUpdate,
getLastUpdateState,
updateApplication,
} from 'expo-cafebazaar-updater';API
| Export | Description |
| --- | --- |
| isAvailable | true when the native Android module is linked. |
| getAutoUpdateState() | Whether Bazaar auto-update is enabled for this app. |
| enableAutoUpdate() | Opens Bazaar auto-update settings for this app. |
| getLastUpdateState() | Whether Bazaar has a newer version of this app. |
| updateApplication() | Opens Bazaar to update this app (or the web listing if Bazaar is missing). |
Auto-update states
| state | Meaning |
| --- | --- |
| ENABLED | Bazaar will download and install updates automatically. |
| DISABLED | Auto-update is supported but turned off. Call enableAutoUpdate(). |
| NOT_SUPPORTED | Bazaar is not installed, is older than 26.2.0, or this platform is not Android. See error. |
Update states
| status | Meaning |
| --- | --- |
| ALREADY_UPDATED | Store version matches this build. |
| NEED_UPDATE | A newer version is on Bazaar. targetVersionCode is the store version code. |
| ERROR | Bazaar is missing, the query failed, or this platform is not Android. See error. |
Testing
Use a release-signed build whose application ID matches the Cafe Bazaar listing, on a device with Bazaar 26.2.0+.
The example app (expo.modules.cafebazaarupdater.example) is only for compiling and linking. It will not receive real update results from Bazaar.
License
MIT
