一次性配置内购服务
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#import "AppleSignInManager.h"
|
||||
#import "KBNetworkManager.h"
|
||||
#import "KBAuthManager.h"
|
||||
#import "FGIAPManager.h"
|
||||
#import "IAPVerifyTransactionObj.h"
|
||||
#import "KBAPI.h"
|
||||
#import "KBUser.h"
|
||||
|
||||
@@ -15,6 +17,14 @@
|
||||
|
||||
@implementation KBLoginVM
|
||||
|
||||
/// 统一初始化内购(只执行一次)。既可以在“启动时已登录”的场景调用,也可以在“登录成功回调”里调用。
|
||||
+ (void)kb_configureIAPIfNeeded {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
[[FGIAPManager shared] setConfigureWith:[IAPVerifyTransactionObj new]];
|
||||
});
|
||||
}
|
||||
|
||||
+ (instancetype)shared {
|
||||
static KBLoginVM *vm; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ vm = [KBLoginVM new]; });
|
||||
return vm;
|
||||
@@ -64,7 +74,8 @@
|
||||
return;
|
||||
}
|
||||
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
||||
completion(true,nil);
|
||||
[KBLoginVM kb_configureIAPIfNeeded];
|
||||
if (completion) completion(YES, nil);
|
||||
// 保存登录态到共享钥匙串;供 App 与扩展共享
|
||||
// BOOL ok = [[KBAuthManager shared] saveAccessToken:user.token
|
||||
// refreshToken:nil
|
||||
@@ -99,7 +110,8 @@
|
||||
return;
|
||||
}
|
||||
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
||||
completion(true,nil);
|
||||
[KBLoginVM kb_configureIAPIfNeeded];
|
||||
if (completion) completion(YES, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -128,7 +140,8 @@
|
||||
return;
|
||||
}
|
||||
[[KBUserSessionManager shared] handleLoginSuccessWithUser:user];
|
||||
completion(true,nil);
|
||||
[KBLoginVM kb_configureIAPIfNeeded];
|
||||
if (completion) completion(YES, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user