在 UIWebView 中取得 JSContext 审核会被拒不?

2015-09-07 11:01:48 +08:00
 xi_lin


self.context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
取得 JSContext 的方法会不会审核被拒?
查了下拒不拒都有例子。。不敢用了都

4770 次点击
所在节点    iDev
12 条回复
jhdxr
2015-09-07 11:29:16 +08:00
没因为这个悲剧过
lynulzy
2015-09-07 13:09:00 +08:00
为什么会悲剧
siroccoicode
2015-09-07 13:55:20 +08:00
不会,从 iOS8.2 开始允许使用 JavascriptCore 来动态执行代码。
xi_lin
2015-09-07 14:39:38 +08:00
@jhdxr 那就好~
xi_lin
2015-09-07 14:40:06 +08:00
@lynulzy 因为 documentView.webView.mainFrame.javaScriptContext 不在官方文档里
xi_lin
2015-09-07 14:40:20 +08:00
@siroccoicode 在 iOS7 上用呢?
DingSoung
2015-09-07 14:47:52 +08:00
不会,用过。
lynulzy
2015-09-07 15:06:37 +08:00
和这个方法的效果一样吧?

- stringByEvaluatingJavaScriptFromString:
siroccoicode
2015-09-07 20:45:07 +08:00
@xi_lin 准确说是从 iOS7 开始公开了 JSC 的接口,发布 iOS8.2 的时候修改了开发者协议,内容如下

> 3.3.2 An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework, provided that such scripts and code do not change the primary purpose of the Application by providing features or functionality that are inconsistent with the intended and advertised purpose of the Application as submitted to the App Store.

实际上就意味着允许开发者直接使用 JavascriptCore 接口来进行一些更加``奇妙``的操作
xi_lin
2015-09-07 23:15:37 +08:00
@dingsoung thanks
xi_lin
2015-09-07 23:16:19 +08:00
@lynulzy 主要是想简化 js -> native 这一步,有了 JSContext 就可以直接 JSExport 直接调用方法了
xi_lin
2015-09-07 23:16:50 +08:00
@siroccoicode 原来如此,谢谢!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/218792

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX