Skip to content

Commit

Permalink
fix #69
Browse files Browse the repository at this point in the history
  • Loading branch information
duwen committed Nov 19, 2018
1 parent 1164660 commit f0e3c72
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
Binary file modified Build/Products/Debug-iphonesimulator/libdsbridge.a
Binary file not shown.
2 changes: 1 addition & 1 deletion dsBridge.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "dsBridge"
s.version = "3.0.5"
s.version = "3.0.6"
s.summary = "An ios bridge for calling functions synchronously and asynchronously between JavaScript and Object-C in WKWebView/UIWebView"

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 2 additions & 0 deletions dsbridge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
812F1D3B216F1F9D00B5BD0C /* publish.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = publish.sh; sourceTree = "<group>"; };
8142EA1C214212E600BEE5C0 /* dsbridgedemo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dsbridgedemo-Bridging-Header.h"; sourceTree = "<group>"; };
8142EA1D214212E700BEE5C0 /* JsApiTestSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsApiTestSwift.swift; sourceTree = "<group>"; };
815612E92020304600C4F5CD /* InternalApis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InternalApis.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -112,6 +113,7 @@
818F0B851E18C08100679925 = {
isa = PBXGroup;
children = (
812F1D3B216F1F9D00B5BD0C /* publish.sh */,
81CFC867202C42AA00CF9D83 /* img */,
81CFC861202953CB00CF9D83 /* .travis.yml */,
81CFC85F2029456C00CF9D83 /* readme-chs.md */,
Expand Down
7 changes: 4 additions & 3 deletions dsbridge/DWKWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ -(NSString *)call:(NSString*) method :(NSString*) argStr
do{
if(args && (cb= args[@"_dscbstub"])){
if([JavascriptInterfaceObject respondsToSelector:selasyn]){
__weak typeof(self) weakSelf = self;
void (^completionHandler)(id,BOOL) = ^(id value,BOOL complete){
NSString *del=@"";
result[@"code"]=@0;
Expand All @@ -280,18 +281,18 @@ -(NSString *)call:(NSString*) method :(NSString*) argStr
del=[@"delete window." stringByAppendingString:cb];
}
NSString*js=[NSString stringWithFormat:@"try {%@(JSON.parse(decodeURIComponent(\"%@\")).data);%@; } catch(e){};",cb,(value == nil) ? @"" : value,del];

__strong typeof(self) strongSelf = weakSelf;
@synchronized(self)
{
UInt64 t=[[NSDate date] timeIntervalSince1970]*1000;
jsCache=[jsCache stringByAppendingString:js];
if(t-lastCallTime<50){
if(!isPending){
[self evalJavascript:50];
[strongSelf evalJavascript:50];
isPending=true;
}
}else{
[self evalJavascript:0];
[strongSelf evalJavascript:0];
}
}

Expand Down
2 changes: 2 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
pod trunk push --allow-warnings

0 comments on commit f0e3c72

Please sign in to comment.