reformat code
This commit is contained in:
parent
8cf0f57665
commit
e22c21583f
@ -44,32 +44,32 @@
|
|||||||
|
|
||||||
-(void)loadRestoreKey:(NSString *)funid oid:(NSString *) oid{
|
-(void)loadRestoreKey:(NSString *)funid oid:(NSString *) oid{
|
||||||
NSLog(@"loadRestoreKey::funid: %@, oid:%@", funid, oid);
|
NSLog(@"loadRestoreKey::funid: %@, oid:%@", funid, oid);
|
||||||
// if ([NSThread isMainThread]) {
|
// if ([NSThread isMainThread]) {
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Tips"
|
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Tips"
|
||||||
message:@"In order to restore recovery key, please Scan QRCode or Pick from Photo Library."
|
message:@"In order to restore recovery key, please Scan QRCode or Pick from Photo Library."
|
||||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||||
UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel"
|
UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel"
|
||||||
style:UIAlertActionStyleCancel
|
style:UIAlertActionStyleCancel
|
||||||
handler: ^(UIAlertAction *action){
|
handler: ^(UIAlertAction *action){
|
||||||
NSLog(@"alert cancel pressed");
|
NSLog(@"alert cancel pressed");
|
||||||
}];
|
}];
|
||||||
|
|
||||||
UIAlertAction *scanAction = [UIAlertAction actionWithTitle:@"Scan"
|
UIAlertAction *scanAction = [UIAlertAction actionWithTitle:@"Scan"
|
||||||
style:UIAlertActionStyleDefault
|
style:UIAlertActionStyleDefault
|
||||||
handler: ^(UIAlertAction *action){
|
handler: ^(UIAlertAction *action){
|
||||||
NSLog(@"scan pressed");
|
NSLog(@"scan pressed");
|
||||||
[self scanQRCode:funid title: @"" ];
|
[self scanQRCode:funid title: @"" ];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"Photo"
|
UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"Photo"
|
||||||
style:UIAlertActionStyleDefault
|
style:UIAlertActionStyleDefault
|
||||||
handler: ^(UIAlertAction *action){
|
handler: ^(UIAlertAction *action){
|
||||||
NSLog(@"photo pressed");
|
NSLog(@"photo pressed");
|
||||||
[self openLocalPhotoAlbum];
|
[self openLocalPhotoAlbum];
|
||||||
|
|
||||||
}];
|
}];
|
||||||
[alertController addAction:actionCancel];
|
[alertController addAction:actionCancel];
|
||||||
[alertController addAction:scanAction];
|
[alertController addAction:scanAction];
|
||||||
@ -81,51 +81,51 @@
|
|||||||
-(void)startScanQRCode:(NSString *)funid title:(NSString *) title{
|
-(void)startScanQRCode:(NSString *)funid title:(NSString *) title{
|
||||||
std::string sfunid = std::string([funid UTF8String], [funid lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
std::string sfunid = std::string([funid UTF8String], [funid lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
||||||
if ([QRCodeReader supportsMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]]) {
|
if ([QRCodeReader supportsMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]]) {
|
||||||
static QRCodeReaderViewController *vc = nil;
|
static QRCodeReaderViewController *vc = nil;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
// if we are active again, we don't need to do this anymore
|
// if we are active again, we don't need to do this anymore
|
||||||
if (vc == nil) {
|
if (vc == nil) {
|
||||||
QRCodeReader *reader = [QRCodeReader readerWithMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]];
|
QRCodeReader *reader = [QRCodeReader readerWithMetadataObjectTypes:@[AVMetadataObjectTypeQRCode]];
|
||||||
vc = [QRCodeReaderViewController readerWithCancelButtonTitle:@"Cancel" codeReader:reader startScanningAtLoad:YES showSwitchCameraButton:YES showTorchButton:YES];
|
vc = [QRCodeReaderViewController readerWithCancelButtonTitle:@"Cancel" codeReader:reader startScanningAtLoad:YES showSwitchCameraButton:YES showTorchButton:YES];
|
||||||
vc.modalPresentationStyle = UIModalPresentationFormSheet;
|
vc.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
[vc setCompletionWithBlock:^(NSString *resultAsString) {
|
||||||
|
NSLog(@"Completion with result: %@", resultAsString);
|
||||||
|
[self dismissViewControllerAnimated:YES completion:^{
|
||||||
|
|
||||||
|
NSString *result;
|
||||||
|
if (resultAsString.length > 0) {
|
||||||
|
result = [NSString stringWithFormat:@"{errcode: 0, data: '%@'}", resultAsString];
|
||||||
|
} else {
|
||||||
|
result = [NSString stringWithFormat:@"{errcode: 1, errmsg: 'cancel'}"];
|
||||||
}
|
}
|
||||||
|
std::string sresult = std::string([result UTF8String], [result lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
||||||
[vc setCompletionWithBlock:^(NSString *resultAsString) {
|
// WalletEvent::Emit(sfunid.c_str(), sresult.c_str());
|
||||||
NSLog(@"Completion with result: %@", resultAsString);
|
}];
|
||||||
[self dismissViewControllerAnimated:YES completion:^{
|
}];
|
||||||
|
[self presentViewController:vc animated:YES completion:NULL];
|
||||||
NSString *result;
|
});
|
||||||
if (resultAsString.length > 0) {
|
|
||||||
result = [NSString stringWithFormat:@"{errcode: 0, data: '%@'}", resultAsString];
|
|
||||||
} else {
|
|
||||||
result = [NSString stringWithFormat:@"{errcode: 1, errmsg: 'cancel'}"];
|
|
||||||
}
|
|
||||||
std::string sresult = std::string([result UTF8String], [result lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
|
||||||
// WalletEvent::Emit(sfunid.c_str(), sresult.c_str());
|
|
||||||
}];
|
|
||||||
}];
|
|
||||||
[self presentViewController:vc animated:YES completion:NULL];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)scanQRCode:(NSString *)funid title:(NSString *) title{
|
-(void)scanQRCode:(NSString *)funid title:(NSString *) title{
|
||||||
NSLog(@"scanQRCode:: funId: %@ title: %@", funid, title);
|
NSLog(@"scanQRCode:: funId: %@ title: %@", funid, title);
|
||||||
// [self openLocalPhotoAlbum];
|
// [self openLocalPhotoAlbum];
|
||||||
// [self signWithApple];
|
// [self signWithApple];
|
||||||
|
|
||||||
|
|
||||||
__weak __typeof(self) weakSelf = self;
|
__weak __typeof(self) weakSelf = self;
|
||||||
[LBXPermission authorizeWithType:LBXPermissionType_Camera completion:^(BOOL granted, BOOL firstTime) {
|
[LBXPermission authorizeWithType:LBXPermissionType_Camera completion:^(BOOL granted, BOOL firstTime) {
|
||||||
if (granted) {
|
if (granted) {
|
||||||
[weakSelf startScanQRCode:funid title:title];
|
[weakSelf startScanQRCode:funid title:title];
|
||||||
}
|
}
|
||||||
else if(!firstTime)
|
else if(!firstTime)
|
||||||
{
|
{
|
||||||
[LBXPermissionSetting showAlertToDislayPrivacySettingWithTitle:@"Error" msg:@"The camera is need to scan QR codes" cancel:@"Cancel" setting:@"Setting" ];
|
[LBXPermissionSetting showAlertToDislayPrivacySettingWithTitle:@"Error" msg:@"The camera is need to scan QR codes" cancel:@"Cancel" setting:@"Setting" ];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,13 +135,13 @@
|
|||||||
__weak __typeof(self) weakSelf = self;
|
__weak __typeof(self) weakSelf = self;
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[LBXPermission authorizeWithType:LBXPermissionType_Photos completion:^(BOOL granted, BOOL firstTime) {
|
[LBXPermission authorizeWithType:LBXPermissionType_Photos completion:^(BOOL granted, BOOL firstTime) {
|
||||||
if (granted) {
|
if (granted) {
|
||||||
[weakSelf openLocalPhoto];
|
[weakSelf openLocalPhoto];
|
||||||
}
|
}
|
||||||
else if (!firstTime )
|
else if (!firstTime )
|
||||||
{
|
{
|
||||||
[LBXPermissionSetting showAlertToDislayPrivacySettingWithTitle:@"Error" msg:@"The Photo Library is need to restore recovery key." cancel:@"Cancel" setting:@"Setting"];
|
[LBXPermissionSetting showAlertToDislayPrivacySettingWithTitle:@"Error" msg:@"The Photo Library is need to restore recovery key." cancel:@"Cancel" setting:@"Setting"];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -160,16 +160,16 @@
|
|||||||
|
|
||||||
// crash on some mobile
|
// crash on some mobile
|
||||||
picker.allowsEditing = NO;
|
picker.allowsEditing = NO;
|
||||||
|
|
||||||
[self presentViewController:picker animated:YES completion:nil];
|
[self presentViewController:picker animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
#pragma mark- - UIImagePickerControllerDelegate
|
#pragma mark- - UIImagePickerControllerDelegate
|
||||||
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
|
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||||
{
|
{
|
||||||
[picker dismissViewControllerAnimated:YES completion:^{
|
[picker dismissViewControllerAnimated:YES completion:^{
|
||||||
|
|
||||||
[self handPhotoDidFinishPickingMediaWithInfo:info];
|
[self handPhotoDidFinishPickingMediaWithInfo:info];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handPhotoDidFinishPickingMediaWithInfo:(NSDictionary *)info
|
- (void)handPhotoDidFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||||
@ -177,13 +177,13 @@
|
|||||||
__block UIImage* image = [info objectForKey:UIImagePickerControllerEditedImage];
|
__block UIImage* image = [info objectForKey:UIImagePickerControllerEditedImage];
|
||||||
|
|
||||||
if (!image){
|
if (!image){
|
||||||
image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
||||||
}
|
}
|
||||||
if (@available(iOS 8.0, *)) {
|
if (@available(iOS 8.0, *)) {
|
||||||
__weak __typeof(self) weakSelf = self;
|
__weak __typeof(self) weakSelf = self;
|
||||||
[LBXScanNative recognizeImage:image success:^(NSArray<LBXScanResult *> *array) {
|
[LBXScanNative recognizeImage:image success:^(NSArray<LBXScanResult *> *array) {
|
||||||
[weakSelf scanResultWithArray:array];
|
[weakSelf scanResultWithArray:array];
|
||||||
}];
|
}];
|
||||||
}else{
|
}else{
|
||||||
NSLog(@"native低于ios8.0不支持识别图片");
|
NSLog(@"native低于ios8.0不支持识别图片");
|
||||||
}
|
}
|
||||||
@ -191,22 +191,22 @@
|
|||||||
|
|
||||||
- (void)scanResultWithArray:(NSArray<LBXScanResult*>*)array
|
- (void)scanResultWithArray:(NSArray<LBXScanResult*>*)array
|
||||||
{
|
{
|
||||||
if (!array || array.count < 1)
|
if (!array || array.count < 1)
|
||||||
{
|
{
|
||||||
NSLog(@"error scan photo");
|
NSLog(@"error scan photo");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (LBXScanResult *result in array) {
|
for (LBXScanResult *result in array) {
|
||||||
NSLog(@"scanResult:%@",result.strScanned);
|
NSLog(@"scanResult:%@",result.strScanned);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array[0].strScanned || [array[0].strScanned isEqualToString:@""] ) {
|
if (!array[0].strScanned || [array[0].strScanned isEqualToString:@""] ) {
|
||||||
NSLog(@"识别失败了");
|
NSLog(@"识别失败了");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LBXScanResult *scanResult = array[0];
|
LBXScanResult *scanResult = array[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -25,8 +25,8 @@ static NSString * const kClientID =
|
|||||||
@implementation UIViewController (Wallet)
|
@implementation UIViewController (Wallet)
|
||||||
|
|
||||||
+(void)toWallet:(NSString *)url{
|
+(void)toWallet:(NSString *)url{
|
||||||
UIApplication *app = [UIApplication sharedApplication];
|
UIApplication *app = [UIApplication sharedApplication];
|
||||||
[app openURL:[NSURL URLWithString:url]];
|
[app openURL:[NSURL URLWithString:url]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,74 +45,74 @@ static NSString * const kClientID =
|
|||||||
|
|
||||||
|
|
||||||
-(void)signToGoogle:(NSString *) funid {
|
-(void)signToGoogle:(NSString *) funid {
|
||||||
GIDConfiguration *_configuration = [[GIDConfiguration alloc] initWithClientID:kClientID];
|
GIDConfiguration *_configuration = [[GIDConfiguration alloc] initWithClientID:kClientID];
|
||||||
[GIDSignIn.sharedInstance signInWithConfiguration:_configuration
|
[GIDSignIn.sharedInstance signInWithConfiguration:_configuration
|
||||||
presentingViewController:self
|
presentingViewController:self
|
||||||
completion:^(GIDGoogleUser *user, NSError *error) {
|
completion:^(GIDGoogleUser *user, NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Status: Authentication error: %@", error);
|
NSLog(@"Status: Authentication error: %@", error);
|
||||||
}
|
}
|
||||||
[self refreshUserInfo];
|
[self refreshUserInfo];
|
||||||
[self refreshTokenID: user funid:funid];
|
[self refreshTokenID: user funid:funid];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
-(void) refreshTokenID:(GIDGoogleUser *)user funid:(NSString*) funid{
|
-(void) refreshTokenID:(GIDGoogleUser *)user funid:(NSString*) funid{
|
||||||
[user.authentication doWithFreshTokens:^(GIDAuthentication * _Nullable authentication,
|
[user.authentication doWithFreshTokens:^(GIDAuthentication * _Nullable authentication,
|
||||||
NSError * _Nullable error) {
|
NSError * _Nullable error) {
|
||||||
if (error) { return; }
|
if (error) { return; }
|
||||||
if (authentication == nil) { return; }
|
if (authentication == nil) { return; }
|
||||||
|
|
||||||
NSString *idToken = authentication.idToken;
|
NSString *idToken = authentication.idToken;
|
||||||
// Send ID token to backend (example below).
|
// Send ID token to backend (example below).
|
||||||
NSLog(@"idToken: %@", idToken);
|
NSLog(@"idToken: %@", idToken);
|
||||||
std::string methodName = "nativeCallBack";
|
std::string methodName = "nativeCallBack";
|
||||||
NSString *paramStr = [NSString stringWithFormat:@"{\"errcode\": 0, \"data\": \"%@\"}", idToken];
|
NSString *paramStr = [NSString stringWithFormat:@"{\"errcode\": 0, \"data\": \"%@\"}", idToken];
|
||||||
std::string sfunid = std::string([funid UTF8String], [funid lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
std::string sfunid = std::string([funid UTF8String], [funid lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
||||||
std::string sparam = std::string([paramStr UTF8String], [paramStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
std::string sparam = std::string([paramStr UTF8String], [paramStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
||||||
cocos2d::nativeCallBack(sfunid.c_str(), methodName.c_str(), sparam.c_str());
|
cocos2d::nativeCallBack(sfunid.c_str(), methodName.c_str(), sparam.c_str());
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)signWithGoogle:(NSString *)funid {
|
-(void)signWithGoogle:(NSString *)funid {
|
||||||
[GIDSignIn.sharedInstance restorePreviousSignInWithCompletion:^(GIDGoogleUser * _Nullable user,
|
[GIDSignIn.sharedInstance restorePreviousSignInWithCompletion:^(GIDGoogleUser * _Nullable user,
|
||||||
NSError * _Nullable error) {
|
NSError * _Nullable error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
// Show the app's signed-out state.
|
// Show the app's signed-out state.
|
||||||
[self signToGoogle: funid];
|
[self signToGoogle: funid];
|
||||||
} else {
|
} else {
|
||||||
// Show the app's signed-in state.
|
// Show the app's signed-in state.
|
||||||
[self refreshTokenID: user funid:funid];
|
[self refreshTokenID: user funid:funid];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)signOutGoogle:(NSString *)funid {
|
-(void)signOutGoogle:(NSString *)funid {
|
||||||
[GIDSignIn.sharedInstance signOut];
|
[GIDSignIn.sharedInstance signOut];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reportAuthStatus {
|
- (void)reportAuthStatus {
|
||||||
GIDGoogleUser *googleUser = [GIDSignIn.sharedInstance currentUser];
|
GIDGoogleUser *googleUser = [GIDSignIn.sharedInstance currentUser];
|
||||||
if (googleUser.authentication) {
|
if (googleUser.authentication) {
|
||||||
NSLog(@"Status: Authenticated");
|
NSLog(@"Status: Authenticated");
|
||||||
} else {
|
} else {
|
||||||
// To authenticate, use Google Sign-In button.
|
// To authenticate, use Google Sign-In button.
|
||||||
NSLog(@"Status: Not authenticated");
|
NSLog(@"Status: Not authenticated");
|
||||||
}
|
}
|
||||||
|
|
||||||
[self refreshUserInfo];
|
[self refreshUserInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)refreshUserInfo {
|
- (void)refreshUserInfo {
|
||||||
if (GIDSignIn.sharedInstance.currentUser.authentication == nil) {
|
if (GIDSignIn.sharedInstance.currentUser.authentication == nil) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NSLog(@"email: %@", GIDSignIn.sharedInstance.currentUser.profile.email);
|
NSLog(@"email: %@", GIDSignIn.sharedInstance.currentUser.profile.email);
|
||||||
NSLog(@"username: %@", GIDSignIn.sharedInstance.currentUser.profile.name);
|
NSLog(@"username: %@", GIDSignIn.sharedInstance.currentUser.profile.name);
|
||||||
NSLog(@"userid: %@", GIDSignIn.sharedInstance.currentUser.userID);
|
NSLog(@"userid: %@", GIDSignIn.sharedInstance.currentUser.userID);
|
||||||
NSLog(@"givenName: %@", GIDSignIn.sharedInstance.currentUser.profile.givenName);
|
NSLog(@"givenName: %@", GIDSignIn.sharedInstance.currentUser.profile.givenName);
|
||||||
NSLog(@"familyName: %@", GIDSignIn.sharedInstance.currentUser.profile.familyName);
|
NSLog(@"familyName: %@", GIDSignIn.sharedInstance.currentUser.profile.familyName);
|
||||||
NSLog(@"hostedDomain: %@", GIDSignIn.sharedInstance.currentUser.hostedDomain);
|
NSLog(@"hostedDomain: %@", GIDSignIn.sharedInstance.currentUser.hostedDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark- - Sign In With Apple
|
#pragma mark- - Sign In With Apple
|
||||||
@ -130,63 +130,63 @@ static NSString * const kClientID =
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {
|
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {
|
||||||
if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) {
|
if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) {
|
||||||
// 用户登录使用ASAuthorizationAppleIDCredential
|
// 用户登录使用ASAuthorizationAppleIDCredential
|
||||||
ASAuthorizationAppleIDCredential *credential = authorization.credential;
|
ASAuthorizationAppleIDCredential *credential = authorization.credential;
|
||||||
NSString *user = credential.user;
|
NSString *user = credential.user;
|
||||||
NSData *identityToken = credential.identityToken;
|
NSData *identityToken = credential.identityToken;
|
||||||
NSLog(@"fullName - %@",credential.fullName);
|
NSLog(@"fullName - %@",credential.fullName);
|
||||||
//授权成功后,你可以拿到苹果返回的全部数据,根据需要和后台交互。
|
//授权成功后,你可以拿到苹果返回的全部数据,根据需要和后台交互。
|
||||||
NSLog(@"user - %@ %@",user,identityToken);
|
NSLog(@"user - %@ %@",user,identityToken);
|
||||||
//保存apple返回的唯一标识符
|
//保存apple返回的唯一标识符
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:user forKey:@"userIdentifier"];
|
[[NSUserDefaults standardUserDefaults] setObject:user forKey:@"userIdentifier"];
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
} else if ([authorization.credential isKindOfClass:[ASPasswordCredential class]]) {
|
} else if ([authorization.credential isKindOfClass:[ASPasswordCredential class]]) {
|
||||||
// 用户登录使用现有的密码凭证
|
// 用户登录使用现有的密码凭证
|
||||||
ASPasswordCredential *psdCredential = authorization.credential;
|
ASPasswordCredential *psdCredential = authorization.credential;
|
||||||
// 密码凭证对象的用户标识 用户的唯一标识
|
// 密码凭证对象的用户标识 用户的唯一标识
|
||||||
NSString *user = psdCredential.user;
|
NSString *user = psdCredential.user;
|
||||||
NSString *psd = psdCredential.password;
|
NSString *psd = psdCredential.password;
|
||||||
NSLog(@"psduser - %@ %@",psd,user);
|
NSLog(@"psduser - %@ %@",psd,user);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"授权信息不符");
|
NSLog(@"授权信息不符");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - 授权回调失败
|
#pragma mark - 授权回调失败
|
||||||
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(ios(13.0)){
|
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(ios(13.0)){
|
||||||
|
|
||||||
NSLog(@"错误信息:%@", error);
|
NSLog(@"错误信息:%@", error);
|
||||||
NSString *errorMsg;
|
NSString *errorMsg;
|
||||||
switch (error.code) {
|
switch (error.code) {
|
||||||
case ASAuthorizationErrorCanceled:
|
case ASAuthorizationErrorCanceled:
|
||||||
errorMsg = @"用户取消了授权请求";
|
errorMsg = @"用户取消了授权请求";
|
||||||
NSLog(@"errorMsg - %@",errorMsg);
|
NSLog(@"errorMsg - %@",errorMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASAuthorizationErrorFailed:
|
case ASAuthorizationErrorFailed:
|
||||||
errorMsg = @"授权请求失败";
|
errorMsg = @"授权请求失败";
|
||||||
NSLog(@"errorMsg - %@",errorMsg);
|
NSLog(@"errorMsg - %@",errorMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASAuthorizationErrorInvalidResponse:
|
case ASAuthorizationErrorInvalidResponse:
|
||||||
errorMsg = @"授权请求响应无效";
|
errorMsg = @"授权请求响应无效";
|
||||||
NSLog(@"errorMsg - %@",errorMsg);
|
NSLog(@"errorMsg - %@",errorMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASAuthorizationErrorNotHandled:
|
case ASAuthorizationErrorNotHandled:
|
||||||
errorMsg = @"未能处理授权请求";
|
errorMsg = @"未能处理授权请求";
|
||||||
NSLog(@"errorMsg - %@",errorMsg);
|
NSLog(@"errorMsg - %@",errorMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASAuthorizationErrorUnknown:
|
case ASAuthorizationErrorUnknown:
|
||||||
errorMsg = @"授权请求失败未知原因";
|
errorMsg = @"授权请求失败未知原因";
|
||||||
NSLog(@"errorMsg - %@",errorMsg);
|
NSLog(@"errorMsg - %@",errorMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user