Skip to main content

Bind devices to users

An app installation can outlive a login session, and one customer can use several devices. Keep device registration and user identity as separate records in your backend.

Choose your targeting model​

Use a Registration ID to reach a specific installation. Use an alias when your product needs a stable targeting value for a user across installations. Use tags for opt-in groups or application-defined segments.

Issue opaque aliases from your backend. Avoid email addresses, phone numbers, and sequential identifiers that expose account details. A targeting label is not an authorization boundary: the receiving app must still authenticate and authorize access to the referenced resource.

Update the binding at login​

After your backend authenticates the customer, associate the current installation with that account and supply the intended alias. Apply the alias through your chosen JPush integration and check its completion result.

Android example:

JPushInterface.setAlias(context, sequenceNumber, aliasFromYourBackend);

Receive the operation result in onAliasOperatorResult. For iOS, use setAlias:completion:seq: and check the completion code. Both are asynchronous operations; a local call is not confirmation that the remote binding succeeded.

Clear the binding at logout​

Remove the user-to-installation association on your server and clear the alias through the SDK. On Android, use deleteAlias(context, sequenceNumber); on iOS, use the corresponding delete-alias API. Handle completion and retry a failed cleanup according to your app's lifecycle.

If a device switches accounts, stop targeting the former account from your backend immediately. Already queued notifications can still arrive, so show sensitive details only after authenticating the current user and fetching the authorized resource.

Keep tags manageable​

Use a documented vocabulary for your own tags, such as language or a customer-selected topic. Distinguish replacement operations from add/remove operations so one feature does not erase another feature's labels. Apply preferences consistently across devices.

Verify account switching​

Sign in as account A, send a targeted notification, sign out, then sign in as B on the same device. Confirm that future notifications target the correct account and that stale messages cannot open A's private data.

References: Android alias and tag APIs and iOS alias and tag APIs.