Identity verification proves to PushFire which user your app calls for. Your server computes an identity hash for each signed-in user with a secret that only your server knows. The app sends the hash with each subscriber call. PushFire then refuses a call for a user without the matching hash.
TODO for Erik before publishing: publish this guide only after the Swift SDK, Flutter SDK and Firebase extension releases that add identity verification. Check each method name in this guide against those releases: Swift login(externalId:identityHash:) and setIdentityHash(_:), Flutter loginSubscriber(identityHash:) and setIdentityHash, and the Firebase extension release with getIdentityHash. Delete this paragraph when they match.
Why you need identity verification
Your app ships a Public key (pf_pk_…). Anyone can extract it from the app bundle. Without identity verification, a person with that key can:
- call login-subscriber with any externalId and their own device. PushFire then links their device to that user, so they receive that user's push notifications.
- add, change or remove that user's tags, including the opt-out tags OptOutPush and OptOutEmail.
- change that user's profile or log that user out.
External IDs are often emails or sequential numbers, so they are easy to guess. Identity verification closes this gap. The public key alone is no longer enough to act as a user.
How identity verification works
- The identity secret (pfid_…) belongs to your project. It stays on your server.
- The identity hash is HMAC-SHA256(key = identity secret, message = externalId), written as 64 lowercase hex characters.
- The app sends the hash in the HTTP header X-PushFire-Identity-Hash. The SDKs do this for you.
The hash is needed on these six endpoints when the call names an identified subscriber (one with an externalId): login-subscriber, logout-subscriber, update-subscriber, add-subscriber-tag, update-subscriber-tag and remove-subscriber-tag. Anonymous subscribers (a device with no login) need no hash. register-device and update-device need no hash.
Step 1: generate the identity secret
- Open console.pushfire.app and select your project.
- Go to Settings → Identity Verification.
- Click Generate secret.
- Copy the secret. It starts with pfid_. The console shows it once. If you lose it, rotate it, as the section "Rotate the identity secret" below shows.
- Store it as a server secret, for example PUSHFIRE_IDENTITY_SECRET in your server environment, in Supabase Edge Function secrets or in Google Cloud Secret Manager.
Warning: never put the identity secret in your app, a NEXT_PUBLIC_ / VITE_ / EXPO_PUBLIC_ variable or a no-code frontend. With the secret, anyone can compute the hash for every user.
Do not turn on Require identity verification yet. Do that in step 5, after your app sends hashes.
Step 2: compute the hash on your server
Compute the hash for the user that your server has authenticated. Never compute a hash for an externalId that the app sends in the request body. That would let any user get a hash for any other user.
Hash the externalId exactly as your app sends it to PushFire: the same characters, no trimming and no change of case. A numeric ID is hashed as its decimal string, so 123 and "123" give the same hash.
Node.js and TypeScript
Python
Supabase Edge Function (Deno)
This function reads the user from the Supabase access token, so it returns a hash for the signed-in user only. Set the secret with supabase secrets set PUSHFIRE_IDENTITY_SECRET=pfid_....
The app calls it with supabase.functions.invoke('pushfire-identity'), which sends the user's access token. A browser app also needs CORS headers on this function.
Firebase: the PushFire Firebase extension
The callable function getIdentityHash is available in the next extension release. It works like this:
- It needs a signed-in Firebase Auth user and ignores any data the app sends.
- It reads the document <your users collection>/<auth uid>, takes the externalId with the extension's field mapping, and returns { externalId, identityHash }.
- Your user documents must use the Firebase Auth UID as the document ID. Documents with automatic IDs are not supported yet.
- Set the new extension parameter Identity secret (PUSHFIRE_IDENTITY_SECRET) to your pfid_ secret when you install or reconfigure the extension. Firebase stores it in Secret Manager.
- Without the secret, or when the document has no externalId value, the function returns the error failed-precondition.
The app calls it after Firebase sign-in and logs in to PushFire with exactly the values it returns:
Until that release, use a Cloud Function of your own with the Node.js code above.
Step 3: return the hash to the app after sign-in
After your sign-in finishes, the app asks your server for the hash. Your server answers with externalId and identityHash. Use the externalId from that response for the PushFire login, so the two always match.
The hash does not expire. The app can keep it with the user's session and ask again after each sign-in.
Step 4: pass the hash to the SDK login
Swift / iOS
The SDK stores the hash and sends it on every later call for this user: tags, profile updates and logout.
Flutter
Automatic login (AuthProvider.firebase, AuthProvider.supabase, FirebaseAuthProvider or SupabaseAuthProvider) cannot ask your server for a hash. When you turn on verification, log in by hand as shown above, and check your SDK's README for the identity verification options of your version.
FlutterFlow and Dreamflow
- Dreamflow uses the Flutter SDK. Ask the agent to call your hash endpoint after sign-in and pass identityHash to loginSubscriber, as in the Flutter example.
- FlutterFlow: add an API call to your hash endpoint after your sign-in action, then pass its identityHash to the login action. Keep verification off until your PushFire-Lib version has an identity hash parameter. Existing projects have until 2027-12-03.
React Native, Android, web and the REST API
Send the header yourself on the six endpoints above. Keep the hash after login and clear it after logout:
The React Native, Android and web guides show a client helper that sends the header.
Step 5: turn on Require identity verification
- Ship the app version that sends the hash.
- Test it. PushFire already checks every hash that the app sends, even with verification off. A wrong hash returns 401 identity_verification_failed, so you find mistakes before you turn verification on.
- Wait until most of your users run that version. Older app versions send no hash, so their logins and tag calls fail after you turn verification on.
- In Settings → Identity Verification, turn on Require identity verification.
You can turn it off again at any time.
Rotate the identity secret
Rotate the secret when you think someone has seen it.
- In Settings → Identity Verification, click Rotate secret and copy the new secret.
- Put the new secret on your server.
- PushFire accepts hashes from the previous secret for 7 days after a rotation. In that time, installed apps get new hashes from your server.
- Give the app the new hash without a new login. Call setIdentityHash with the hash from your server, for example at app start:
After 7 days, hashes from the old secret return 401 identity_verification_failed.
Errors
The API returns these errors with the body { "error": "...", "errors": [{ "code": "...", "message": "..." }] }. The SDKs report them as typed errors and do not retry.
- 401 identity_verification_required: verification is on and the call sent no hash, or the project has no identity secret yet. Fetch the hash from your server and pass it to login.
- 401 identity_verification_failed: the hash matches neither the current secret nor the previous one. Check that the server hashes the same externalId that the app sends, with the current secret.
- 403 external_id_change_not_allowed: a call with the public key tried to change a subscriber's existing externalId while verification is on. Change it from your server with the Secret key.
update-subscriber checks the hash against the subscriber's stored externalId. To give an anonymous subscriber its first externalId, send the hash of the new value.
When identity verification is on
- New projects get verification on by default. This default starts soon after the SDK releases that send the hash. Check the switch in Settings → Identity Verification to see the state of your project.
- Existing projects keep unverified access until 2027-12-03. On that date PushFire turns verification on for every project. Before then, PushFire emails each project owner whose app still sends identified calls without a hash.
Test vectors for your implementation
Run your hash function against these values. Each line shows the secret, the externalId and the expected hash.
- pfid_test_secret_0123456789abcdef, user_42: 5bce94e3b7c422f9ad260cd2abc44b2b2fa73f296683ad1a3b54a437769a45c7
- pfid_test_secret_0123456789abcdef, 123 (string or number): 28a2670e8e93ffde3fa53ea536c2e97b779632a14b8ee0a81f3270b7d4a71580
- pfid_test_secret_0123456789abcdef, alice@example.com: 078615dfb449cf376da967822133763196245f088b73d53ed39cc7ed313314ad
- pfid_test_secret_0123456789abcdef, Zoë-東京: 8a6259549dbd82b43e9aa924e5506c297bc658cf15a46e698d74979413c2a3a0
- another-secret, user_42: 5d932a9fc933022922cd5488f445b03cc05d6444a241bf0d8a86b3fac6952dbe
The key is the UTF-8 bytes of the whole secret string, including pfid_. The message is the UTF-8 bytes of the externalId.
FAQ
Do anonymous subscribers need an identity hash?
No. A subscriber without an externalId is a device with no login. Its calls need no hash. The hash is needed from the moment the app logs a user in.
Do calls with the Secret key need an identity hash?
No. Calls with a Secret key (pf_sk_…), a Restricted key that holds a Secret scope, or a legacy key never need the hash. These keys belong on your server, which already knows who the user is.
Can I put the identity secret or the Secret key in my app?
No. Never ship the identity secret (pfid_…) or a Secret key (pf_sk_…) in a mobile app, browser bundle or no-code frontend. The app gets only the Public key (pf_pk_…) and the hash for its own signed-in user.
Can the app compute the hash itself?
No. To compute the hash, the app would need the identity secret, and then anyone could extract it. Always compute the hash on your server, a Supabase Edge Function or a Firebase Cloud Function.
How do I hash a numeric external ID?
Hash its decimal string. 123 and "123" give the same hash. Do not add leading zeros, spaces or a decimal point.
Does the hash expire?
No. A hash stays valid until you rotate the secret, and for 7 days after that.
Next steps
- Keys: Public and Secret keys.
- SDK setup: Swift / iOS and Flutter.
- Server calls: Push notification REST API quickstart.