-
Notifications
You must be signed in to change notification settings - Fork 0
/
WXAuthModule.m
60 lines (49 loc) · 1.6 KB
/
WXAuthModule.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// WXAuthModule.m
// WeexEros
//
// Created by mac3 on 2018/12/28.
// Copyright © 2018 benmu. All rights reserved.
//
#import "WXAuthModule.h"
#import "WXAuthManager.h"
#import <WechatOpenSDK/WXApi.h>
#import <WeexPluginLoader/WeexPluginLoader/WeexPluginLoader.h>
WX_PlUGIN_EXPORT_MODULE(WXAuth, WXAuthModule)
@interface WXAuthModule ()
@property (nonatomic, assign) BOOL WXAppIsInstall;
@end
@implementation WXAuthModule
@synthesize weexInstance;
WX_EXPORT_METHOD_SYNC(@selector(isInstallWXApp))
WX_EXPORT_METHOD_SYNC(@selector(initWX:universalLink:))
WX_EXPORT_METHOD(@selector(WXAuth:callback:))
WX_EXPORT_METHOD_SYNC(@selector(openMini:))
/** 判断是否安装了微信 */
-(BOOL)isInstallWXApp
{
dispatch_sync(dispatch_get_main_queue(), ^{
self.WXAppIsInstall = [WXApi isWXAppInstalled];
});
return self.WXAppIsInstall;
}
- (void)initWX:(NSString *)appkey universalLink:(NSString *)universalLink
{
// [WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString *log) {
// NSLog(@"WeChatSDK: %@", log);
// }];
[WXApi registerApp:appkey universalLink:universalLink];
//调用自检函数
// [WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
// NSLog(@"%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);
// }];
}
- (void)WXAuth:(NSDictionary *)info callback:(WXModuleCallback)callback
{
[[WXAuthManager shareInstance] WXAuth:info callback:callback];
}
- (void)openMini:(NSDictionary *)info
{
[[WXAuthManager shareInstance] LaunchMiniProgramReqWithId:info[@"id"] programPath:info[@"path"]];
}
@end