diff --git a/CustomKeyboard/KeyboardViewController.m b/CustomKeyboard/KeyboardViewController.m index 9326fba..1309c7c 100644 --- a/CustomKeyboard/KeyboardViewController.m +++ b/CustomKeyboard/KeyboardViewController.m @@ -1421,7 +1421,15 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center, - (void)chatLimitPopViewDidTapRecharge:(KBChatLimitPopView *)view { [self kb_dismissChatLimitPop]; - [self showSubscriptionPanel]; + NSString *urlString = + [NSString stringWithFormat:@"%@://recharge?src=keyboard&vipType=svip", + KB_APP_SCHEME]; + NSURL *scheme = [NSURL URLWithString:urlString]; + BOOL success = [KBHostAppLauncher openHostAppURL:scheme + fromResponder:self.view]; + if (!success) { + [KBHUD showInfo:KBLocalized(@"Please open the App to finish purchase")]; + } } #pragma mark - lazy diff --git a/keyBoard/AppDelegate.m b/keyBoard/AppDelegate.m index 64313b1..415cf92 100644 --- a/keyBoard/AppDelegate.m +++ b/keyBoard/AppDelegate.m @@ -192,6 +192,9 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0; return YES; } else if ([host isEqualToString:@"recharge"]) { // kbkeyboard://recharge NSDictionary *params = [self kb_queryParametersFromURL:url]; + NSString *vipType = [params[@"vipType"] lowercaseString]; + BOOL preferSvip = ([vipType isKindOfClass:NSString.class] && vipType.length > 0 && + ([vipType isEqualToString:@"svip"] || [vipType isEqualToString:@"1"])); NSString *productId = params[@"productId"]; BOOL autoPay = NO; NSString *autoFlag = params[@"autoPay"]; @@ -203,34 +206,37 @@ static NSTimeInterval const kKBSubscriptionPrefillTTL = 10 * 60.0; autoPay = YES; } - BOOL wantsPrefill = NO; - NSString *prefillFlag = params[@"prefill"]; - if ([prefillFlag respondsToSelector:@selector(boolValue)] && prefillFlag.boolValue) { - wantsPrefill = YES; - } - NSString *src = params[@"src"]; - if ([src isKindOfClass:NSString.class] && [src.lowercaseString isEqualToString:@"keyboard"]) { - wantsPrefill = YES; - } - NSDictionary *prefillPayload = wantsPrefill ? [self kb_consumeSubscriptionPrefillPayloadIfValid] : nil; - if ([prefillPayload isKindOfClass:NSDictionary.class]) { - NSString *payloadProductId = prefillPayload[@"productId"]; - if (productId.length == 0 && [payloadProductId isKindOfClass:NSString.class]) { - productId = payloadProductId; - } - } - KBPayMainVC *vc = [[KBPayMainVC alloc] init]; - if ([prefillPayload isKindOfClass:NSDictionary.class]) { - NSArray *productsJSON = prefillPayload[@"products"]; - NSNumber *selectedIndexNumber = prefillPayload[@"selectedIndex"]; - NSInteger selectedIndex = [selectedIndexNumber respondsToSelector:@selector(integerValue)] ? selectedIndexNumber.integerValue : NSNotFound; - [vc configureWithProductId:productId - autoPurchase:autoPay - prefillProductsJSON:productsJSON - selectedIndex:selectedIndex]; - } else { - [vc configureWithProductId:productId autoPurchase:autoPay]; + vc.initialSelectedIndex = preferSvip ? 1 : 0; + if (!preferSvip) { + BOOL wantsPrefill = NO; + NSString *prefillFlag = params[@"prefill"]; + if ([prefillFlag respondsToSelector:@selector(boolValue)] && prefillFlag.boolValue) { + wantsPrefill = YES; + } + NSString *src = params[@"src"]; + if ([src isKindOfClass:NSString.class] && [src.lowercaseString isEqualToString:@"keyboard"]) { + wantsPrefill = YES; + } + NSDictionary *prefillPayload = wantsPrefill ? [self kb_consumeSubscriptionPrefillPayloadIfValid] : nil; + if ([prefillPayload isKindOfClass:NSDictionary.class]) { + NSString *payloadProductId = prefillPayload[@"productId"]; + if (productId.length == 0 && [payloadProductId isKindOfClass:NSString.class]) { + productId = payloadProductId; + } + } + + if ([prefillPayload isKindOfClass:NSDictionary.class]) { + NSArray *productsJSON = prefillPayload[@"products"]; + NSNumber *selectedIndexNumber = prefillPayload[@"selectedIndex"]; + NSInteger selectedIndex = [selectedIndexNumber respondsToSelector:@selector(integerValue)] ? selectedIndexNumber.integerValue : NSNotFound; + [vc configureWithProductId:productId + autoPurchase:autoPay + prefillProductsJSON:productsJSON + selectedIndex:selectedIndex]; + } else { + [vc configureWithProductId:productId autoPurchase:autoPay]; + } } [KB_CURRENT_NAV pushViewController:vc animated:true]; return YES;