+ [ios] judge task from config
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/996bf9d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/996bf9d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/996bf9d4 Branch: refs/heads/0.16-dev Commit: 996bf9d4066cf1a7289ffc1342a0590fa2b74a1d Parents: 5dbcb87 Author: é½å±± <sunjjb...@163.com> Authored: Thu Sep 7 17:14:50 2017 +0800 Committer: é½å±± <sunjjb...@163.com> Committed: Thu Sep 7 17:14:50 2017 +0800 ---------------------------------------------------------------------- .../WeexSDK/Sources/Module/WXPrerenderManager.m | 32 +++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/996bf9d4/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m b/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m index 90f1c7f..2f61925 100644 --- a/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m +++ b/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m @@ -234,8 +234,38 @@ static NSString *const MSG_PRERENDER_SUCCESS = @"success"; } + (BOOL)isTaskExist:(NSString *)url{ + if( !url ||url.length == 0){ + return NO; + } + id configCenter = [WXSDKEngine handlerForProtocol:@protocol(WXConfigCenterProtocol)]; + if ([configCenter respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) { + BOOL switchOn = NO; // defautle NO + id switchOnValue = [configCenter configForKey:@"iOS_weex_prerender_config.is_switch_on" defaultValue:@YES isDefault:NULL]; + if(switchOnValue){ + switchOn = [switchOnValue boolValue]; + } + if(!switchOn){ + return NO; + } + + id urlsValue = [configCenter configForKey:@"iOS_weex_prerender_config.urls" defaultValue:NULL isDefault:NULL]; + if(urlsValue){ + NSData *data = [urlsValue dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + NSArray *urls = [WXUtility JSONObject:data error:&error]; + if(urls && [urls count]>0){ + for (NSString *configUrl in urls) { + if(configUrl && [[WXPrerenderManager getTaskKeyFromUrl:configUrl] isEqualToString:[WXPrerenderManager getTaskKeyFromUrl:url]]) { + return YES; + } + } + + } + } + + } - return [[WXPrerenderManager sharedInstance] isTaskExist:url]; + return NO; } - (BOOL)isTaskExist:(NSString *)url