Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27205] Webview http redirects not working as on 7.5.1

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-08-29T21:48:09.000+0000
Affected Version/sRelease 8.0.0
Fix Version/sRelease 8.2.0
ComponentsiOS
Labelsdefect, engSchedule
ReporterFabian Martinez
AssigneeVijay Singh
Created2019-07-01T16:34:17.000+0000
Updated2019-08-29T21:48:09.000+0000

Description

We have an integration with Plaid (https://plaid.com/) where we use a web view and capture redirects on the site. From their docs: “Communication between the WebView and your app is handled by HTTP redirects rather than client-side JavaScript callbacks. These redirects should be intercepted by your app.” Working code: $.bankPlaidLinkWebView.addEventListener('beforeload', function(_e) { if (_e.url.indexOf(schemaOrString) > -1) { $.bankPlaidLinkWebView.stopLoading(); handleCommand(_e.url); } }); beforeload triggers with an url the same as the one I sent. After that we should listen for an url that has "plaidlink" as the scheme. From the docs: "All redirect URLs have the scheme plaidlink. The event type is communicated via the URL host and data is passed via the querystring. There are two supported events, connected and exit, which are documented below." These redirects are never triggered and it always trigger my original url. This is working on a published app but has stopped working since SDK 8.0.0.GA, I guess it’s related to the switch to WKWebview. Checking TiUIWebView.m I found that changing line #995 from @"url" : webView.URL.absoluteString to: @"url" : navigationAction.request.URL fixes the problem. Don't know if you should fix it here or on the newly introduced 'redirect' event. This was working before 8.0 and works if I change the mentioned line.

Comments

  1. Rakhi Mitro 2019-07-02

    [~inzori], Thanks for reporting this. Can you please test this issue on SDK 8.0.2.GA and let us know how it goes?
  2. Fabian Martinez 2019-07-02

    Hi, it is already tested on 8.0.2.GA and the problem still remains. 8.0.0.GA to 8.0.2.GA all uses {color:red}@"url" : webView.URL.absoluteString{color} when triggering the events beforeload and redirect. To make it work as it used to we need it with this: {color:red}@"url" : navigationAction.request.URL.absoluteString{color} At least on one of the events. Thanks
  3. Vijay Singh 2019-07-02

    [~inzori] Can you please give a complete test case to reproduce it? Thanks!
  4. Fabian Martinez 2019-07-02

    Here's a test case. [Test case 8.0.2.GA](https://inzori.com/fmartinez/testwebview.zip) Steps: 1- Click on "Plaid" button, it will open a new window with a webview that loads the page from plaid.com 2- check the console log, it displays the url: https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&key=361a76619ae1a2e0b7da377e218f4d&env=sandbox&product=transactions&clientName=Inzori&apiVersion=v2 3- Click on the "X" in the upper right corner. It should close the window and go back to the screen with the "plaid" button. 4- It displays a white screen. Check the console log again, same URL. Replace TiUIWebView.m line 997 with navigationAction.request.URL.absoluteString instead of webView.URL.absoluteString. Clean and compile again. Repeat the steps above and check the URL when clicking the "X", it displays: plaidlink://event?error_code=&error_message=&error_type=&event_name=EXIT&exit_status=requires_credentials&institution_search_query&link_session_id=f82814f9-920e-4309-8914-5a72b24c2e2f&mfa_type&request_id×tamp=2019-07-02T17%3A18%3A40.031Z&view_name and closes the window.
  5. Vijay Singh 2019-07-02

    Here you go [~inzori]. Thanks for reporting! PR - https://github.com/appcelerator/titanium_mobile/pull/11020
  6. Keerthi Mahalingam 2019-08-13

    FR passed.waiting for PR's merge
  7. Samir Mohammed 2019-08-23

    [~vijaysingh] Please could you add a PR for 8_3_X.
  8. Christopher Williams 2019-08-29

    merged to master (8.2.0)
  9. Keerthi Mahalingam 2019-08-29

    Verified the fix on sdk 8.2.0.v20190829124255.Webview http redirect works as expected. closing {CODE} Name = Mac OS X Version = 10.14.5 Architecture = 64bit Node.js Node.js Version = 10.16.2 npm Version = 6.9.0 Titanium CLI CLI Version = 5.2.1 Titanium SDK SDK Version = 8.2.0.v20190829124255 Device -iPhone XR iOS 13 Simulator -iPhone 6 iOS 12 {CODE}

JSON Source