Skip to main content

Keep push notifications attached to the signed-in user

Section ID: Guide/jbmo9ticlh#register-push-devices

Keep a coaching update attached to the right person when a phone signs in, rotates its push token or switches accounts. Enroll the signed-in user’s device, send a test update, then remove that enrollment on sign-out.

Before starting, obtain the push token with the client SDK and the user’s device permission, and configure the matching delivery channel on your backend.

Recipe: receive an update on the signed-in device​

Section ID: Guide/jbmo9ticlh#push-device-registration

Build the device enrollment part of a coaching-update notification. The device must be registered to the person who is signed in when it receives the notice—not to whoever last used the phone.

  1. Ask for device notification permission for the feature the user enabled, then obtain the current FCM token with the client SDK.

  2. Register that token under the signed-in user below. Keep it out of logs.

  3. Read registered channels and confirm push enrollment. If it is absent, repair registration before continuing. Then send a controlled test notice. Confirm it reaches the intended device, then test opening its destination.

  4. Keep registration current when the SDK rotates the token.

  5. On sign-out or account switch, remove the old user’s binding before registering the next user. Follow the recovery steps below if removal is uncertain.

Registration is setup; it does not prove provider delivery or that the device displayed a notice.

Register after sign-in or token rotation​

Section ID: Guide/jbmo9ticlh#register-a-device

Request example: Register a push notification device · Request fields.

See Register a push notification device for the request and response contract. The following values illustrate the choices for this example; replace identifiers with your own authorized values.

  • fcmToken: text firebase-cloud-messaging-token.
  • platform: text PLATFORM_IOS.
  • deviceId: text device-unique-id.

Response:

Response example: Register a push notification device · Response fields.

See Register a push notification device for the request and response contract. The following values illustrate the choices for this example; replace identifiers with your own authorized values.

  • subscriberId: text user_123.
  • success: boolean true.

Check enrollment before testing delivery​

Section ID: Guide/jbmo9ticlh#get-registered-channels

Check which notification channels are available for the current user.

Request example: Get registered notification channels · Request fields.

See Get registered notification channels for the request and response contract. The following values illustrate the choices for this example; replace identifiers with your own authorized values.

  • (root): empty object.

Response:

Response example: Get registered notification channels · Response fields.

See Get registered notification channels for the request and response contract. The following values illustrate the choices for this example; replace identifiers with your own authorized values.

  • channels[0].channel: text CHANNEL_IN_APP.
  • channels[0].registered: boolean true.
  • channels[0].credentialCount: number 1.
  • channels[1].channel: text CHANNEL_PUSH.
  • channels[2].channel: text CHANNEL_EMAIL.
  • channels[2].registered: boolean true.
  • channels[2].credentialCount: number 1.
  • channels[3].channel: text CHANNEL_SMS.

This example shows push enrollment is absent. Repair enrollment for the intended user and current device before sending a test; see registration fields. Registration alone does not prove delivery.

Remove this device before account switch​

Section ID: Guide/jbmo9ticlh#unregister-a-device

Request example: Unregister a push notification device · Request fields.

See Unregister a push notification device for the request and response contract. The following values illustrate the choices for this example; replace identifiers with your own authorized values.

  • fcmToken: text firebase-cloud-messaging-token.

Response:

Response example: Unregister a push notification device · Response fields.

See Unregister a push notification device for the request and response contract. The following values illustrate the choices for this example; replace identifiers with your own authorized values.

  • subscriberId: text user_123.

Use the remaining-device result to confirm this device was removed.

Recover failed enrollment and sign-out​

Section ID: Guide/jbmo9ticlh#device-lifecycle

Register while the intended user is authenticated. Listen for token rotation. After a reconnect or failed registration, check registered channels and retry the current token with a bounded retry policy instead of waiting for another rotation. Do not log push tokens.

Unregister the current device while the old user is still authenticated. If it fails, clear private data from the device, keep track of the pending removal, and retry under that user's authenticated session or ask support before binding the device to a different user. Signing out locally does not remove a server registration. Do not delete the user's persistent schedules when signing out one device.

A successful registration does not confirm delivery or display. Send a test to the device and check delivery status; receiving, displaying and opening a notification are separate outcomes. Device expiry rules differ by platform, so do not apply Android inactivity rules to iOS.

Document ID: Guide/jbmo9ticlh