Pushwoosh treats an email address as a separate virtual device (device type 14). The email address itself is the Hardware ID (HWID). When you call getTags() from the mobile SDK, it queries the server using the physical device's native HWID. Because of this, email-scoped tags, like the default "Unsubscribed Emails" tag, are not visible to the mobile SDK.
You can use one of two methods to get this data.
Sync status using user-centric tags
If you want to read the subscription status on the mobile app using getTags(), you can use a user-level custom tag. These tags are shared across all channels (mobile, web, and email) mapped to the same userId.
- Create a custom tag: Go to Audience > Tags in your Pushwoosh Control Panel. Create a new tag, such as
Email_Unsubscribed(Boolean), with the User-specific option enabled. - Bind profiles to a single
userId:In your mobile app, set the user ID when the user logs in:
Pushwoosh.sharedInstance().setUserId("YOUR_UNIQUE_USER_ID")On your backend, associate the email with the same user ID using
/registerEmailUser. Include"device_type": 14to prevent overriding other tags:{ "request": { "application": "YOUR_APP_CODE", "userId": "YOUR_UNIQUE_USER_ID", "email": "user@example.com", "device_type": 14 } }
Sync both tags: When you update the subscription status via
/setEmailTags, write to both the system-level "Unsubscribed Emails" tag (for delivery suppression) and your custom user-centricEmail_Unsubscribedtag:{ "request": { "application": "YOUR_APP_CODE", "email": "user@example.com", "tags": { "Unsubscribed Emails": true, "Email_Unsubscribed": true } } }- Read the tag on the device: When the device and the email share the same
userId, callinggetTags()on the mobile SDK retrieves your user-levelEmail_Unsubscribedvalue.
Query via server-to-server API
If your mobile app gets this status through your own backend, you can query the Pushwoosh API from your server. Send a request to /getTags using the email address as the hwid and specify the email device type (14):
{
"request": {
"application": "YOUR_APPLICATION_CODE",
"hwid": "user-email@example.com",
"device_type": 14
}
}
This bypasses the mobile device session and returns all tags stored on the email profile, including "Unsubscribed Emails".
Comments
0 comments
Please sign in to leave a comment.