1
This commit is contained in:
@@ -182,13 +182,17 @@
|
||||
if (!self.myVM) {
|
||||
self.myVM = [[KBMyVM alloc] init];
|
||||
}
|
||||
[self.myVM fetchCharacterListByUserWithCompletion:^(NSArray<KBCharacter *> * _Nonnull characterArray, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
KBLOG(@"[Login] Failed to sync keyboard characters after login: %@", error);
|
||||
} else {
|
||||
KBLOG(@"[Login] Synced %tu keyboard characters after login", characterArray.count);
|
||||
}
|
||||
}];
|
||||
/// 防止token写入过慢导致请求head没有token
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.myVM fetchCharacterListByUserWithCompletion:^(NSArray<KBCharacter *> * _Nonnull characterArray, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
KBLOG(@"[Login] Failed to sync keyboard characters after login: %@", error);
|
||||
} else {
|
||||
KBLOG(@"[Login] Synced %tu keyboard characters after login", characterArray.count);
|
||||
}
|
||||
}];
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
@@ -16,16 +16,29 @@
|
||||
completion:(KBPayCompletion)completion {
|
||||
if (needShow) { [KBHUD show]; }
|
||||
|
||||
[[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT jsonBody:params headers:nil autoShowBusinessError:false completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
[[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT
|
||||
jsonBody:params
|
||||
headers:nil
|
||||
autoShowBusinessError:false
|
||||
completion:^(NSDictionary *json,
|
||||
NSURLResponse *response,
|
||||
NSError *error) {
|
||||
if (needShow) { [KBHUD dismiss]; }
|
||||
|
||||
|
||||
if (error) {
|
||||
if (completion) completion(ERROR_CODE, error.localizedDescription ?: KBLocalized(@"Network error"));
|
||||
if ([error.domain isEqualToString:KBNetworkErrorDomain] &&
|
||||
error.code == KBNetworkErrorBusiness) {
|
||||
NSNumber *codeNum = error.userInfo[@"code"];
|
||||
NSInteger bizCode = codeNum.integerValue; // 这里就是底层附带的业务 code
|
||||
// 根据 bizCode 做处理,比如透传给上层 completion
|
||||
if (completion) completion(bizCode, error.localizedDescription ?: KBLocalized(@"Network error"));
|
||||
return;
|
||||
}
|
||||
|
||||
// if (completion) completion(ERROR_CODE, error.localizedDescription ?: KBLocalized(@"Network error"));
|
||||
return;
|
||||
}
|
||||
|
||||
// NSInteger sta = [self.class extractStatusFromResponseObject:jsonOrData response:response];
|
||||
// NSString *msg = [self.class extractMessageFromResponseObject:jsonOrData] ?: (sta == KBBizCodeSuccess ? @"OK" : KBLocalized(@"Failed"));
|
||||
|
||||
if (completion) completion(KBBizCodeSuccess, @"ok");
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
}
|
||||
|
||||
- (void)setConfigureWith:(id<FGIAPVerifyTransaction>)verifyTransaction{
|
||||
// 只初始化一次,避免重复向 SKPaymentQueue 注册多个观察者。
|
||||
if (self->_iap != nil) {
|
||||
return;
|
||||
}
|
||||
self->_iap = [[FGIAPService alloc] initWithTransaction:verifyTransaction];
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ static NSMutableDictionary *FGIAPServiceErrorMapsFromTransaction (SKPaymentTrans
|
||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||
}
|
||||
|
||||
if ([transaction.payment.productIdentifier isEqualToString:self.productIdentifier]) {
|
||||
if (transaction.originalTransaction == nil && [transaction.payment.productIdentifier isEqualToString:self.productIdentifier]) {
|
||||
self.productIdentifier = nil;
|
||||
if (_buyProductCompleteBlock) {
|
||||
_buyProductCompleteBlock(msg, result);
|
||||
|
||||
Reference in New Issue
Block a user