cordova-plugin-wechat
cordova-plugin-wechat copied to clipboard
Wechat auth method
I have used this plugin to authentication with native Wechat application. Application has redirected to native Wechat app, but I can't get any response from this function: Wechat.auth(scope, (response) => { console.log(response) }, (reason) => {}); What's the reason for this issue? Thanks!
hi,
i think you've missed the second param state
properly.
Wechat.auth(scope, state, function (response) {
// you may use response.code to get the access token.
alert(JSON.stringify(response));
}, function (reason) {
alert("Failed: " + reason);
});
``

@jasonz1987 Can you help me?
@duongduckien which platform did you use? you should see debug log in android/studio console to check if there is any error.
@jasonz1987 I'm testing on IOS platform. I have debugged on a real device with Safari. I don't see any errors.
@jasonz1987 Do you have any example with Ionic for this plugin?
@duongduckien you should check url scheme and debug openURL
method in your xcode project ,some plugins like ionic-plugin-deeplink
or ionic-plugin-facebook
will prevent openURL
method.
https://www.jason-z.com/post/85
@jasonz1987 Oh, I have used ionic-plugin-deeplink
and ionic-plugin-facebook
in my project. I will check your solution. Thanks!
@jasonz1987 How can I fix it?
As of today 2020-01-22, ionic-plugin-deeplinks has release a version of 1.0.21 which is not available in mpn, but only github. Seems to have fix it as they close jasonz's PR and release this version. However, it still doesn't work. Due to the line
// [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification object:openURLData]];
It work if unremark the first line and remark the second line. annotation is not available, so, openURLData is always empty.