HotCodePush

Target devices with attributes

Set attributes such as userId, tenant or plan in the app, check the reach with the audience preview and release to the devices that match.

A release reaches only the devices whose attributes match its conditions: userId, tenant, plan, any label the app sets through the SDK. Every condition is evaluated on the device, and the audience preview counts the reach before you publish. The fingerprint and binary ranges of Compatibility are conditions too. The short version is the site's OTA update targeting page.

Prerequisites

  • Quickstart has run, so the SDK is installed and a first release is live.
  • Channels: a release lives in a channel, and conditions choose within it.

1. Set attributes in the app

If the app already sets its attributes, skip to step 2. Set them where the app learns them, such as after sign-in:

src/app.ts
import { HotCodePush } from "@hotcodepush/capacitor-live-updates";

await HotCodePush.setAttributes({ userId: '42', plan: 'pro' });
await HotCodePush.sync();

setAttributes merges string attributes into the ones the device holds, and a null value removes its key. The device reports them when they change, so the audience preview can count them and the console shows them. The sync() after the call runs a check now.

Attributes are labels for targeting, never personal data: an opaque user id yes, an email never. The key and value limits are on your SDK's API page.

2. Check the reach

The audience preview counts the channel's active devices, seen within 30 days, whose attributes and binaries match.

npx hotcodepush audience get --attribute plan=pro

The first line counts the devices the release reaches, followed by a table per platform and per binary version. Inside a project the count equals what release create --dry-run prints. audience lists the flags and the warnings.

3. Release to the match

npx hotcodepush release create --path dist --attribute plan=pro --binary-version ">=2.3.0"

The CLI states the reach, asks once and uploads, and --yes answers in a pipeline. The fingerprint condition is added from the bundle on its own. --binary-version and --os-version take the range syntax on Compatibility.

Every condition of a release must hold, so two values of one key are two releases. A condition applies to every platform of the release, and platforms that need different ranges get a release each with --platform. A release carries at most 16 conditions.

The release applies within about a minute. If nothing happens, see Troubleshooting.

4. Target one device or a list

A device condition names devices by id. Take the id from the debug screen on the phone, or find a customer's devices by attribute with npx hotcodepush device list --attribute userId=42.

npx hotcodepush release create --path dist --device 6b1e9d37-2f5c-4a80-9c46-d8e3a1f7b259

--device repeats, and every id goes into one condition of at most 500 ids. A larger group gets an attribute instead.

5. Verify

Probe the device: the CLI evaluates the live index as the device would and marks every condition of every release.

npx hotcodepush device probe --device 6b1e9d37-2f5c-4a80-9c46-d8e3a1f7b259

The verdict per release names the condition type that failed, attribute here, never the value. In the console, open the device and click Probe for the same verdicts. If nothing happens, see Troubleshooting.

What the public index carries

The channel index is readable by anyone holding the app id and the channel id, both of which ship in the binary. In the index, an attribute condition carries the key in plaintext and the value as a hash, and a device condition carries hashed ids. So a reader can confirm a guess but not list your customers. The console, the CLI and the API show you the values you set.

Attributes choose which release a device gets, never which bytes it may read: every device on a channel can fetch every bundle in it. Content one group must not see goes into a channel of its own, as Set up environments and tenants shows. Privacy and device data lists the whole surface.

Next steps

Last updated on

On this page