Add WeChat Login on iOS
Use the WeChat OpenSDK release selected for your iOS application. Obtain the AppID and agreed application configuration from NextAppMarket before wiring up login.
1. Configure the app identity and callbacks
Add the SDK to the app target, then apply the URL scheme, query schemes, associated-domain, and Universal Link configuration required by that release. Match the bundle identifier and callback values in the credential handoff.
Register the app with the assigned AppID and Universal Link. This Objective-C excerpt illustrates the SDK call:
#import "WXApi.h"
[WXApi registerApp:wechatAppId universalLink:wechatUniversalLink];
wechatAppId and wechatUniversalLink are configuration values for your application. Verify that the link association works on the installed build before investigating the authentication exchange.
2. Start the authorization request
Create a login attempt on your backend. Use its random, short-lived state in the request:
SendAuthReq *request = [[SendAuthReq alloc] init];
request.scope = @"snsapi_userinfo";
request.state = stateFromYourBackend;
[WXApi sendReq:request completion:^(BOOL dispatched) {
if (!dispatched) {
// Restore the login UI and let the customer choose another method.
}
}];
Keep your WXApiDelegate alive for the callback. The completion block reports request dispatch, not a signed-in user.
3. Forward callback events
Route URL callbacks to WXApi handleOpenURL:delegate: and Universal Link activities to WXApi handleOpenUniversalLink:delegate:. If your app uses scenes, wire the corresponding scene lifecycle methods as well as the app lifecycle required by your architecture. A callback must reach the same authentication coordinator regardless of how the app resumes.
In onResp:, confirm the response is a SendAuthResp. Handle errCode before using code. For an approved response, send the code and returned state to your backend. Finish sign-in only after the backend returns your application's session.
Verify the customer journey
Check the Universal Link on a real device, then test approval, cancellation, an expired login attempt, and return while the app is backgrounded. Keep an alternative sign-in path available when WeChat cannot be used.
If the app opens but login never completes, trace the callback from the lifecycle method to the SDK delegate, then to your backend. Logging a correlation ID for the attempt is enough; avoid logging the code or token.
Reference: WeChat iOS access guide. The snippets show established OpenSDK integration points; verify framework packaging and lifecycle signatures against the release you install.