Managing user consent
Pushwoosh supports compliance with privacy regulations (e.g., GDPR, CCPA) by allowing developers to control when the SDK begins communication with Pushwoosh servers. This allows to ensure that no data is collected before the user gives explicit consent.
Overview
Anchor link toBy default, the Pushwoosh SDK begins communication and collecting device data immediately upon initialization. However, you can change this behavior so that no communication happens until the user gives consent.
With this setup:
If the user gives consent, the SDK initializes and begins collecting data.
If the user does not give consent, the SDK stays inactive and does not collect any data.
If the user later withdraws consent, the SDK stops all activity and disconnects from the servers.
Pushwoosh provides mechanisms to manage this flow in iOS, Android, and Unity.
Disable SDK server communication at startup
Anchor link toBy default, the communication with the SDK is enabled. To disable all communication with Pushwoosh servers until consent is explicitly granted by the user, add the following key to your Info.plist
:
<key>Pushwoosh_ALLOW_SERVER_COMMUNICATION</key><false/>
Check communication status
Anchor link toUse the following methods to determine if communication is currently allowed:
import SwiftUIimport PushwooshFramework
var serverCommunicationAllowed = PWCoreServerCommunicationManager.sharedInstance.isServerCommunicationAllowedprint("isServerCommunicationAllowed: ", serverCommunicationAllowed)
import PushwooshFramework
var serverCommunicationAllowed = PWCoreServerCommunicationManager.sharedInstance.isServerCommunicationAllowedprint("isServerCommunicationAllowed: ", serverCommunicationAllowed)
#import <PushwooshFramework/PushwooshFramework.h>
BOOL serverCommunicationAllowed = [PWCoreServerCommunicationManager sharedInstance].isServerCommunicationAllowed;NSLog(@"isServerCommunicationAllowed: %d", serverCommunicationAllowed);
Enable SDK communication after consent
Anchor link toOnce the user has granted consent, enable communication as follows:
import SwiftUIimport PushwooshFramework
Pushwoosh.sharedInstance().startServerCommunication()
import PushwooshFramework
Pushwoosh.sharedInstance().startServerCommunication()
#import <PushwooshFramework/PushwooshFramework.h>
[[Pushwoosh sharedInstance] startServerCommunication];
Register for push notifications
Anchor link toOnce communication is enabled, explicitly register for push notifications:
import SwiftUIimport PushwooshFramework
Pushwoosh.sharedInstance().registerForPushNotifications()
import PushwooshFramework
Pushwoosh.sharedInstance().registerForPushNotifications()
#import <PushwooshFramework/PushwooshFramework.h>
[[Pushwoosh sharedInstance] registerForPushNotifications];
Disable communication
Anchor link toTo stop communication with Pushwoosh servers (e.g., if the user revokes consent):
import SwiftUIimport PushwooshFramework
Pushwoosh.sharedInstance().stopServerCommunication()
import PushwooshFramework
Pushwoosh.sharedInstance().stopServerCommunication()
#import <PushwooshFramework/PushwooshFramework.h>
[[Pushwoosh sharedInstance] stopServerCommunication];
Android
Anchor link toDisable SDK server communication at startup
Anchor link toBy default, communication is enabled. To prevent any data from being sent to Pushwoosh servers until user consent is obtained, add the following to your AndroidManifest.xml
:
<meta-data android:name="com.pushwoosh.allow_server_communication" android:value="false" />
Check communication status
Anchor link toUse the following methods to determine if server communication is currently allowed:
import com.pushwoosh.Pushwoosh;
boolean isCommunicationEnabled = Pushwoosh.getInstance().isServerCommunicationAllowed();Log.d("Pushwoosh", "Communication enabled = " + isCommunicationEnabled);
import com.pushwoosh.Pushwoosh
val isCommunicationEnabled = Pushwoosh.getInstance().isServerCommunicationAllowed()Log.d("Pushwoosh", "Communication enabled = $isCommunicationEnabled")
Enable SDK communication after consent
Anchor link toOnce the user has granted consent, enable communication as follows:
import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().startServerCommunication();
import com.pushwoosh.Pushwoosh
Pushwoosh.getInstance().startServerCommunication()
Register for push notifications
Anchor link toAfter communication is enabled, explicitly register for push notifications:
import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().registerForPushNotifications();
import com.pushwoosh.Pushwoosh
Pushwoosh.getInstance().registerForPushNotifications()
Disable communication
Anchor link toTo stop communication with Pushwoosh servers (e.g., if the user revokes consent):
import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().stopServerCommunication();
import com.pushwoosh.Pushwoosh
Pushwoosh.getInstance().stopServerCommunication()
Unity
Anchor link toDisable SDK server communication at startup
Anchor link toBy default, the communication with the SDK is enabled. To disable all communication with Pushwoosh servers until consent is explicitly granted by the user, apply platform-specific settings:
Android
Add the following to your Unity project at AndroidManifest.xml
:
<meta-data android:name="com.pushwoosh.allow_server_communication" android:value="false" />
iOS
Modify Info.plist
:
<key>Pushwoosh_ALLOW_SERVER_COMMUNICATION</key><false/>
Note: You must enable communication before calling RegisterForPushNotifications
.
Check communication status
Anchor link toUse the following method to check whether server communication is currently allowed:
bool enabled = Pushwoosh.Instance.IsCommunicationEnabled();
Enable SDK communication after consent
Anchor link toTo enable communication after consent:
Pushwoosh.Instance.SetCommunicationEnabled(true);
Register for push notifications
Anchor link toOnce communication is enabled, you can register the device for push notifications:
Pushwoosh.Instance.RegisterForPushNotifications();
Disable communication
Anchor link toTo stop communication with Pushwoosh servers (e.g., if the user revokes consent):
Pushwoosh.Instance.SetCommunicationEnabled(false);
Web Push
Anchor link toDisable automatic subscription at startup
Anchor link toBy default, the Pushwoosh SDK shows the native subscription prompt as soon as it is initialized. To prevent the SDK from automatically showing the subscription prompt upon initialization, set the communicationEnabled
parameter to false
in the init
call.
<script type="text/javascript" src="//cdn.pushwoosh.com/webpush/v3/pushwoosh-web-notifications.js" async></script><script type="text/javascript"> var Pushwoosh = Pushwoosh || []; Pushwoosh.push(['init', { // other initialization parameters... communicationEnabled: false, // Disable communication to prevent automatic subscription prompts }]);</script>
Enable subscription after consent
Anchor link toOnce you have disabled automatic subscription, you can prompt the user to subscribe at any time. When the user agrees to receive push notifications (e.g., by clicking a “Subscribe” button on your custom UI), you can enable communication by calling the setCommunicationEnabled
method. Calling Pushwoosh.setCommunicationEnabled(true)
enables communication with Pushwoosh services. Once enabled, the SDK will proceed to show the native browser permission prompt.
Pushwoosh.setCommunicationEnabled(true) .then(() => { console.log('User is subscribed to push notifications.'); }) .catch((error) => { console.error('Error subscribing user:', error); });
Disable communication
Anchor link toTo stop communication with Pushwoosh services (e.g., if the user revokes consent), call setCommunicationEnabled
with false
.
Pushwoosh.setCommunicationEnabled(false);