Skip to content

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.

By 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 to

By 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 to

Use the following methods to determine if communication is currently allowed:

import SwiftUI
import PushwooshFramework
var serverCommunicationAllowed = PWCoreServerCommunicationManager.sharedInstance.isServerCommunicationAllowed
print("isServerCommunicationAllowed: ", serverCommunicationAllowed)
Anchor link to

Once the user has granted consent, enable communication as follows:

import SwiftUI
import PushwooshFramework
Pushwoosh.sharedInstance().startServerCommunication()

Register for push notifications

Anchor link to

Once communication is enabled, explicitly register for push notifications:

import SwiftUI
import PushwooshFramework
Pushwoosh.sharedInstance().registerForPushNotifications()

Disable communication

Anchor link to

To stop communication with Pushwoosh servers (e.g., if the user revokes consent):

import SwiftUI
import PushwooshFramework
Pushwoosh.sharedInstance().stopServerCommunication()

Disable SDK server communication at startup

Anchor link to

By 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 to

Use 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);
Anchor link to

Once the user has granted consent, enable communication as follows:

import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().startServerCommunication();

Register for push notifications

Anchor link to

After communication is enabled, explicitly register for push notifications:

import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().registerForPushNotifications();

Disable communication

Anchor link to

To stop communication with Pushwoosh servers (e.g., if the user revokes consent):

import com.pushwoosh.Pushwoosh;
Pushwoosh.getInstance().stopServerCommunication();

Disable SDK server communication at startup

Anchor link to

By 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 to

Use the following method to check whether server communication is currently allowed:

bool enabled = Pushwoosh.Instance.IsCommunicationEnabled();
Anchor link to

To enable communication after consent:

Pushwoosh.Instance.SetCommunicationEnabled(true);

Register for push notifications

Anchor link to

Once communication is enabled, you can register the device for push notifications:

Pushwoosh.Instance.RegisterForPushNotifications();

Disable communication

Anchor link to

To stop communication with Pushwoosh servers (e.g., if the user revokes consent):

Pushwoosh.Instance.SetCommunicationEnabled(false);

Disable automatic subscription at startup

Anchor link to

By 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>
Anchor link to

Once 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 to

To stop communication with Pushwoosh services (e.g., if the user revokes consent), call setCommunicationEnabled with false.

Pushwoosh.setCommunicationEnabled(false);