Search code examples
androidpush-notificationaccess-tokenbaidu

Get Access Token for Baidu Push Notification


I am trying to get the access token for Baidu Push Notification. I've done everything according to their SDK documentation and I am able to send push notifications from their console. I went through their documentation and I am using this line of code to start the service.

PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Utils.getMetaValue(SplashActivity.this, "api_key"));

there is another method that uses

 PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_ACCESS_TOKEN, Utils.getMetaValue(SplashActivity.this, "api_key"));

but I can't seem to get it to work or get the access token, probably due to a mistake in the code I am using. Could anyone guide me? I am able to get things like userId, channelId and requestId when I use the first method though, would one of these be the access token instead?

When I use the second method I get a "30603 Illegal construction request, server-side validation failed" error.

All of the guides are in Mandarin and Google Translate could only go so far. Help would be much appreciated.


Solution

  • You can find your resultCode like this.

    your resultCode

    code error list