Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WeChat android api

Tags:

android

wechat

I am trying to make an Android app which communicates with WeChat app.

Followed the sample from here

But in the sample and in my own app I am able to make api calls, which is being done. For example api.sendResp(resp) results to true.

But nothing happens, while authorising I still get null token from SendAuth.Resp.

Has anyone faced this problem?

like image 517
sandris Avatar asked Mar 21 '23 11:03

sandris


2 Answers

Two things to check:

  1. is the package signature right?
  2. did the app approved?(before approved you cannot publish anything)

make sure those and you'll get it work.

good luck.

like image 171
Meng Wang Avatar answered Apr 02 '23 00:04

Meng Wang


There's much more to check than just the package signature when trying to send a message to WeChat. Below is a list of issues I found while integrating with WeChat that cause the same issue you're having:

  1. WeChat seems to break if your package name differs from your applicationId. This is probably due to the reflection used by WeChat to respond to your request. If your package name differs from what's set in WeChat, you'll transition to WeChat when an auth attempt is made but you'll never get a response. If your applicationID differs from what's in WeChat, nothing at all will happen when you request an authorization. Basically you must not use applicationId.
  2. Package name can be mixed case but what's saved in WeChat must exactly match what's in your application.
  3. The Signature hash should only be alpha numeric. Do no include other symbols like ":". Use the MD5 signature.
  4. You must have a validated WeChat app on the device (use a real phone).
  5. You must use the proper project structure. If your package name is com.test.app, you must place your activity for handling WeChat responses at com.test.app.wxapi.WXEntryActivity.
  6. You must register before attempting to get a token.
  7. Be careful with minified code (Proguard). There are articles online that mention minified code can mess up WeChat communication.
  8. You must export your WXEntryActivity in your manifest.

Working example with successful SendAuth.Resp

like image 37
aaronbruckner Avatar answered Apr 02 '23 01:04

aaronbruckner