From 633e6a9123051a908452df86ccc295ddb52bd755 Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Fri, 12 Dec 2025 20:08:34 +0800 Subject: [PATCH] 1 --- keyBoard.xcodeproj/project.pbxproj | 62 +++++++++---------- keyBoard/Class/Login/VM/KBLoginVM.m | 18 +++--- keyBoard/Class/Pay/VM/PayVM.m | 25 ++++++-- .../Class/Vender/FGIAPService/FGIAPManager.m | 4 -- .../Class/Vender/FGIAPService/FGIAPService.m | 2 +- 5 files changed, 62 insertions(+), 49 deletions(-) diff --git a/keyBoard.xcodeproj/project.pbxproj b/keyBoard.xcodeproj/project.pbxproj index 173e3e4..784d98d 100644 --- a/keyBoard.xcodeproj/project.pbxproj +++ b/keyBoard.xcodeproj/project.pbxproj @@ -11,16 +11,11 @@ 041007D42ECE012500D203BB /* 002.zip in Resources */ = {isa = PBXBuildFile; fileRef = 041007D32ECE012500D203BB /* 002.zip */; }; 04122F5D2EC5E5A900EF7AB3 /* KBLoginVM.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F5B2EC5E5A900EF7AB3 /* KBLoginVM.m */; }; 04122F622EC5F41D00EF7AB3 /* KBUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F612EC5F41D00EF7AB3 /* KBUser.m */; }; - 04122F6D2EC5F40800EF7AB3 /* NSObject+FGIsNullOrEmpty.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F6B2EC5F40800EF7AB3 /* NSObject+FGIsNullOrEmpty.m */; }; - 04122F6E2EC5F40800EF7AB3 /* FGIAPProductsFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F652EC5F40800EF7AB3 /* FGIAPProductsFilter.m */; }; - 04122F6F2EC5F40800EF7AB3 /* FGIAPManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F632EC5F40800EF7AB3 /* FGIAPManager.m */; }; - 04122F702EC5F40800EF7AB3 /* FGIAPService.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F672EC5F40800EF7AB3 /* FGIAPService.m */; }; 04122F7E2EC5FC5500EF7AB3 /* KBJfPayCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F7C2EC5FC5500EF7AB3 /* KBJfPayCell.m */; }; 04122F822EC5FC6F00EF7AB3 /* KBJfPay.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F802EC5FC6F00EF7AB3 /* KBJfPay.m */; }; 04122F872EC6198C00EF7AB3 /* WMDragView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F852EC6198C00EF7AB3 /* WMDragView.m */; }; 04122F882EC6F07F00EF7AB3 /* KBFullAccessManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A9FE112EB4D0D20020DB6D /* KBFullAccessManager.m */; }; 04122F8B2EC6F7C800EF7AB3 /* IAPVerifyTransactionObj.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F8A2EC6F7C800EF7AB3 /* IAPVerifyTransactionObj.m */; }; - 04B5A1A22EEFA12300AAAAAA /* KBPayProductModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B5A1A12EEFA12300AAAAAA /* KBPayProductModel.m */; }; 04122F8E2EC6F83F00EF7AB3 /* PayVM.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F8D2EC6F83F00EF7AB3 /* PayVM.m */; }; 04122F912EC73AF700EF7AB3 /* KBVipPay.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122F902EC73AF700EF7AB3 /* KBVipPay.m */; }; 04122FAA2EC73C0100EF7AB3 /* KBVipPayHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04122FA92EC73C0100EF7AB3 /* KBVipPayHeaderView.m */; }; @@ -119,6 +114,10 @@ 0498BDDE2EE81508006CC1D5 /* KBShopVM.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDDD2EE81508006CC1D5 /* KBShopVM.m */; }; 0498BDE12EEA87C9006CC1D5 /* KBShopStyleModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDE02EEA87C8006CC1D5 /* KBShopStyleModel.m */; }; 0498BDE42EEA885D006CC1D5 /* KBShopThemeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDE32EEA885D006CC1D5 /* KBShopThemeModel.m */; }; + 0498BDF02EEC0E56006CC1D5 /* FGIAPManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDE72EEC0E56006CC1D5 /* FGIAPManager.m */; }; + 0498BDF12EEC0E56006CC1D5 /* FGIAPProductsFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDE92EEC0E56006CC1D5 /* FGIAPProductsFilter.m */; }; + 0498BDF22EEC0E56006CC1D5 /* NSObject+FGIsNullOrEmpty.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDEF2EEC0E56006CC1D5 /* NSObject+FGIsNullOrEmpty.m */; }; + 0498BDF32EEC0E56006CC1D5 /* FGIAPService.m in Sources */ = {isa = PBXBuildFile; fileRef = 0498BDEB2EEC0E56006CC1D5 /* FGIAPService.m */; }; 049FB20B2EC1C13800FAB05D /* KBSkinBottomActionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB20A2EC1C13800FAB05D /* KBSkinBottomActionView.m */; }; 049FB20E2EC1CD2800FAB05D /* KBAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB20D2EC1CD2800FAB05D /* KBAlert.m */; }; 049FB2112EC1F72F00FAB05D /* KBMyListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2102EC1F72F00FAB05D /* KBMyListCell.m */; }; @@ -145,6 +144,7 @@ 04A9FE1B2EB892460020DB6D /* KBLocalizationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A9FE192EB892460020DB6D /* KBLocalizationManager.m */; }; 04A9FE202EB893F10020DB6D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04A9FE1E2EB893F10020DB6D /* Localizable.strings */; }; 04A9FE212EB893F10020DB6D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04A9FE1E2EB893F10020DB6D /* Localizable.strings */; }; + 04B5A1A22EEFA12300AAAAAA /* KBPayProductModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B5A1A12EEFA12300AAAAAA /* KBPayProductModel.m */; }; 04C6EABA2EAF86530089C901 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 04C6EAAE2EAF86530089C901 /* Assets.xcassets */; }; 04C6EABC2EAF86530089C901 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 04C6EAB12EAF86530089C901 /* LaunchScreen.storyboard */; }; 04C6EABD2EAF86530089C901 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 04C6EAB42EAF86530089C901 /* Main.storyboard */; }; @@ -230,16 +230,6 @@ 04122F5B2EC5E5A900EF7AB3 /* KBLoginVM.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBLoginVM.m; sourceTree = ""; }; 04122F602EC5F41D00EF7AB3 /* KBUser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBUser.h; sourceTree = ""; }; 04122F612EC5F41D00EF7AB3 /* KBUser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBUser.m; sourceTree = ""; }; - 04122F622EC5F40800EF7AB3 /* FGIAPManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPManager.h; sourceTree = ""; }; - 04122F632EC5F40800EF7AB3 /* FGIAPManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FGIAPManager.m; sourceTree = ""; }; - 04122F642EC5F40800EF7AB3 /* FGIAPProductsFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPProductsFilter.h; sourceTree = ""; }; - 04122F652EC5F40800EF7AB3 /* FGIAPProductsFilter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FGIAPProductsFilter.m; sourceTree = ""; }; - 04122F662EC5F40800EF7AB3 /* FGIAPService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPService.h; sourceTree = ""; }; - 04122F672EC5F40800EF7AB3 /* FGIAPService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FGIAPService.m; sourceTree = ""; }; - 04122F682EC5F40800EF7AB3 /* FGIAPServiceUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPServiceUtility.h; sourceTree = ""; }; - 04122F692EC5F40800EF7AB3 /* FGIAPVerifyTransaction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPVerifyTransaction.h; sourceTree = ""; }; - 04122F6A2EC5F40800EF7AB3 /* NSObject+FGIsNullOrEmpty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSObject+FGIsNullOrEmpty.h"; sourceTree = ""; }; - 04122F6B2EC5F40800EF7AB3 /* NSObject+FGIsNullOrEmpty.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSObject+FGIsNullOrEmpty.m"; sourceTree = ""; }; 04122F7B2EC5FC5500EF7AB3 /* KBJfPayCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBJfPayCell.h; sourceTree = ""; }; 04122F7C2EC5FC5500EF7AB3 /* KBJfPayCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBJfPayCell.m; sourceTree = ""; }; 04122F7F2EC5FC6F00EF7AB3 /* KBJfPay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBJfPay.h; sourceTree = ""; }; @@ -248,8 +238,6 @@ 04122F852EC6198C00EF7AB3 /* WMDragView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMDragView.m; sourceTree = ""; }; 04122F892EC6F7C800EF7AB3 /* IAPVerifyTransactionObj.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IAPVerifyTransactionObj.h; sourceTree = ""; }; 04122F8A2EC6F7C800EF7AB3 /* IAPVerifyTransactionObj.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IAPVerifyTransactionObj.m; sourceTree = ""; }; - 04B5A1A02EEFA12300AAAAAA /* KBPayProductModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBPayProductModel.h; sourceTree = ""; }; - 04B5A1A12EEFA12300AAAAAA /* KBPayProductModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBPayProductModel.m; sourceTree = ""; }; 04122F8C2EC6F83F00EF7AB3 /* PayVM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PayVM.h; sourceTree = ""; }; 04122F8D2EC6F83F00EF7AB3 /* PayVM.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PayVM.m; sourceTree = ""; }; 04122F8F2EC73AF700EF7AB3 /* KBVipPay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBVipPay.h; sourceTree = ""; }; @@ -421,6 +409,16 @@ 0498BDE02EEA87C8006CC1D5 /* KBShopStyleModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBShopStyleModel.m; sourceTree = ""; }; 0498BDE22EEA885D006CC1D5 /* KBShopThemeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBShopThemeModel.h; sourceTree = ""; }; 0498BDE32EEA885D006CC1D5 /* KBShopThemeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBShopThemeModel.m; sourceTree = ""; }; + 0498BDE62EEC0E56006CC1D5 /* FGIAPManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPManager.h; sourceTree = ""; }; + 0498BDE72EEC0E56006CC1D5 /* FGIAPManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FGIAPManager.m; sourceTree = ""; }; + 0498BDE82EEC0E56006CC1D5 /* FGIAPProductsFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPProductsFilter.h; sourceTree = ""; }; + 0498BDE92EEC0E56006CC1D5 /* FGIAPProductsFilter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FGIAPProductsFilter.m; sourceTree = ""; }; + 0498BDEA2EEC0E56006CC1D5 /* FGIAPService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPService.h; sourceTree = ""; }; + 0498BDEB2EEC0E56006CC1D5 /* FGIAPService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FGIAPService.m; sourceTree = ""; }; + 0498BDEC2EEC0E56006CC1D5 /* FGIAPServiceUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPServiceUtility.h; sourceTree = ""; }; + 0498BDED2EEC0E56006CC1D5 /* FGIAPVerifyTransaction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FGIAPVerifyTransaction.h; sourceTree = ""; }; + 0498BDEE2EEC0E56006CC1D5 /* NSObject+FGIsNullOrEmpty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSObject+FGIsNullOrEmpty.h"; sourceTree = ""; }; + 0498BDEF2EEC0E56006CC1D5 /* NSObject+FGIsNullOrEmpty.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSObject+FGIsNullOrEmpty.m"; sourceTree = ""; }; 049FB2092EC1C13800FAB05D /* KBSkinBottomActionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBSkinBottomActionView.h; sourceTree = ""; }; 049FB20A2EC1C13800FAB05D /* KBSkinBottomActionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSkinBottomActionView.m; sourceTree = ""; }; 049FB20C2EC1CD2800FAB05D /* KBAlert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBAlert.h; sourceTree = ""; }; @@ -468,6 +466,8 @@ 04A9FE192EB892460020DB6D /* KBLocalizationManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBLocalizationManager.m; sourceTree = ""; }; 04A9FE1C2EB893F10020DB6D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 04A9FE1D2EB893F10020DB6D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; + 04B5A1A02EEFA12300AAAAAA /* KBPayProductModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBPayProductModel.h; sourceTree = ""; }; + 04B5A1A12EEFA12300AAAAAA /* KBPayProductModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBPayProductModel.m; sourceTree = ""; }; 04C6EAAC2EAF86530089C901 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 04C6EAAD2EAF86530089C901 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 04C6EAAE2EAF86530089C901 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -646,16 +646,16 @@ 04122F6C2EC5F40800EF7AB3 /* FGIAPService */ = { isa = PBXGroup; children = ( - 04122F622EC5F40800EF7AB3 /* FGIAPManager.h */, - 04122F632EC5F40800EF7AB3 /* FGIAPManager.m */, - 04122F642EC5F40800EF7AB3 /* FGIAPProductsFilter.h */, - 04122F652EC5F40800EF7AB3 /* FGIAPProductsFilter.m */, - 04122F662EC5F40800EF7AB3 /* FGIAPService.h */, - 04122F672EC5F40800EF7AB3 /* FGIAPService.m */, - 04122F682EC5F40800EF7AB3 /* FGIAPServiceUtility.h */, - 04122F692EC5F40800EF7AB3 /* FGIAPVerifyTransaction.h */, - 04122F6A2EC5F40800EF7AB3 /* NSObject+FGIsNullOrEmpty.h */, - 04122F6B2EC5F40800EF7AB3 /* NSObject+FGIsNullOrEmpty.m */, + 0498BDE62EEC0E56006CC1D5 /* FGIAPManager.h */, + 0498BDE72EEC0E56006CC1D5 /* FGIAPManager.m */, + 0498BDE82EEC0E56006CC1D5 /* FGIAPProductsFilter.h */, + 0498BDE92EEC0E56006CC1D5 /* FGIAPProductsFilter.m */, + 0498BDEA2EEC0E56006CC1D5 /* FGIAPService.h */, + 0498BDEB2EEC0E56006CC1D5 /* FGIAPService.m */, + 0498BDEC2EEC0E56006CC1D5 /* FGIAPServiceUtility.h */, + 0498BDED2EEC0E56006CC1D5 /* FGIAPVerifyTransaction.h */, + 0498BDEE2EEC0E56006CC1D5 /* NSObject+FGIsNullOrEmpty.h */, + 0498BDEF2EEC0E56006CC1D5 /* NSObject+FGIsNullOrEmpty.m */, ); path = FGIAPService; sourceTree = ""; @@ -1833,10 +1833,6 @@ 0498BDDE2EE81508006CC1D5 /* KBShopVM.m in Sources */, 049FB2112EC1F72F00FAB05D /* KBMyListCell.m in Sources */, A1B2D7022EB8C00100000001 /* KBLangTestVC.m in Sources */, - 04122F6D2EC5F40800EF7AB3 /* NSObject+FGIsNullOrEmpty.m in Sources */, - 04122F6E2EC5F40800EF7AB3 /* FGIAPProductsFilter.m in Sources */, - 04122F6F2EC5F40800EF7AB3 /* FGIAPManager.m in Sources */, - 04122F702EC5F40800EF7AB3 /* FGIAPService.m in Sources */, 0498BD7B2EE04518006CC1D5 /* KBCharacter.m in Sources */, 04122FB32EC73C0100EF7AB3 /* KBVipReviewListCell.m in Sources */, 048908DA2EBF61AF00FABA60 /* UICollectionViewLeftAlignedLayout.m in Sources */, @@ -1854,6 +1850,10 @@ 0479205F2EDEE1FC004E8522 /* CRBoxInputCellProperty.m in Sources */, 047920602EDEE1FC004E8522 /* CRLineView.m in Sources */, 047C65502EBCBA9E0035E841 /* KBShopVC.m in Sources */, + 0498BDF02EEC0E56006CC1D5 /* FGIAPManager.m in Sources */, + 0498BDF12EEC0E56006CC1D5 /* FGIAPProductsFilter.m in Sources */, + 0498BDF22EEC0E56006CC1D5 /* NSObject+FGIsNullOrEmpty.m in Sources */, + 0498BDF32EEC0E56006CC1D5 /* FGIAPService.m in Sources */, 0477BE042EBC83130055D639 /* HomeMainVC.m in Sources */, 0477BDFD2EBC6A170055D639 /* HomeHotVC.m in Sources */, 04122FAA2EC73C0100EF7AB3 /* KBVipPayHeaderView.m in Sources */, diff --git a/keyBoard/Class/Login/VM/KBLoginVM.m b/keyBoard/Class/Login/VM/KBLoginVM.m index ab5e6b1..9beceb3 100644 --- a/keyBoard/Class/Login/VM/KBLoginVM.m +++ b/keyBoard/Class/Login/VM/KBLoginVM.m @@ -182,13 +182,17 @@ if (!self.myVM) { self.myVM = [[KBMyVM alloc] init]; } - [self.myVM fetchCharacterListByUserWithCompletion:^(NSArray * _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 * _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 diff --git a/keyBoard/Class/Pay/VM/PayVM.m b/keyBoard/Class/Pay/VM/PayVM.m index aaf55a1..88026a2 100644 --- a/keyBoard/Class/Pay/VM/PayVM.m +++ b/keyBoard/Class/Pay/VM/PayVM.m @@ -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"); }]; } diff --git a/keyBoard/Class/Vender/FGIAPService/FGIAPManager.m b/keyBoard/Class/Vender/FGIAPService/FGIAPManager.m index f63604a..cbdcada 100644 --- a/keyBoard/Class/Vender/FGIAPService/FGIAPManager.m +++ b/keyBoard/Class/Vender/FGIAPService/FGIAPManager.m @@ -19,10 +19,6 @@ } - (void)setConfigureWith:(id)verifyTransaction{ - // 只初始化一次,避免重复向 SKPaymentQueue 注册多个观察者。 - if (self->_iap != nil) { - return; - } self->_iap = [[FGIAPService alloc] initWithTransaction:verifyTransaction]; } diff --git a/keyBoard/Class/Vender/FGIAPService/FGIAPService.m b/keyBoard/Class/Vender/FGIAPService/FGIAPService.m index fdefab5..1d96f3b 100644 --- a/keyBoard/Class/Vender/FGIAPService/FGIAPService.m +++ b/keyBoard/Class/Vender/FGIAPService/FGIAPService.m @@ -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);