Skip to content

Android: Visiting cross-domain URL does not trigger didOpenExternalUrl #233

@pfeiffer

Description

@pfeiffer

Description

After upgrading the dependency to Hotwire Native Android, it seems that proposing visits to a cross-domain URL does not trigger didOpenExternalUrl as previously.

The library seems to override didOpenExternalUrl from Hotwire Native to handle this, but this method no longer exists in Hotwire Native Android. On iOS it works.

Culprint:

The issue seems to be that the onDidOpenExternalUrl is no longer provided or invoked by Hotwire Native Android when a cross-domain navigation happen. Instead, they handle crossdomains navigations with a Route Decision Handler.

Solution:

One solution could be to implement the cross-domain check in the visitProposedToLocation and instead of sending RNVisitableViewEvent.VISIT_PROPOSAL to the RN side, we could trigger the RNVisitableViewEvent.OPEN_EXTERNAL_URL with the URL of the host of the location does not match the base URL.

Steps to reproduce

To reproduce:

  1. In a VisitableView, open a URL containing a link to a cross-domain URL, eg. https://www.github.com
  2. Tap the link

Expected behavior:

  1. The tapping of the external link should (per default) open a browser window using Linking.open(..)

Actual behavior:

  1. A onVisitProposal is triggered with advance action and location = https://www.github.com

Snack or a link to a repository

React Native Turbo version

1.2.1

React Native version

0.74.7

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions