From 76309354866e6142c0529182a902876d1f47b88d Mon Sep 17 00:00:00 2001 From: JarvanMo Date: Sat, 18 Nov 2023 23:44:55 +0800 Subject: [PATCH] avoid rough consuming OpenURL --- ios/Classes/FluwxPlugin.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ios/Classes/FluwxPlugin.m b/ios/Classes/FluwxPlugin.m index 31cbd698..84fabc53 100644 --- a/ios/Classes/FluwxPlugin.m +++ b/ios/Classes/FluwxPlugin.m @@ -426,7 +426,12 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction __strong typeof(weakSelf) strongSelf = weakSelf; [WXApi handleOpenURL:url delegate:strongSelf]; }; - +// Let's hold this until the PR contributor send feedback. +// if ([url.absoluteString contains:[self fetchWeChatAppId]]){ +// return YES; +// } else { +// return NO; +// } // simply return YES to indicate that we can handle open url request later return NO; @@ -1607,4 +1612,14 @@ - (SendMessageToWXReq *)requestWithText:(NSString *)text return req; } +-(NSString*)fetchWeChatAppId{ + NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary]; + NSArray* types = infoDic[@"CFBundleURLTypes"]; + for(NSDictionary* dic in types){ + if([@"weixin" isEqualToString:dic[@"CFBundleURLName"]]){ + return dic[@"CFBundleURLSchemes"][0]; + } + } + return nil; +} @end