If your app logs a 401 Unauthorized during device registration and no subscribers appear in the Control Panel, the SDK's requests are not being authorised. The usual cause is a missing or mis-scoped Device API token in your native configuration.
1. Get your Device API token
In the Pushwoosh Control Panel go to Settings → API Access. API Access tokens are managed at account level; each token is then granted access to specific applications. Copy the value of a token of type Device (a Server token will not work for Device API calls).
2. Add the token to your app
Android
Add this <meta-data> tag inside the <application> tag of AndroidManifest.xml:
<application>
...
<meta-data
android:name="com.pushwoosh.apitoken"
android:value="YOUR_DEVICE_API_TOKEN" />
...
</application>
iOS
Add this key to Info.plist:
<key>Pushwoosh_API_TOKEN</key>
<string>YOUR_DEVICE_API_TOKEN</string>
3. Check the token's application access
This is the step most often missed. A valid token still returns 401 if it has not been granted access to the application code your app initialises with. In Settings → API Access, open the three-dot menu (⋮) next to the token and confirm the target application is included in its permissions.
4. Rebuild and retest
Rebuild the app after changing the manifest or plist — these values are read at build time. New installations should then register without a 401. If the error persists, verify that the application code in your app matches the application the token is scoped to.
Comments
0 comments
Please sign in to leave a comment.