Registering a browser for web push notifications involves several steps handled by the Pushwoosh Web SDK once it's correctly integrated into your website:
- SDK Initialization: The process begins when the Pushwoosh Web SDK initializes on your webpage, typically via a call like
Pushwoosh.push(['init', {}])
. During this initialization, a unique Hardware ID (HWID) is generated for that specific browser instance. - Device Synchronization: The SDK then sends a
getConfig
request to Pushwoosh servers. This request synchronizes the newly generated HWID and other basic browser parameters (like browser type, version, OS) with your Pushwoosh application. At this point, the device will appear in your Pushwoosh User Explorer. However, it cannot yet receive push notifications because it doesn't have a push token. - Triggering Subscription: To get a push token, a subscription mechanism must be triggered. This can happen in a few ways:
- Displaying a default or a customizable subscription prompt (e.g., a small pop-up asking the user if they want to receive notifications).
- Using a subscription button or widget that the user clicks.
- Making a direct call to the
Pushwoosh.subscribe()
SDK method, often tied to a user action.
- Browser Permission Prompt: When
Pushwoosh.subscribe()
is executed (through any of the methods above), the browser's native permission prompt for notifications will appear, asking the user to "Allow" or "Block" notifications from your site. - Push Token Acquisition & Registration: If the user clicks "Allow," the SDK obtains a push token from the browser. It then sends a
registerDevice
request to Pushwoosh, associating this push token with the device's HWID in your user base. Once this is done, the device is fully subscribed and can receive push notifications.
How to find your device's HWID:
- Inspect SDK Requests: Open your browser's developer tools (usually by pressing F12) and go to the "Console" or "Network" tab. Look for SDK requests like
getConfig
orregisterDevice
being sent to Pushwoosh servers. The HWID is usually included in the payload or parameters of these requests (e.g.,"hwid":"YOUR_HWID_HERE"
). To see more detailed logs, you can addlogLevel: 'info'
(or'debug'
) to your SDK initialization configuration. - Use Browser Console Command: On a page where your Pushwoosh SDK is integrated, open the browser's developer console and type
Pushwoosh.getHWID()
. Press Enter, and it should return the HWID for that browser.
Comments
0 comments
Please sign in to leave a comment.