Compare commits
3 Commits
34089ddeea
...
1096f24c57
| Author | SHA1 | Date | |
|---|---|---|---|
| 1096f24c57 | |||
| 7ed84fd445 | |||
| 4e2d7d2908 |
@@ -481,6 +481,13 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (void)functionView:(KBFunctionView *_Nullable)functionView didRightTapToolActionAtIndex:(NSInteger)index{
|
- (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];
|
NSString *schemeStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME];
|
||||||
NSURL *scheme = [NSURL URLWithString:schemeStr];
|
NSURL *scheme = [NSURL URLWithString:schemeStr];
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -13,12 +13,27 @@
|
|||||||
#define KB_MAI_POINT_PATH_NEW_ACCOUNT @"/newAccount"
|
#define KB_MAI_POINT_PATH_NEW_ACCOUNT @"/newAccount"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef KB_MAI_POINT_PATH_GENERIC_DATA
|
||||||
|
#define KB_MAI_POINT_PATH_GENERIC_DATA @"/genericData"
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
extern NSString * const KBMaiPointErrorDomain;
|
extern NSString * const KBMaiPointErrorDomain;
|
||||||
|
|
||||||
typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable error);
|
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.
|
/// Lightweight reporter for Mai point tracking. Safe for app + extension.
|
||||||
@interface KBMaiPointReporter : NSObject
|
@interface KBMaiPointReporter : NSObject
|
||||||
|
|
||||||
@@ -26,9 +41,18 @@ typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable err
|
|||||||
|
|
||||||
/// POST /newAccount with type + account.
|
/// POST /newAccount with type + account.
|
||||||
- (void)reportNewAccountWithType:(NSString *)type
|
- (void)reportNewAccountWithType:(NSString *)type
|
||||||
account:(NSString *)account
|
account:(nullable NSString *)account
|
||||||
completion:(KBMaiPointReportCompletion _Nullable)completion;
|
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.
|
/// Generic POST for future endpoints.
|
||||||
- (void)postPath:(NSString *)path
|
- (void)postPath:(NSString *)path
|
||||||
parameters:(NSDictionary *)parameters
|
parameters:(NSDictionary *)parameters
|
||||||
|
|||||||
@@ -42,11 +42,16 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
|
|||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)kb_trimmedStringOrEmpty:(NSString * _Nullable)string {
|
||||||
|
NSString *value = [string isKindOfClass:[NSString class]] ? string : @"";
|
||||||
|
return [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] ?: @"";
|
||||||
|
}
|
||||||
|
|
||||||
- (void)reportNewAccountWithType:(NSString *)type
|
- (void)reportNewAccountWithType:(NSString *)type
|
||||||
account:(NSString *)account
|
account:(NSString * _Nullable)account
|
||||||
completion:(KBMaiPointReportCompletion)completion {
|
completion:(KBMaiPointReportCompletion _Nullable)completion {
|
||||||
NSString *trimmedType = [type stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
NSString *trimmedType = [self kb_trimmedStringOrEmpty:type];
|
||||||
NSString *trimmedAccount = [account stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
NSString *trimmedAccount = [self kb_trimmedStringOrEmpty:account];
|
||||||
if (trimmedType.length == 0 || trimmedAccount.length == 0) {
|
if (trimmedType.length == 0 || trimmedAccount.length == 0) {
|
||||||
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
|
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
|
||||||
code:-1
|
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];
|
[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
|
- (void)postPath:(NSString *)path
|
||||||
parameters:(NSDictionary *)parameters
|
parameters:(NSDictionary *)parameters
|
||||||
completion:(KBMaiPointReportCompletion)completion {
|
completion:(KBMaiPointReportCompletion _Nullable)completion {
|
||||||
if (path.length == 0 || ![parameters isKindOfClass:[NSDictionary class]]) {
|
if (path.length == 0 || ![parameters isKindOfClass:[NSDictionary class]]) {
|
||||||
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
|
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
|
||||||
code:-1
|
code:-1
|
||||||
|
|||||||
@@ -52,6 +52,11 @@
|
|||||||
[weakSelf.navigationController pushViewController:vc animated:true];
|
[weakSelf.navigationController pushViewController:vc animated:true];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
[[KBMaiPointReporter sharedReporter] reportGenericDataWithEventType:KBMaiPointGenericReportTypePage account:@"123" completion:^(BOOL success, NSError * _Nullable error) {
|
||||||
|
NSLog(@"===");
|
||||||
|
}];
|
||||||
|
|
||||||
// 测试groups
|
// 测试groups
|
||||||
// NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
|
// NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
|
||||||
// // 写入一个简单字符串
|
// // 写入一个简单字符串
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#import "KBForgetPwdNewPwdVC.h"
|
#import "KBForgetPwdNewPwdVC.h"
|
||||||
#import "KBLoginVM.h"
|
#import "KBLoginVM.h"
|
||||||
#import "KBEmailRegistVC.h"
|
#import "KBLoginVC.h"
|
||||||
@interface KBForgetPwdNewPwdVC () <UITextFieldDelegate>
|
@interface KBForgetPwdNewPwdVC () <UITextFieldDelegate>
|
||||||
|
|
||||||
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password
|
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
if (success) {
|
if (success) {
|
||||||
UIViewController *targetVC = nil;
|
UIViewController *targetVC = nil;
|
||||||
for (UIViewController *vc in KB_CURRENT_NAV.viewControllers) {
|
for (UIViewController *vc in KB_CURRENT_NAV.viewControllers) {
|
||||||
if ([vc isKindOfClass:[KBEmailRegistVC class]]) {
|
if ([vc isKindOfClass:[KBLoginVC class]]) {
|
||||||
targetVC = vc;
|
targetVC = vc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,9 +128,12 @@
|
|||||||
if (!self.viewModel) {
|
if (!self.viewModel) {
|
||||||
self.viewModel = [[KBMyVM alloc] init];
|
self.viewModel = [[KBMyVM alloc] init];
|
||||||
}
|
}
|
||||||
|
__weak typeof(self) weakSelf = self;
|
||||||
[KBHUD show];
|
[KBHUD show];
|
||||||
[self.viewModel fetchInviteCodeWithCompletion:^(KBInviteCodeModel * _Nullable inviteCode, NSError * _Nullable error) {
|
[self.viewModel fetchInviteCodeWithCompletion:^(KBInviteCodeModel * _Nullable inviteCode, NSError * _Nullable error) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
__strong typeof(weakSelf) self = weakSelf;
|
||||||
|
if (!self) { return; }
|
||||||
[KBHUD dismiss];
|
[KBHUD dismiss];
|
||||||
if (error) {
|
if (error) {
|
||||||
[KBHUD showInfo:error.localizedDescription ?: KBLocalized(@"Network error")];
|
[KBHUD showInfo:error.localizedDescription ?: KBLocalized(@"Network error")];
|
||||||
@@ -142,9 +145,21 @@
|
|||||||
[KBHUD showInfo:KBLocalized(@"Failed")];
|
[KBHUD showInfo:KBLocalized(@"Failed")];
|
||||||
return;
|
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;
|
UIPasteboard.generalPasteboard.string = textToCopy;
|
||||||
[KBHUD showInfo:KBLocalized(@"Copy Success")];
|
[self presentViewController:activityVC animated:YES completion:nil];
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,9 @@
|
|||||||
- (void)applePayReqWithParams:(NSDictionary *)params
|
- (void)applePayReqWithParams:(NSDictionary *)params
|
||||||
needShow:(BOOL)needShow
|
needShow:(BOOL)needShow
|
||||||
completion:(KBPayCompletion)completion {
|
completion:(KBPayCompletion)completion {
|
||||||
// if (needShow) { [KBHUD show]; }
|
if (needShow) {
|
||||||
[KBHUD showWithStatus:@"Please wait"];
|
[KBHUD showWithStatus:@"Please wait"];
|
||||||
|
}
|
||||||
[[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT
|
[[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT
|
||||||
jsonBody:params
|
jsonBody:params
|
||||||
headers:nil
|
headers:nil
|
||||||
@@ -31,11 +32,15 @@
|
|||||||
NSNumber *codeNum = error.userInfo[@"code"];
|
NSNumber *codeNum = error.userInfo[@"code"];
|
||||||
NSInteger bizCode = codeNum.integerValue; // 这里就是底层附带的业务 code
|
NSInteger bizCode = codeNum.integerValue; // 这里就是底层附带的业务 code
|
||||||
// 根据 bizCode 做处理,比如透传给上层 completion
|
// 根据 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;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ typedef NS_ENUM(NSInteger, KBSkinDetailSection) {
|
|||||||
fromViewController:self
|
fromViewController:self
|
||||||
mode:KBSkinSourceModeRemoteZip
|
mode:KBSkinSourceModeRemoteZip
|
||||||
completion:^(BOOL success) {
|
completion:^(BOOL success) {
|
||||||
|
[KBHUD dismiss];
|
||||||
NSLog(@"%@[SkinDetail] download result id=%@",
|
NSLog(@"%@[SkinDetail] download result id=%@",
|
||||||
(success ? @"✅" : @"❌"),
|
(success ? @"✅" : @"❌"),
|
||||||
self.detailModel.themeId);
|
self.detailModel.themeId);
|
||||||
|
|||||||
Reference in New Issue
Block a user