Files
keyboard/Shared/KBKeyboardPermissionManager.h
2025-11-03 13:25:41 +08:00

38 lines
1.1 KiB
Objective-C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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