Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26063] iOS: Implement WebView.onlink callback

GitHub Issuen/a
TypeStory
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-07-28T15:44:51.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsiOS
Labelsn/a
ReporterVictor Vazquez Montero
AssigneeHans Knöchel
Created2018-05-23T17:38:01.000+0000
Updated2018-10-09T17:09:04.000+0000

Description

description

Costumer is attempting to load a pdf for android using intents with webview. in the mobile app they are using webview control for displaying the remote web site by binding a URL. The web pages in the web site contains few pdf links. On click of normal hyperlinks, respective web page is being shown in the web view. Whereas, on tapping a pdf links, a blank window is getting opened in Android devices. In iOS it’s working fine and a PDF is showing. Per Jira WebView cannot disply PDF documents on Android. So they are using intents as a workaround to open the PDF link. The issue is that on click of the pdf link in the web view, they are unable to get the exact PDF url with any of Titanium WebView API methods or events The customer was able to do it natively and open the PDF's with intents.

Request

The customer wants to know how to get the exact PDF link using the webview API or if there is a workaround they could use.

additional information

attached are two apps. One is a titanium app and one is an android native application. [titanium app](https://axwaysoftware-my.sharepoint.com/personal/vvazquezmontero_axway_com/_layouts/15/guestaccess.aspx?guestaccesstoken=rsxSxfm51VH5t8MRm7YpDX1bHDfJfDfaycmtpKrlAEE%3d&docid=2_11a957eab95234b6ab84003e12f7b0b41&rev=1)

Attachments

FileDateSize
app.js2018-05-23T17:38:02.000+0000826
app (1).js2018-05-23T17:38:02.000+0000826
MyApplication_Android.zip2018-05-23T17:38:02.000+0000947392

Comments

  1. Hans Knöchel 2018-07-16

    PR: https://github.com/appcelerator/titanium_mobile/pull/10180 Test-Case:
       var window = Ti.UI.createWindow(),
           webView = Ti.UI.createWebView({
               url: 'https://india.gov.in/website-ministry-commerce-and-industry',
               onlink: function(e) {
                   if (e.url.endsWith('.pdf')) {
                       alert('PDF: ' + e.url);
                       return false;
                   }
                   return true;
               }
           });
       
       window.add(webView);
       window.open();
       
  2. Samir Mohammed 2018-09-11

    Verified fix with SDK version 7.5.0.v20180906093938. Able to get the exact link of a PDF when clicking on a link. *FR Passed (Test Steps):*

    Created a new Titanium application

    Added the code above in to the application

    Installed app on to the device

    Ran the app

    Clicked on a .PDF link

    able to see the exact link of the PDF which was clicked

    *Environment*
       APPC Studio:  5.1.0.201808080937
       APPC CLI: 7.0.6
       iphone 6 (12.0)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13.6
       Node.js Version: 8.9.1
       Xcode 10.0 beta 6
       
  3. Keerthi Mahalingam 2018-10-09

    Verified the fix on SDK 7.5.0.v20181005164109. PDF link works fine. Closing {CODE} Operating System Name = Mac OS X Version = 10.13.6 Architecture = 64bit Node.js Node.js Version = 8.9.1 npm Version = 5.5.1 Titanium CLI CLI Version = 5.1.1 Titanium SDK SDK Version =7.5.0.v20181005164109 Device =Iphone 62 iOS 12 iPhone 6 iOS 11 simulator {CODE}

JSON Source