Preference Center

 Important

Airship preference centers are widgets that can be embedded in a page in an app or website. Please verify with your legal team that your full preference center page, including any web page for email preference centers, is compliant with local privacy regulations.

Displaying Preference center

Airship’s SDK provides a simple interface for managing the Preference Center within your Cordova application.

Displaying the Preference Center
UAirship.openPreferenceCenter("preferenceCenterId")

Build your own UI

Retrieve the Preference Center config

You can use your own UI in your app, by retrieving the preference center config with getPreferenceCenterConfig:

Retrieve the Preference Center config
UAirship.getPreferenceCenterConfig("preferenceCenterId", function(result) {
    //Use the preference center config
    console.log("getPreferenceCenterConfig" + result)
})

Retrieve subscription lists

To retrieve the channel subscription lists call getChannelSubscriptionLists.

Retrieve the channel subscription lists
UAirship.getChannelSubscriptionLists(function(channelSubscriptionLists) {
    //Use the channel subscription lists
    console.log(channelSubscriptionLists)
})

To retrieve the contact subscription lists call getContactSubscriptionLists.

Retrieve the contact subscription lists
UAirship.getContactSubscriptionLists(function(contactSubscriptionLists) {
    //Use the contact subscription lists
    console.log(contactSubscriptionLists)
})

Edit the channel/contact subscription lists

To edit the channel subscription lists call editChannelSubscriptionLists.

Edit the channel subscription lists
UAirship.editChannelSubscriptionLists()
        .subscribe("food")
        .unsubscribe("test")
        .apply()

To edit the contact subscription lists call editContactSubscriptionLists.

Edit the contact subscription lists
UAirship.editContactSubscriptionLists()
        .subscribe("food", "sms")
        .unsubscribe("test", "email")
        .apply()

Override the Preference Center

If you provide your own UI, you need to listen for the open preference center event to navigate to your custom UI.

document.addEventListener("urbanairship.open_preference_center", handleOpenPreferenceCenter, false)

To make sure that the default preference center UI is not used, you have to set the setUseCustomPreferenceCenterUi to true :

UAirship.setUseCustomPreferenceCenterUi("preferenceCenterId", true)