一次性配置内购服务

This commit is contained in:
2025-12-05 13:49:12 +08:00
parent d2258883df
commit ad18a47d21
3 changed files with 28 additions and 7 deletions

View File

@@ -36,13 +36,17 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 1.
[[FGIAPManager shared] setConfigureWith:[IAPVerifyTransactionObj new]];
/// 2使
/// 1使
[KBLocalizationManager shared].supportedLanguageCodes = KBDefaultSupportedLanguageCodes();
/// 3 : token
/// 2 : token token
[[KBUserSessionManager shared] bootstrapIfNeeded];
/// 3
/// KBLoginVM
if ([KBUserSessionManager shared].isLoggedIn) {
[[FGIAPManager shared] setConfigureWith:[IAPVerifyTransactionObj new]];
}
// /访 Keychain
static NSString *const kKBFullAccessRecordInitializedKey = @"KBFullAccessRecordInitialized";

View File

@@ -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);
}];
}

View File

@@ -19,6 +19,10 @@
}
- (void)setConfigureWith:(id<FGIAPVerifyTransaction>)verifyTransaction{
// SKPaymentQueue
if (self->_iap != nil) {
return;
}
self->_iap = [[FGIAPService alloc] initWithTransaction:verifyTransaction];
}