Skip to content

Commit

Permalink
Merge pull request tidev#5409 from pec1985/timob-16514
Browse files Browse the repository at this point in the history
[TIMOB-16514] Prompt the user before making a call from a webview link
  • Loading branch information
vishalduggal committed Mar 3, 2014
2 parents ebea1bc + a3cf6ee commit 8bd6b65
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 13 additions & 0 deletions apidoc/Titanium/UI/WebView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ properties:
default: false
platforms: [iphone, ipad]

- name: handlePlatformUrl
summary: Lets the webview handle platform supported urls
description: |
By default any urls that are not handled by the Titanium platform but can be handled by the
shared application are automatically sent to the shared application and the webview does not
open these. When this property is set to `true` the webview will attempt to handle these
urls and they will not be sent to the shared application. An example is links to telephone
numbers.
type: Boolean
platforms: [iphone, ipad]
since: "3.3.0"
default: undefined. Behaves as if false

- name: hideLoadIndicator
summary: Hides activity indicator when loading remote URL.
type: Boolean
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SEL reloadMethod;

BOOL willHandleTouches;

BOOL willHandleUrl;
NSString* lastValidLoad;
}

Expand Down
8 changes: 7 additions & 1 deletion iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ - (void)setUrl_:(id)args
}
}

-(void)setHandlePlatformUrl_:(id)arg
{
[[self proxy] replaceValue:arg forKey:@"handlePlatformUrl" notification:NO];
willHandleUrl = [TiUtils boolValue:arg];
}

- (void)ensureLocalProtocolHandler
{
static dispatch_once_t onceToken;
Expand Down Expand Up @@ -685,7 +691,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)

UIApplication * uiApp = [UIApplication sharedApplication];

if ([uiApp canOpenURL:newUrl])
if ([uiApp canOpenURL:newUrl] && !willHandleUrl)
{
[uiApp openURL:newUrl];
return NO;
Expand Down

0 comments on commit 8bd6b65

Please sign in to comment.