To comply with privacy requirements such as GDPR, you can keep the Pushwoosh SDK completely silent until the user consents. Privacy preferences set in your main app are honoured by the Notification Service Extension (NSE) as well.
1. Disable server communication by default
Add this key to your main app target's Info.plist:
-
Key:
Pushwoosh_ALLOW_SERVER_COMMUNICATION -
Type:
Boolean -
Value:
NO(the SDK default isYES)
With this set, the SDK sends nothing to Pushwoosh servers until you explicitly turn communication on.
If you also need to stop device-attribute collection, the related keys are Pushwoosh_ALLOW_COLLECTING_DEVICE_DATA, Pushwoosh_ALLOW_COLLECTING_DEVICE_OS_VERSION, Pushwoosh_ALLOW_COLLECTING_DEVICE_LOCALE and Pushwoosh_ALLOW_COLLECTING_DEVICE_MODEL.
2. Enable communication after the user consents
// Call this after the user provides consent
Pushwoosh.sharedInstance().startServerCommunication()
Pushwoosh.sharedInstance().registerForPushNotifications()
3. Disable communication when consent is revoked
Unregistering is the critical step: once APNs stops delivering to the device, the Notification Service Extension is never invoked.
// Call this after the user revokes consent
Pushwoosh.sharedInstance().unregisterForPushNotifications { error in
if let error = error {
print("Unregister failed: \(error)")
}
Pushwoosh.sharedInstance().stopServerCommunication()
}
Note: registration, unregistration and the server-communication switches all live on the Pushwoosh singleton — Pushwoosh.sharedInstance(). Pushwoosh.configure is a different entry point (PushwooshConfig) and only exposes notification-centre delegate and authorization-option helpers such as handleWillPresentNotification(_:completionHandler:), handleNotificationResponse(_:completionHandler:) and setAdditionalAuthorizationOptions(_:); it has no registerForPushNotifications. In Swift the unregister signature is unregisterForPushNotifications(completion:) with the completion defaulting to nil, so Pushwoosh.sharedInstance().unregisterForPushNotifications() is also valid when you do not need the result.
Comments
0 comments
Please sign in to leave a comment.