Closed seanLee closed 6 years ago
JavascriptInterfaceObject调用的方法返回值为void,且服务器传参为Json字符串时会闪退.
修改test.html代码为如下
test.html
function callSyn() { alert(dsBridge.call("testSyn", "{\"url\":\"https://gslb.miaopai.com/stream/U8wK~SkowQqfbmyHNhFyDH0vy-KhqWvmdQMHLQ__.mp4?ssig=f3c7cac4c571591cc1b4c1da917a6ea2&time_stamp=1526013092137&cookie_id=c90730d82972cf7f169f2d7d246fc6a9&vend=1&os=2&partner=1&platform=2&cookie_id=c90730d82972cf7f169f2d7d246fc6a9&refer=miaopai&scid=U8wK%7ESkowQqfbmyHNhFyDH0vy-KhqWvmdQMHLQ__\"}")) }
修改JsApiTest.m代码如下
JsApiTest.m
- (void) testSyn:(NSString *) msg { // return [msg stringByAppendingString:@"[ syn call]"]; NSLog(@"%@",@"call"); }
API签名是有要求的,不能返回void, 可以参考文档:
In order to be compatible with IOS , we make the following convention on Object-C API signature: For synchronous API. (id) handler:(id) msg
In order to be compatible with IOS , we make the following convention on Object-C API signature:
For synchronous API.
(id) handler:(id) msg
JavascriptInterfaceObject调用的方法返回值为void,且服务器传参为Json字符串时会闪退.
修改
test.html
代码为如下修改
JsApiTest.m
代码如下