Connect Mobile Apps to WeChat
Prerequisite
Register a WeChat Open Platform account (微信开放平台账号).
Register a Mobile Application (移动应用).
For iOS, the Associated Domains and Universal Links supports are required in your app. See the official documentation from Apple for details.
For Android, the MD5 fingerprint of the signing keystore is required
See Appendix: Create mobile app on WeChat Open Platform for more details.
WeChat login is incompatible with Passkey
Login with WeChat requires the use of WebKitWebViewUIImplementation which does not support the use of Passkey APIs. At the moment, either passkey or WeChat login can be enabled in your mobile applications.
Get the information from WeChat Open Platform
Once your mobile app is approved on the platform, you will see the word "✅已通过" in the app details page.
Get the
appid(Client ID).

Get the
appsecret(Client Secret). It will only be shown once. You need to re-generate if you lose it.

Get the
原始ID(Account ID) of your WeChat Open Platform account.

Configure Sign in with WeChat in the Authgear portal
Sign in to the Authgear portal.
Select your project.
In the navigation menu, go to Authentication > Social / Enterprise Login.
Click Add Connection.
Select WeChat Mobile / 移动应用.
Fill in Client ID with the
appid.Fill in Client Secret with the
appsecret.Fill in Account ID with the
原始ID.Add a WeChat Redirect URI. This is typically a custom URI with the scheme being your iOS bundle identifier or your Android package name. For example,
com.myapp://authgear/open_wechat_app.Save.
Integrate the WeChat SDK into your iOS app
To integrate the WeChat SDK into your iOS app, you have to read the official integration guide.
This section reminds you some of the important points that you may miss in the official integration guide.
Install the latest version of the WeChat SDK for iOS
The latest version can be found at this URL As of the time of writing, the latest version is 2.0.4.
Specify your WeChat appid in Info.plist
appid in Info.plistSpecify LSApplicationQueriesSchemes in Info.plist
In case you have other schemes, you need to make sure the WeChat ones are the first 50 items.
Make sure OTHER_LDFLAGS contains -ObjC
OTHER_LDFLAGS contains -ObjCThe WeChat SDK for iOS depends on the Objective-C runtime. Therefore, your app has to link to the Objective-C runtime. To do so, you need to make sure OTHER_LDFLAGS contains -ObjC.
The -ObjC flag is so special in CocoaPods that you CANNOT add it with CocoaPods post_install hook.
If your iOS app is written in React Native, the app is likely to have OTHER_LDFLAGS including -ObjC already, as React Native depend on the Objective-C runtime.
In other case, you need to manually edit your Build Settings to include the -ObjC flag.
Add the integration code for the WeChat SDK for iOS
In your AppDelegate.swift
In your SceneDelegate (if you have one)
In your AppDelegate.h
In your AppDelegate.m
In your SceneDelegate.m (if you have one)
Integrate the WeChat SDK into your Android app
To integrate the WeChat SDK into your Android app, you have to read the official integration guide.
This section reminds you some of the important points that you may miss in the official integration guide.
Install the latest version of the WeChat SDK for Android
The latest version can be found at this URL As of the time of writing, the latest version is 6.8.34.
Declare <queries> in your AndroidManifest.xml
<queries> in your AndroidManifest.xmlYou need to declare in your AndroidManifest.xml that your app is supposed to query the existence of the WeChat app at runtime.
Add this to your AndroidManifest.xml.
Declare your callback Activity in your AndroidManifest.xml
AndroidManifest.xmlThe WeChat SDK opens the Activity PACKAGE_NAME.wxapi.WXEntryActivity. You need to implement that Activity and declare it in your AndroidManifest.xml.
Implement the callback Activity
The full Java name of the Activity must be PACKAGE_NAME.wxapi.WXEntryActivity. If the package name you tell WeChat Open Platform is com.myapp, then the full Java name of the Activity must be com.myapp.wxapi.WXEntryActivity.
Here is an example implementation that is based on BroadcastReceiver:
Make sure your Android app is signed by the keystore you tell WeChat Open Platform
On WeChat Open Platform, you need to tell it the MD5 fingerprint of the keystore you use to sign your Android app.
If you use Google Play Console to distribute your Android app, it is likely that you are using Play App Signing. With Play App Signing, you tell Google the fingerprint of the keystore you originally sign your app. Google removes the signature and uses its managed keystore to sign the app before distributing the app to Play Store. The final app running on the device of course bears the signature of the managed keystore. This is also the signature the WeChat SDK sees when it validates the signature.
To get the MD5 fingerprint of the managed keystore, refer to the following screenshot:

Note that the MD5 fingerprint you see on Google Play Console is a colon-delimited uppercase hex string, while WeChat Open Platform expects you to provide a plain lowercase hex string.
For example, suppose the MD5 fingerprint you get from Google Play Console is D4:1D:8C:D9:8F:00:B2:04:E9:80:09:98:EC:F8:42:7E, you can use the following shell command to do the conversion.
The output d41d8cd98f00b204e9800998ecf8427e is in the expected WeChat Open Platform format.
For those of you who produce the final signature of your app using your own keystore, you can use the following shell command to output the MD5 fingerprint.
Where
STORE_FILEis an environment variable pointing to the keystore file on your machine, for example,./mykeystore.jks.STORE_PASSWORDis an environment variable containing the password of the keystore.KEY_ALIASis an environment variable indicating which key in the keystore to use.
Configure Authgear SDK for WeChat
You have 2 actions to take:
Switch to
WebKitWebViewUIImplementationwhen you initialize the Authgear SDK.Implement the callback / delegate of
WebKitWebViewUIImplementation.
Switch to WebKitWebViewUIImplementation
WebKitWebViewUIImplementationImplement the callback / delegate of WebKitWebViewUIImplementation
WebKitWebViewUIImplementationIn your AppDelegate.swift
In your MainActivity.java
In your React Native TypeScript code
In your iOS Native Module MyWeChatModule.h
In your iOS Native Module MyWeChatModule.m
In your WXApiDelegate
In your Android Native Module MyWeChatModule
In your Flutter code
In your AppDelegate.swift
In your MainActivity.kt
Appendix: Create mobile app on WeChat Open Platform
Prerequisite: A WeChat account is required for registering the app.
These information are required for creating the application on the platform, prepare them before creating the application:
Basic Information
移动应用名称
Mobile app name
The app name shown to the end-user when they login
英文名称
Mobile app name in English
The app name shown to an English end-user when they login
移动应用简介
Mobile app description
A description for the approver to understand the app
英文简介
Mobile app description in English
Optional field
应用官网
Official website of the mobile app
The webpage should show the description of the app and offer links to download it on app stores
移动应用图片
App Icon
A 28x28 and a 108x108 icon
应用市场
Is the app released on any app stores for Chinese users?
Choose between: - Unreleased: the login is rate limited to 100 per day - Released: A Chinese ICP license is required (App备案号), for example: 粤B2-00000000-0000A
应用类目
App category
Choose from the list of categories defined by the platform that best describe your app
应用运行流程图
Images of app flow
Any flowchart or screenshots showing how the app works
申请/修改应用说明
Application details
Reasons for application, any testing account and testing instruction.
管理员身份设置
Set Admin
Scan the QR code from the WeChat mobile app to prove the admin identity of the app.
App configuration
iOS
Bundle ID
测试 Bundle (Testing Bundle ID)
Universal Links
备用 Universal Links (Backup Universal Links)
Android
应用包名 (Package name)
应用签名 (App Signature)
Last updated
Was this helpful?