Register a unique id for each user so you can send them individual push notifications.
Register a user
Call registerIndieID when a user logs in:
import { registerIndieID } from 'native-notify';
export default function LoginScreen() {
const onLoggedIn = async (user) => {
await registerIndieID(user.id, yourAppId, 'yourAppToken');
};
// ...
}
It's a plain async function, not a hook. Call it from a login handler or a useEffect, never the render body, which would register on every render. It saves this device's push token under the id, so finish Expo setup first.
Id length
A sub_id can be at most 256 characters, a server-side limit. A database id or UUID is plenty.
registerIndieID resolves with no result and only logs failures. Without an Expo push token (in Expo Go on Android, or before registerNNPushToken has run) it logs a "Setup Error" and registers nothing. On web it skips registration with a log message. To confirm a registration, call Get one successfully registered ID.
Unregister a device
Call unregisterIndieDevice when the user logs out. It removes this device's tokens from the id. The id stays registered and the user's other devices keep receiving pushes.
import { unregisterIndieDevice } from 'native-notify';
unregisterIndieDevice('unique-user-id', yourAppId, 'yourAppToken');
Paired tokens
One device can hold an Expo push token and a native (FCM or APNs) token. The SDK reports them together as the optional devicePair field, { expoToken, nativeToken, platform }, on POST /api/indie/id. You don't call anything, and direct API callers can omit it: the server infers the pair from expoToken and deviceToken. Older servers ignore the field.
When a paired device's native copy of a group, topic or follow push is delivered anyway, and the app's native push credentials recently passed their live check, the server skips the redundant Expo copy. Every other case is unchanged. See Tokens & receipts.