需求: 在iOS9中响应openURL调用
代码:
%hook SMSApplication
- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return OpenURL_handle(url);
}
- (BOOL) application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
{
return OpenURL_handle(url);
}
-(BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
return OpenURL_handle(url);
//return %orig;
}
-(BOOL) openURL:(NSURL *)url
{
return OpenURL_handle(url);
}
操作步骤:
代码中OpenURL_handle是自定义的静态函数,在iOS10中能响应(从其他app调用openURL "sms://xxxxxxxx"
),但在iOS9中就没有响应。
** 环境: iOS 9