0

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.

Darsshan
  • 896
  • 1
  • 11
  • 22

1 Answers1

1

You can find your resultCode like this.

your resultCode

code error list

stonemover
  • 26
  • 4
  • I can see the results code, yes, but how am I to know which acts as an access token? Is it the channelId, userId or requestId? – Darsshan Mar 13 '17 at 02:37
  • There is no access token.You just only set the api_key right. – stonemover Mar 13 '17 at 03:32
  • I set the API key and I can get notifications from console, but to send individual device notifications, you need the access token right? Isn't that what the below code is for: **PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_ACCESS_TOKEN, Utils.getMetaValue(SplashActivity.this, "api_key"));** Then what's the use of that piece of code? So you cannot get access tokens in Baidu Push? – Darsshan Mar 13 '17 at 04:46
  • I know that.The channelId is for send individual device notifications. – stonemover Mar 13 '17 at 10:21
  • Will try individual push using channelId and accept answer if it is working. – Darsshan Mar 13 '17 at 12:55
  • Is channelId individual to device or user ? Because if I login with different user i am getting same channelId and userId – Anand Mar 13 '18 at 05:36
  • @Tyson Is channelId individual to device or user ? Because if I login with different user i am getting same channelId and userId – Anand Mar 14 '18 at 05:33
  • @Tyson Is channelId individual to device or user ? Because if I login with different user i am getting same channelId and userId – Anand Mar 14 '18 at 05:34