Push Registration and Privacy Consent

Overview

This guide explains how to control push notification prompts and manage user privacy consent using Median and OneSignal. Learn how to delay registration, request explicit user consent, and comply with privacy regulations like GDPR.

Delay Push Notification Prompt at Runtime

By default, your app prompts users for push notification permission on first launch and immediately communicates with OneSignal, assigning a oneSignalUserId. Please note that this functionality is only applicable for iOS and Android 13+.

To delay this behavior:

  1. Disable automatic registration in your app configuration.
  2. Manually trigger the push prompt at runtime using the Median JavaScript Bridge.

↔️Median JavaScript Bridge

median.onesignal.register();
<a onclick="median.onesignal.register()">Enable Push Notifications</a>

Initialization vs Registration

Even if push registration is delayed, OneSignal initialization still occurs, and a oneSignalUserId is generated. To prevent this, see the next section on user privacy consent.

Require User Privacy Consent Before Initializing OneSignal

By default, your app will automatically send device data to OneSignal to initialize. This includes obtaining a oneSignalUserId which can be used to associate the device and user. To facilitate GDPR compliance, you may optionally defer sending data until consent is received from the user.

To request explicit consent from the user before any device data is sent to OneSignal, set Require user privacy consent before transmitting data to Enable in your app configuration. Then use the Median JavaScript Bridge to grant and revoke consent using the command listed below. Once consent has been granted the device will initialize with OneSignal and a oneSignalUserId will be assigned and sent to the device.

↔️Median JavaScript Bridge

Grant consent (initializes OneSignal and generates oneSignalUserId):

median.onesignal.userPrivacyConsent.grant();
<a onclick="median.onesignal.userPrivacyConsent.grant()">Consent to Push Notification Privacy Policy</a>

Revoke consent (stops future data transmission to OneSignal):

median.onesignal.userPrivacyConsent.revoke()
<a onclick="median.onesignal.userPrivacyConsent.revoke()">Revoke Push Notification Privacy Consent</a>

🚧

Revoking Consent Does Not Block Push Notifications

Revoking OneSignal privacy consent stops your app from sending additional data to OneSignal, but does not prevent receiving push notifications.

To control which users receive which notifications consider using Tags within OneSignal.