To comply with privacy regulations such as GDPR, you can start the Pushwoosh SDK in a disabled state and only enable communication and tracking after the user gives explicit consent. This requires pushwoosh_flutter version 2.3.14 or newer (the version that added the server-communication methods).
1. Disable server communication by default
Prevent the SDK from talking to Pushwoosh servers at app start by adding a native configuration flag.
Android — in AndroidManifest.xml, inside the <application> tag:
<meta-data android:name="com.pushwoosh.allow_server_communication" android:value="false" />
iOS — in Info.plist:
- Key:
Pushwoosh_ALLOW_SERVER_COMMUNICATION - Type: Boolean
- Value: NO
2. Enable communication after consent (opt-in)
In Dart, Pushwoosh.getInstance is a getter, not a method — do not write getInstance().
// When the user opts in
// 1. Start communication with Pushwoosh servers
Pushwoosh.getInstance.startServerCommunication();
// 2. Register the device for push notifications
await Pushwoosh.getInstance.registerForPushNotifications();
3. Disable communication if consent is revoked (opt-out)
Unregister the device before stopping communication, otherwise the unregistration request never reaches Pushwoosh. unregisterForPushNotifications() returns a Future, so await it.
// When the user opts out
// 1. Unregister the device from push notifications
await Pushwoosh.getInstance.unregisterForPushNotifications();
// 2. Only then stop all communication
Pushwoosh.getInstance.stopServerCommunication();
Keeping the plugin on a current release is recommended; check pub.dev for the latest pushwoosh_flutter version.
Comments
0 comments
Please sign in to leave a comment.