iOS custom keyboard第三方输入法
例如正在微信的界面的键盘想要用语音输入功能,于是通过键盘长按空格按键跳转到了扩展所在的APP开启语音识别功能,开启之后如何返回微信的界面
只能拿到键盘所在应用的Bundle ID,拿不到URL Schemes,
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface UISystemNavigationAction : NSObject
@property(nonatomic, readonly, nonnull) NSArray<NSNumber*>* destinations;
-(BOOL)sendResponseForDestination:(NSUInteger)destination;
///在需要跳转回上一个APP的时候调用该方法
-(BOOL)jumpBackToPreviousApp;
#import "UISystemNavigationAction.h"
@implementation UISystemNavigationAction
-(BOOL)jumpBackToPreviousApp{
Ivar sysNavIvar = class_getInstanceVariable(UIApplication.self, "_systemNavigationAction");
UIApplication* app = UIApplication.sharedApplication;
UISystemNavigationAction* action = object_getIvar(app, sysNavIvar);
if (!action) {
return NO;
}
NSUInteger destination = action.destinations.firstObject.unsignedIntegerValue;
return [action sendResponseForDestination:destination];
}
@end