// // RQDouYinManager.m // jiaPei // // Created by 张嵘 on 2022/5/12. // Copyright © 2022 JCZ. All rights reserved. // #import "RQDouYinManager.h" #import @interface RQDouYinManager() @property (nonatomic, readwrite, strong) NSString *clientKey; @property (nonatomic, readwrite, strong) NSString *clientSecret; @end @implementation RQDouYinManager @def_singleton(RQDouYinManager); #pragma mark - PublicMethods - (NSString *)clientKey { return @"awbewr7xlianfnew"; } - (NSString *)clientSecret { return @"dd979dc2a5ddcc0c761fcbe899d87ba1"; } /// 初始化 - (void)initDouYinManagerWithApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { dispatch_async_on_main_queue(^{ [[DouyinOpenSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; [DouyinOpenSDKApplicationDelegate sharedInstance].logDelegate = self; }); } /// 调起登录 - (void)douyinLogin { DouyinOpenSDKAuthRequest *request = [[DouyinOpenSDKAuthRequest alloc] init]; request.permissions = [NSOrderedSet orderedSetWithObject:@"user_info"]; //可选附加权限(如有),用户可选择勾选/不勾选 // request.additionalPermissions = [NSOrderedSet orderedSetWithObjects:@{@"permission":@"friend_relation",@"defaultChecked":@"1"}, @{@"permission":@"message",@"defaultChecked":@"0"}, nil]; [request sendAuthRequestViewController:RQControllerHelper.currentViewController completeBlock:^(DouyinOpenSDKAuthResponse * _Nonnull resp) { NSString *alertString = nil; if (resp.errCode == 0) { // alertString = [NSString stringWithFormat:@"Author Success Code : %@, permission : %@",resp.code, resp.grantedPermissions]; [MBProgressHUD rq_showTips:@"授权成功"]; [RQNotificationCenter postNotificationName:RQDouYinOnRespNotification object:resp.code]; } else{ #if DEBUG alertString = [NSString stringWithFormat:@"Author failed code : %@, msg : %@",@(resp.errCode), resp.errString]; alertString = [NSString stringWithFormat:@"%@",resp.errString]; #else alertString = [NSString stringWithFormat:@"%@",resp.errString]; #endif [NSObject rq_showAlertViewWithTitle:alertString message:nil confirmTitle:@"确定"]; } }]; } #pragma mark - PrivateMethods #pragma mark - DouyinOpenSDKLogDelegate - (void)onLog:(nonnull NSString *)logInfo { } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { if ([[DouyinOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) { return YES; } return NO; } @end