Skip to content

Open deep links externally #139

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

Merged
merged 6 commits into from
Oct 18, 2024
Merged

Open deep links externally #139

merged 6 commits into from
Oct 18, 2024

Conversation

kiftio
Copy link
Contributor

@kiftio kiftio commented Oct 16, 2024

What changes are you making?

Open deep links externally, similar to ios here - Shopify/checkout-sheet-kit-swift#227

  • When links are clicked, we'll call onCheckoutLinkClicked()
  • The DefaultCheckoutEventProcessor will try to open the link
  • The client app should specified queries in its manifest to determine which links/schemes should open.

How to test

Tested with a couple of links

<a href="geo:40.712776,-74.005974?q=Statue+of+Liberty">
    Statue of Liberty
</a>

<a href="sms:+1234567890?body=Hello%20there!">
    Send SMS
</a>
deeplinks.mp4

Before you merge

Important


Checklist for releasing a new version

Tip

See the Contributing documentation for instructions on how to publish a new version of the library.

@kiftio kiftio requested a review from a team as a code owner October 16, 2024 22:37
@kiftio kiftio requested a review from Bruno125 October 16, 2024 22:38
Copy link
Contributor

@markmur markmur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment on lines +16 to +28
<queries>
<!-- for supporting deep links to the maps app -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="geo" />
</intent>

<!-- for supporting deep links to the messaging app -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="sms" />
</intent>
</queries>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if a developer doesn't include this in their manifest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like behaviour depends on API version.

For < 11:

It sounds a bit like a free-for-all, let me do some testing...

For >= 11:

When querying for info about other apps, the system filters info. So the code wouldn't detect that there's anything able to handle the scheme, and we'd log a warning instead of launching the intent.

And the <queries> element declares which apps you want to interact with and makes them visible. Inside queries you could also make it a specific package if you want a specific app instead of any app that can handle the intent as shown above. So, it should give quite good flexibility for clients to decide what they want to launch.

(https://developer.android.com/training/package-visibility)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth updating the warning to link to the readme, or to explain that the intent is probably missing from the manifest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested pre 11, yeah it opens up e.g. the maps, and messaging app even if the queries element is commented/missing from the manifest.

👍 I added a little more info to the README

@kiftio kiftio force-pushed the dk/open-deeplinks-externally branch from 1a1dd96 to 05fb7f1 Compare October 17, 2024 21:25
@kiftio kiftio merged commit 3e5cc6f into main Oct 18, 2024
4 checks passed
@kiftio kiftio deleted the dk/open-deeplinks-externally branch October 18, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants