3 Commits

Author SHA1 Message Date
1096f24c57 修改hud 2025-12-31 17:32:39 +08:00
7ed84fd445 修改分享方式 2025-12-30 20:41:30 +08:00
4e2d7d2908 添加部分通用上报
修改bug 未登录在键盘点击充值要先去跳转登录
2025-12-30 15:27:35 +08:00
8 changed files with 111 additions and 14 deletions

View File

@@ -481,6 +481,13 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
}
}
- (void)functionView:(KBFunctionView *_Nullable)functionView didRightTapToolActionAtIndex:(NSInteger)index{
if (!KBAuthManager.shared.isLoggedIn) {
NSString *schemeStr = [NSString stringWithFormat:@"%@://login?src=keyboard", KB_APP_SCHEME];
NSURL *scheme = [NSURL URLWithString:schemeStr];
// UIApplication App
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:self.view];
return;
}
NSString *schemeStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME];
NSURL *scheme = [NSURL URLWithString:schemeStr];
//

View File

@@ -13,12 +13,27 @@
#define KB_MAI_POINT_PATH_NEW_ACCOUNT @"/newAccount"
#endif
#ifndef KB_MAI_POINT_PATH_GENERIC_DATA
#define KB_MAI_POINT_PATH_GENERIC_DATA @"/genericData"
#endif
NS_ASSUME_NONNULL_BEGIN
extern NSString * const KBMaiPointErrorDomain;
typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable error);
typedef NS_ENUM(NSInteger, KBMaiPointGenericReportType) {
/// 未知/默认类型(按需扩展,具体含义以服务端约定为准)
KBMaiPointGenericReportTypeUnknown = 0,
/// 点击
KBMaiPointGenericReportTypeClick = 1,
/// 曝光
KBMaiPointGenericReportTypeExposure = 2,
/// 页面/进入
KBMaiPointGenericReportTypePage = 3,
};
/// Lightweight reporter for Mai point tracking. Safe for app + extension.
@interface KBMaiPointReporter : NSObject
@@ -26,9 +41,18 @@ typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable err
/// POST /newAccount with type + account.
- (void)reportNewAccountWithType:(NSString *)type
account:(NSString *)account
account:(nullable NSString *)account
completion:(KBMaiPointReportCompletion _Nullable)completion;
//- (void)reportGenericDataWithEvent:(NSString *)event
// account:(nullable NSString *)account
// completion:(KBMaiPointReportCompletion _Nullable)completion;
/// POST /genericData with type + event + account.
- (void)reportGenericDataWithEventType:(KBMaiPointGenericReportType)type
account:(nullable NSString *)account
completion:(KBMaiPointReportCompletion _Nullable)completion;
/// Generic POST for future endpoints.
- (void)postPath:(NSString *)path
parameters:(NSDictionary *)parameters

View File

@@ -42,11 +42,16 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
return reporter;
}
- (NSString *)kb_trimmedStringOrEmpty:(NSString * _Nullable)string {
NSString *value = [string isKindOfClass:[NSString class]] ? string : @"";
return [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] ?: @"";
}
- (void)reportNewAccountWithType:(NSString *)type
account:(NSString *)account
completion:(KBMaiPointReportCompletion)completion {
NSString *trimmedType = [type stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *trimmedAccount = [account stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
account:(NSString * _Nullable)account
completion:(KBMaiPointReportCompletion _Nullable)completion {
NSString *trimmedType = [self kb_trimmedStringOrEmpty:type];
NSString *trimmedAccount = [self kb_trimmedStringOrEmpty:account];
if (trimmedType.length == 0 || trimmedAccount.length == 0) {
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
code:-1
@@ -66,9 +71,44 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
[self postPath:KB_MAI_POINT_PATH_NEW_ACCOUNT parameters:params completion:completion];
}
//- (void)reportGenericDataWithEvent:(NSString *)event
// account:(NSString * _Nullable)account
// completion:(KBMaiPointReportCompletion _Nullable)completion {
// [self reportGenericDataWithType:KBMaiPointGenericReportTypeUnknown
// event:event
// account:account
// completion:completion];
//}
- (void)reportGenericDataWithEventType:(KBMaiPointGenericReportType)eventType
account:(nullable NSString *)account
completion:(KBMaiPointReportCompletion _Nullable)completion{
// if ([KBUserSessionManager shared].isLoggedIn == false) {
// return;
// }
NSString *trimmedAccount = [self kb_trimmedStringOrEmpty:account];
if (trimmedAccount.length == 0) {
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
code:-1
userInfo:@{NSLocalizedDescriptionKey: @"Invalid parameter"}];
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(NO, error);
});
}
return;
}
NSDictionary *params = @{
@"eventId": @"123",
@"account": account
};
[self postPath:KB_MAI_POINT_PATH_GENERIC_DATA parameters:params completion:completion];
}
- (void)postPath:(NSString *)path
parameters:(NSDictionary *)parameters
completion:(KBMaiPointReportCompletion)completion {
completion:(KBMaiPointReportCompletion _Nullable)completion {
if (path.length == 0 || ![parameters isKindOfClass:[NSDictionary class]]) {
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
code:-1

View File

@@ -52,6 +52,11 @@
[weakSelf.navigationController pushViewController:vc animated:true];
};
[[KBMaiPointReporter sharedReporter] reportGenericDataWithEventType:KBMaiPointGenericReportTypePage account:@"123" completion:^(BOOL success, NSError * _Nullable error) {
NSLog(@"===");
}];
// groups
// NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
// //

View File

@@ -7,7 +7,7 @@
#import "KBForgetPwdNewPwdVC.h"
#import "KBLoginVM.h"
#import "KBEmailRegistVC.h"
#import "KBLoginVC.h"
@interface KBForgetPwdNewPwdVC () <UITextFieldDelegate>
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password
@@ -131,7 +131,7 @@
if (success) {
UIViewController *targetVC = nil;
for (UIViewController *vc in KB_CURRENT_NAV.viewControllers) {
if ([vc isKindOfClass:[KBEmailRegistVC class]]) {
if ([vc isKindOfClass:[KBLoginVC class]]) {
targetVC = vc;
break;
}

View File

@@ -128,9 +128,12 @@
if (!self.viewModel) {
self.viewModel = [[KBMyVM alloc] init];
}
__weak typeof(self) weakSelf = self;
[KBHUD show];
[self.viewModel fetchInviteCodeWithCompletion:^(KBInviteCodeModel * _Nullable inviteCode, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) self = weakSelf;
if (!self) { return; }
[KBHUD dismiss];
if (error) {
[KBHUD showInfo:error.localizedDescription ?: KBLocalized(@"Network error")];
@@ -142,9 +145,21 @@
[KBHUD showInfo:KBLocalized(@"Failed")];
return;
}
id shareItem = textToCopy;
NSURL *url = [NSURL URLWithString:textToCopy];
if (url) {
shareItem = url;
}
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[shareItem] applicationActivities:nil];
UIPopoverPresentationController *popover = activityVC.popoverPresentationController;
if (popover) {
popover.sourceView = self.view;
popover.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds), 1, 1);
popover.permittedArrowDirections = 0;
}
UIPasteboard.generalPasteboard.string = textToCopy;
[KBHUD showInfo:KBLocalized(@"Copy Success")];
[self presentViewController:activityVC animated:YES completion:nil];
});
}];

View File

@@ -14,8 +14,9 @@
- (void)applePayReqWithParams:(NSDictionary *)params
needShow:(BOOL)needShow
completion:(KBPayCompletion)completion {
// if (needShow) { [KBHUD show]; }
[KBHUD showWithStatus:@"Please wait"];
if (needShow) {
[KBHUD showWithStatus:@"Please wait"];
}
[[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT
jsonBody:params
headers:nil
@@ -31,11 +32,15 @@
NSNumber *codeNum = error.userInfo[@"code"];
NSInteger bizCode = codeNum.integerValue; // code
// bizCode completion
if (completion) completion(bizCode, error.localizedDescription ?: KBLocalized(@"Network error"));
NSString *msg = error.localizedDescription ?: KBLocalized(@"Network error");
if (needShow) { [KBHUD showError:msg]; }
if (completion) completion(bizCode, msg);
return;
}
// if (completion) completion(ERROR_CODE, error.localizedDescription ?: KBLocalized(@"Network error"));
NSString *msg = error.localizedDescription ?: KBLocalized(@"Network error");
if (needShow) { [KBHUD showError:msg]; }
if (completion) completion(KBBizCodeSystemError, msg);
return;
}

View File

@@ -296,6 +296,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
fromViewController:self
mode:KBSkinSourceModeRemoteZip
completion:^(BOOL success) {
[KBHUD dismiss];
NSLog(@"%@[SkinDetail] download result id=%@",
(success ? @"✅" : @"❌"),
self.detailModel.themeId);