From d3c2bd4fde5142fbd5546c9aadf5da44eb6af3b0 Mon Sep 17 00:00:00 2001 From: wangtao Date: Mon, 19 Jul 2021 10:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=88=E6=9D=83=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=9A=84=E6=B5=8B=E8=AF=95=E5=B0=8F=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Podfile | 4 ++-- demo.xcodeproj/project.pbxproj | 12 +++++----- demo/AppDelegate.m | 1 + demo/ViewController.m | 41 ++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Podfile b/Podfile index 4c7d13e..39b3990 100644 --- a/Podfile +++ b/Podfile @@ -4,8 +4,8 @@ platform :ios, "9.0" inhibit_all_warnings! target "demo" do - pod 'FinApplet', '2.29.1' - pod 'FinAppletExt', '2.29.1' + pod 'FinApplet' + pod 'FinAppletExt' end diff --git a/demo.xcodeproj/project.pbxproj b/demo.xcodeproj/project.pbxproj index 5cac6a7..bfb2728 100644 --- a/demo.xcodeproj/project.pbxproj +++ b/demo.xcodeproj/project.pbxproj @@ -118,7 +118,7 @@ 9DD565B523EC45080011FC4A /* Sources */, 9DD565B623EC45080011FC4A /* Frameworks */, 9DD565B723EC45080011FC4A /* Resources */, - BF23969D00C03EFEF2CAA500 /* [CP] Embed Pods Frameworks */, + D5CFBA4174EF15FFF4AA041A /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -174,21 +174,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - BF23969D00C03EFEF2CAA500 /* [CP] Embed Pods Frameworks */ = { + D5CFBA4174EF15FFF4AA041A /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-frameworks-${CONFIGURATION}-input-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-resources-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-frameworks-${CONFIGURATION}-output-files.xcfilelist", + "${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-demo/Pods-demo-resources.sh\"\n"; showEnvVarsInLog = 0; }; E71B82096235B4713AA534F8 /* [CP] Check Pods Manifest.lock */ = { diff --git a/demo/AppDelegate.m b/demo/AppDelegate.m index 6fb1c2b..dd1aba4 100644 --- a/demo/AppDelegate.m +++ b/demo/AppDelegate.m @@ -29,6 +29,7 @@ config.apiPrefix = @"/api/v1/mop"; [[FATClient sharedClient] initWithConfig:config error:nil]; + [[FATClient sharedClient] setEnableLog:YES]; [FATClient sharedClient].delegate = [FINDemoClientHelper sharedHelper]; diff --git a/demo/ViewController.m b/demo/ViewController.m index 3f47525..56875dc 100644 --- a/demo/ViewController.m +++ b/demo/ViewController.m @@ -60,6 +60,9 @@ }; [self.appletList addObject:@{@"appId":@"5fc8934aefb8c600019e9747",@"title":@"自定义H5 API示例", @"startParams":startParams}]; [self.appletList addObject:@{@"appId":@"60c5bbf99e094f00015079ee",@"title":@"原生向小程序发送事件"}]; + //登录授权示例需要原生App注入相关方法 + [self registAppletLoginApi]; + [self.appletList addObject:@{@"appId":@"60f051ea525ea10001c0bd22",@"title":@"小程序登录授权示例"}]; [self.tableView reloadData]; } @@ -75,6 +78,44 @@ } } +- (void)registAppletLoginApi { + //注入获取用户信息 + [[FATClient sharedClient]registerExtensionApi:@"getUserProfile" handle:^(id param, FATExtensionApiCallback callback) { + NSDictionary *userInfo = @{@"nickName":@"张三",@"avatarUrl":@"",@"gender":@1,@"country":@"中国",@"province":@"广东省",@"city":@"深圳",@"language":@"zh_CN"}; + NSDictionary *resDic = @{@"userInfo":userInfo}; + callback(FATExtensionCodeSuccess,resDic); + }]; + + //注入登录方法 + [[FATClient sharedClient]registerExtensionApi:@"login" handle:^(id param, FATExtensionApiCallback callback) { + //回调给小程序结果 + UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"是否同意授权登录?" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *agreeAction = [UIAlertAction actionWithTitle:@"允许" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + + callback(FATExtensionCodeSuccess,@{@"desc":@"登录成功"}); + + }]; + [alertVC addAction:agreeAction]; + UIAlertAction *refuseAction = [UIAlertAction actionWithTitle:@"拒绝" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + callback(FATExtensionCodeSuccess,@{@"desc":@"登录失败"}); + }]; + [alertVC addAction:refuseAction]; + if (self.presentedViewController) { + [self.presentedViewController presentViewController:alertVC animated:YES completion:^{ + + }]; + } else { + [self presentViewController:alertVC animated:YES completion:^{ + + }]; + } + + + + }]; + +} + #pragma mark - UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {