cordova-plugin-wechat icon indicating copy to clipboard operation
cordova-plugin-wechat copied to clipboard

Wechat auth method

Open duongduckien opened this issue 5 years ago • 10 comments

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!

duongduckien avatar Aug 24 '19 12:08 duongduckien

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 avatar Aug 24 '19 13:08 jasonz1987

Screen Shot 2019-08-25 at 1 59 48 A@jasonz1987 @jasonz1987 I have tried to add state param, but I got the same result. I can't get the response when native Wechat app pop to Ionic app. Do you have any idea? Thanks!

duongduckien avatar Aug 24 '19 19:08 duongduckien

@jasonz1987 Can you help me?

duongduckien avatar Aug 25 '19 09:08 duongduckien

@duongduckien which platform did you use? you should see debug log in android/studio console to check if there is any error.

jasonz1987 avatar Aug 26 '19 07:08 jasonz1987

@jasonz1987 I'm testing on IOS platform. I have debugged on a real device with Safari. I don't see any errors.

duongduckien avatar Aug 26 '19 09:08 duongduckien

@jasonz1987 Do you have any example with Ionic for this plugin?

duongduckien avatar Aug 26 '19 09:08 duongduckien

@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 avatar Aug 26 '19 09:08 jasonz1987

@jasonz1987 Oh, I have used ionic-plugin-deeplink and ionic-plugin-facebook in my project. I will check your solution. Thanks!

duongduckien avatar Aug 26 '19 10:08 duongduckien

Screen Shot 2019-08-26 at 5 14 03 PM @jasonz1987 How can I fix it?

duongduckien avatar Aug 26 '19 10:08 duongduckien

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.

royanon avatar Jan 22 '20 05:01 royanon