Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with auto-detected links not opening. #601

Merged
merged 2 commits into from
Jan 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions lib/ProMotion/web/web_screen_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,34 @@ def refresh; web.reload; end
def stop; web.stopLoading; end
alias :reload :refresh

def open_in_chrome(inRequest)
def open_in_chrome(in_request)
# Add pod 'OpenInChrome' to your Rakefile if you want links to open in Google Chrome for users.
# This will fall back to Safari if the user doesn't have Chrome installed.
chrome_controller = OpenInChromeController.sharedInstance
return open_in_safari(inRequest) unless chrome_controller.isChromeInstalled
chrome_controller.openInChrome(inRequest.URL)
return open_in_safari(in_request) unless chrome_controller.isChromeInstalled
chrome_controller.openInChrome(in_request.URL)
end

def open_in_safari(inRequest)
def open_in_safari(in_request)
# Open UIWebView delegate links in Safari.
UIApplication.sharedApplication.openURL(inRequest.URL)
UIApplication.sharedApplication.openURL(in_request.URL)
end

# UIWebViewDelegate Methods - Camelcase
def webView(inWeb, shouldStartLoadWithRequest:inRequest, navigationType:inType)
if self.external_links == true && inType == UIWebViewNavigationTypeLinkClicked
if defined?(OpenInChromeController)
open_in_chrome inRequest
else
open_in_safari inRequest
def webView(in_web, shouldStartLoadWithRequest:in_request, navigationType:in_type)
if %w(http https).include?(in_request.URL.scheme)
if self.external_links == true && in_type == UIWebViewNavigationTypeLinkClicked
if defined?(OpenInChromeController)
open_in_chrome in_request
else
open_in_safari in_request
end
return false # don't allow the web view to load the link.
end
return false #don't allow the web view to load the link.
end

load_request_enable = true #return true on default for local file loading.
load_request_enable = !!on_request(inRequest, inType) if self.respond_to?(:on_request)
load_request_enable = !!on_request(in_request, in_type) if self.respond_to?(:on_request)
load_request_enable
end

Expand Down