If you are receiving 401 Unauthorized errors for Web SDK API calls like registerUser
, applicationOpen
, or setTags
after initialization (while getConfig
might work), ensure you have included the apiToken
parameter in your Pushwoosh.push(['init', {...}])
configuration.
This parameter is required for authorizing SDK requests. You can find your API Access token in your Pushwoosh Control Panel under the API Access section for your specific application.
Example Initialization:
Pushwoosh.push(['init', {
logLevel: 'debug', // Or 'error', 'warn', 'info'
applicationCode: 'YOUR_PUSHWOOSH_APP_CODE', // Replace with your actual App Code
apiToken: 'YOUR_API_ACCESS_TOKEN', // Replace with your token from Control Panel
safariWebsitePushID: 'web.your.domain.id', // Replace with your Safari Web Push ID
defaultNotificationTitle: 'Your Website Title',
defaultNotificationImage: 'https://yoursite.com/icon.png',
autoSubscribe: true,
// userId: 'OPTIONAL_USER_ID', // Optional: Set if you track users
subscribeWidget: {
enable: true
},
serviceWorkerUrl: '/service-worker.js' // Path to your service worker file
// tags: { 'TagName': 'TagValue' } // Optional: Set initial tags
}]);
Make sure to replace placeholder values like YOUR_PUSHWOOSH_APP_CODE
, YOUR_API_ACCESS_TOKEN
, web.your.domain.id
, etc., with your actual configuration details obtained from your Pushwoosh account.
Comments
0 comments
Please sign in to leave a comment.