This commit is contained in:
2025-11-03 13:25:41 +08:00
parent ffea9d2022
commit c7021e382e
12 changed files with 384 additions and 27 deletions

View File

@@ -0,0 +1,37 @@
//
// KBKeyboardPermissionManager.h
// 主 App/键盘扩展 共用的“键盘启用 + 完全访问”权限管理
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, KBFARecord) {
KBFARecordUnknown = 0,
KBFARecordDenied = 1,
KBFARecordGranted = 2,
};
/// 统一权限管理App 与扩展均可使用)
@interface KBKeyboardPermissionManager : NSObject
+ (instancetype)shared;
/// App 侧:是否已添加并启用了自定义键盘(通过遍历 activeInputModes 粗略判断)
- (BOOL)isKeyboardEnabled;
/// 最后一次由扩展上报的“完全访问”状态(来源:扩展运行后写入共享钥匙串)
- (KBFARecord)lastKnownFullAccess;
/// 扩展侧:上报“完全访问”状态(写入共享钥匙串,以便 App 读取)
- (void)reportFullAccessFromExtension:(BOOL)granted;
/// App 侧:若未满足“已启用键盘 + 完全访问(或未知)”则展示引导页KBPermissionViewController
- (void)presentPermissionIfNeededFrom:(UIViewController *)presenting;
@end
NS_ASSUME_NONNULL_END