Learn how to implement a custom user preference center in your app or website using OneSignal APIs to manage notification topics, frequencies, channels, and data privacy settings.
A Preference Center is a page on your app or website that allows your users to control how and what kind of messages they receive from you. For more details and reasons why to create a Preference Center, see A Guide to User Preference Centers.
This guide explains the technical setup needed to include a user preference center in your app or website using OneSignal’s APIs. In this guide we discuss how to:
When the user lands on your preference center, use the View user API to pull the OneSignal data for the user based on either the external_id
or a custom alias you set. This will provide you the user properties
and subscriptions
. Helpful data includes but not limited to:
properties
: the user data
tags
- custom data you send to OneSignallanguage
- the language code for the usersubscriptions
: the messaging channels and subscription status
id
- the Subscription IDtype
- Email
, SMS
, *Push (AndroidPush
, iOSPush
, ChromePush
, SafariPush
, etc)enabled
- true
means subscribed, false
means unsubscribedtoken
- the push token, email address, or phone number depending on the subscription typeUse the data provided to populate the preference center as needed.
Refer to Data Tags. Tags are key-value pairs used to segment and personalize. Use string-encoded integers or timestamps to enable range-based filtering.
Users can toggle interests (e.g., sports: 1
) or set frequency tags like newsletter-frequency: weekly
. Use this data in Segments or the Create notification API with filters.
To update a tag, call the Update user API.
Check subscriptions
for type and enabled status. Show token
only for email/SMS, not for push.
If contact info exists in your system but not yet in OneSignal, use your own DB as a fallback to display it.
Use addEmail
, addSms
SDK methods or Create subscription and Update subscription APIs. Subscription id
is required for updates.
If push is not enabled, prompt user.
Use Update subscription to set enabled
to false
. Toggle to true
to opt-in again.
Prevent SDK init by default and require user consent to initialize. See Handling Personal Data.
Use Delete user API to fully remove a user from OneSignal.