For web platforms (browsers), the Pushwoosh Web SDK simplifies device and user registration primarily through the init
call.
Initialize the SDK and Register Device/User: The
pushwoosh.push(['init', { ... }])
call handles both the SDK initialization and device registration. You can also include auserId
to associate the device with a specific user and settags
within this same call.Here's an example of the
init
call:var Pushwoosh = Pushwoosh || []; Pushwoosh.push(['init', { applicationCode: 'YOUR_PUSHWOOSH_APP_CODE', // Replace with your Application Code from Pushwoosh Control Panel apiToken: 'YOUR_API_TOKEN', // Replace with your API Access Token from Pushwoosh Control Panel (if required by your SDK version/setup) userId: 'your_custom_user_id', // Optional: Your internal User ID to identify the user tags: { // Optional: Custom tags for segmentation 'TagName': 'TagValue' } }]);
Key Parameters:
applicationCode
: (Mandatory) Your unique application identifier from the Pushwoosh Control Panel.apiToken
: (Mandatory, as per Web SDK 3.0 documentation) Your API Access Token from the Pushwoosh Control Panel.userId
: (Optional) If you provide auserId
, Pushwoosh links the device's unique Hardware ID (HWID, automatically generated by the SDK) to your custom User ID. This is useful for tracking a single user across multiple devices (e.g., their browser and a mobile app).tags
: (Optional) Allows you to assign custom key-value pairs to the user/device for segmentation purposes.
Important Considerations:
- Ensure your website is served over HTTPS, as this is a requirement for web push notifications to function correctly.
- The device (browser) will be registered with Pushwoosh after this
init
call. If auserId
is provided, it will be associated with that device. - While the device can be registered without explicit notification permission, the user will need to grant permission to receive push notifications.
By using the init
call as shown, you effectively register the device and, if userId
is included, register the user and associate them with that device in a single step for the Web SDK.
Comments
0 comments
Please sign in to leave a comment.