The problem

My problem is that the App clicks wechat login to jump to wechat, and then directly jumps back to the App without confirming authorization, so there is no follow-up

The solution

I have searched official documents and forums of wechat and found that many people have this problem. The solutions I see below do not solve my problem, and my solution will be attached at last:

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler{ return [WXApi  handleOpenUniversalLink:userActivity delegate:self]; }Copy the code

This method is necessary

  • UniversalLink needs to be consistent with wechat open platform links, for example, with “/”, and Associated Domains with applinks+
  • Open the Log method startLogByLevel, open the self-checking function continueUserActivity, note that the register method should be placed in the middle of the first two methods, run the program to check the print Log
  • SendReq: Completion returns NO and prints wxlog:Error: Set Token fail, errCode:4

Still no solution

I checked whether apple-app-site-Association and Bundle Identifier support Aassociated Domains, and even updated the SDK of wechat to the latest, but it still failed until I found a solution

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler { return [[UMSocialManager defaultManager] handleUniversalLink: activity options: nil]; }Copy the code

Some people feedback that this is ok, indicating that there is a conflict between The sharing of Umeng and wechat login, but I modified it, but it still does not work. But reflect a message, will it be related to the sharing of Umeng, from the beginning to the end our code is no problem, it is umeng made the ghost. Because our app uses Umeng to share, we directly delete the previous wechat login code and use umeng to log in.

[[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_WechatSession currentViewController:nil completion:^(id result, NSError *error) {
UMSocialUserInfoResponse *resp = result;
***
}];
Copy the code

conclusion

Because the feedback from the forum of wechat is that this problem is recent, I think it should be a conflict between Umeng and wechat, wechat has not been solved, so either delete the SDK of Umeng and use wechat, or use Umeng login. Now I think it’s quite interesting. There are so many problems about this on wechat forum, the customer service said that you could solve them according to the solution I gave you. Why is it still not solved?