增加授权登录的测试小程序
parent
02c2e68c1c
commit
d3c2bd4fde
4
Podfile
4
Podfile
|
@ -4,8 +4,8 @@ platform :ios, "9.0"
|
||||||
inhibit_all_warnings!
|
inhibit_all_warnings!
|
||||||
|
|
||||||
target "demo" do
|
target "demo" do
|
||||||
pod 'FinApplet', '2.29.1'
|
pod 'FinApplet'
|
||||||
pod 'FinAppletExt', '2.29.1'
|
pod 'FinAppletExt'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
9DD565B523EC45080011FC4A /* Sources */,
|
9DD565B523EC45080011FC4A /* Sources */,
|
||||||
9DD565B623EC45080011FC4A /* Frameworks */,
|
9DD565B623EC45080011FC4A /* Frameworks */,
|
||||||
9DD565B723EC45080011FC4A /* Resources */,
|
9DD565B723EC45080011FC4A /* Resources */,
|
||||||
BF23969D00C03EFEF2CAA500 /* [CP] Embed Pods Frameworks */,
|
D5CFBA4174EF15FFF4AA041A /* [CP] Copy Pods Resources */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
|
@ -174,21 +174,21 @@
|
||||||
/* End PBXResourcesBuildPhase section */
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXShellScriptBuildPhase section */
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
BF23969D00C03EFEF2CAA500 /* [CP] Embed Pods Frameworks */ = {
|
D5CFBA4174EF15FFF4AA041A /* [CP] Copy Pods Resources */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputFileListPaths = (
|
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 = (
|
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;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
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;
|
showEnvVarsInLog = 0;
|
||||||
};
|
};
|
||||||
E71B82096235B4713AA534F8 /* [CP] Check Pods Manifest.lock */ = {
|
E71B82096235B4713AA534F8 /* [CP] Check Pods Manifest.lock */ = {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
config.apiPrefix = @"/api/v1/mop";
|
config.apiPrefix = @"/api/v1/mop";
|
||||||
|
|
||||||
[[FATClient sharedClient] initWithConfig:config error:nil];
|
[[FATClient sharedClient] initWithConfig:config error:nil];
|
||||||
|
[[FATClient sharedClient] setEnableLog:YES];
|
||||||
|
|
||||||
[FATClient sharedClient].delegate = [FINDemoClientHelper sharedHelper];
|
[FATClient sharedClient].delegate = [FINDemoClientHelper sharedHelper];
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,9 @@
|
||||||
};
|
};
|
||||||
[self.appletList addObject:@{@"appId":@"5fc8934aefb8c600019e9747",@"title":@"自定义H5 API示例", @"startParams":startParams}];
|
[self.appletList addObject:@{@"appId":@"5fc8934aefb8c600019e9747",@"title":@"自定义H5 API示例", @"startParams":startParams}];
|
||||||
[self.appletList addObject:@{@"appId":@"60c5bbf99e094f00015079ee",@"title":@"原生向小程序发送事件"}];
|
[self.appletList addObject:@{@"appId":@"60c5bbf99e094f00015079ee",@"title":@"原生向小程序发送事件"}];
|
||||||
|
//登录授权示例需要原生App注入相关方法
|
||||||
|
[self registAppletLoginApi];
|
||||||
|
[self.appletList addObject:@{@"appId":@"60f051ea525ea10001c0bd22",@"title":@"小程序登录授权示例"}];
|
||||||
[self.tableView reloadData];
|
[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
|
#pragma mark - UITableViewDataSource
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue