处理上架的问题

1:处理了openurl 拉起问题
2:去掉了http
3 隐私等等
This commit is contained in:
2026-03-05 14:30:07 +08:00
parent 8cc484edcb
commit d8a84dc478
34 changed files with 506 additions and 511 deletions

View File

@@ -51,8 +51,6 @@
// 基础baseUrl
#ifndef KB_BASE_URL
//#define KB_BASE_URL @"https://m1.apifoxmock.com/m1/5438099-5113192-default/"
//#define KB_BASE_URL @"http://192.168.2.22:7529/api"
#define KB_BASE_URL @"https://devcallback.loveamorkey.com/api"
#endif

View File

@@ -6,11 +6,17 @@
// 从扩展拉起主app
#import <Foundation/Foundation.h>
#import <TargetConditionals.h>
#if __has_include(<UIKit/UIKit.h>)
#import <UIKit/UIKit.h>
#else
@class UIResponder;
#endif
NS_ASSUME_NONNULL_BEGIN
@interface KBHostAppLauncher : NSObject
/// 从某个 responder 出发,尝试通过 UIApplication 打开宿主 app 的 URL
/// 在主 App 内打开 URL。注意在 App Extension 环境下会直接返回 NO扩展内请使用 `extensionContext openURL:`)。
+ (BOOL)openHostAppURL:(NSURL *)url fromResponder:(UIResponder *)startResponder;
@end

View File

@@ -7,46 +7,34 @@
// KBHostAppLauncher.m
#import "KBHostAppLauncher.h"
#import <objc/message.h>
#import <TargetConditionals.h>
#if !TARGET_OS_EXTENSION
#import <UIKit/UIKit.h>
#endif
@implementation KBHostAppLauncher
+ (BOOL)openHostAppURL:(NSURL *)url fromResponder:(UIResponder *)startResponder {
if (!url || !startResponder) return NO;
UIResponder *responder = startResponder;
while (responder) {
if ([responder isKindOfClass:[UIApplication class]]) {
UIApplication *app = (UIApplication *)responder;
#if TARGET_OS_EXTENSION
// App Extension 使 UIApplication
return NO;
#else
// App UIApplication responder
UIApplication *app = UIApplication.sharedApplication;
if (!app) { return NO; }
if (@available(iOS 18.0, *)) {
// iOS 18+ open:options:completionHandler:
SEL sel = @selector(openURL:options:completionHandler:);
if ([app respondsToSelector:sel]) {
// [app openURL:url options:@{} completionHandler:nil];
void (*func)(id, SEL, NSURL *, NSDictionary *, void(^)(BOOL)) = (void *)objc_msgSend;
if (func) {
func(app, sel, url, @{}, nil);
return YES;
}
}
return NO;
} else {
// iOS 17- openURL:
if (@available(iOS 10.0, *)) {
[app openURL:url options:@{} completionHandler:nil];
return YES;
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([app respondsToSelector:@selector(openURL:)]) {
return [app openURL:url];
}
return [app openURL:url];
#pragma clang diagnostic pop
return NO;
}
}
responder = responder.nextResponder;
}
return NO;
#endif
}
@end

View File

@@ -6,7 +6,13 @@
#import <Foundation/Foundation.h>
#ifndef KB_MAI_POINT_BASE_URL
#if DEBUG
#define KB_MAI_POINT_BASE_URL @"http://192.168.2.21:35310/api"
#else
/// Release 默认关闭埋点上报(避免内网地址/HTTP 出现在上架包里)。
/// 线上如需开启,请在 Build SettingsPreprocessor Macros中覆盖该宏为 HTTPS 地址。
#define KB_MAI_POINT_BASE_URL @""
#endif
#endif
#ifndef KB_MAI_POINT_PATH_NEW_ACCOUNT

View File

@@ -201,8 +201,19 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
return;
}
NSString *base = [self kb_trimmedStringOrEmpty:KB_MAI_POINT_BASE_URL];
if (base.length == 0) {
// Release /HTTP
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(YES, nil);
});
}
return;
}
NSString *safePath = [path hasPrefix:@"/"] ? path : [@"/" stringByAppendingString:path];
NSString *urlString = [NSString stringWithFormat:@"%@%@", KB_MAI_POINT_BASE_URL, safePath];
NSString *urlString = [NSString stringWithFormat:@"%@%@", base, safePath];
NSURL *url = [NSURL URLWithString:urlString];
if (!url) {
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
@@ -216,6 +227,18 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
return;
}
#if !DEBUG
// HTTPS HTTP
if (![url.scheme.lowercaseString isEqualToString:@"https"]) {
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(YES, nil);
});
}
return;
}
#endif
NSError *jsonError = nil;
NSData *body = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&jsonError];
if (jsonError) {