Dolidod Teethtard
Dolidod Teethtard

Reputation: 623

Expo shared link is not clickable

I've been trying to create mechanism for my Expo app, that will allow users to share content of app (so I basically need linking with params, and I think I know how to do it, according to docs).

I wanted to start creating this mechanism with simple sharing, without params (just clickable link that opens app). Here's my code (executed when user presses share button):

share = async () => {
  await Share.share({
    message: Linking.makeUrl()
  })
}

It shares link as excepted (I tried it on messenger), but shared link is not clickable. I also tried using exp://192.168.100.3:190000 that points to my PC in the same LAN (I coped that from http://localhost:19002/), where metro bundler is running, and copying Tunnel link - neither of those worked, link is just a plain text, and if user clicks on it nothing happens. But, when I scan QR code, from http://localhost:19002/ (metro bundler page) application opens as excepted.

Upvotes: 4

Views: 3295

Answers (1)

Kaloyan Kosev
Kaloyan Kosev

Reputation: 13067

You're doing everything just fine!

The reason why a shared link is not clickable in some apps is simply because of the mechanisms of the other apps for "detecting" links from plain text and "linkifying" them.

You see, these links are actually "deep links" (custom URL schemes).

Here's an example. If I share this link: exp://192.168.100.3:190000 over Slack, it becomes "clickable", because it looks like Slack has a mechanism to detect these custom "deep links" which lead to a mobile app:

slack message

If I share the same link over Messanger, it outputs it as a plain text. This is because Messanger doesn't have a mechanism to detect these "deep links".

messenger message

In order for the link to "click", it must be rendered in an anchor tag. Messenger simply linkifies only "known" web links (http://, https://...), not custom ones.

The QR code reader in your case opens your deep link, because it has a mechanism to detect "deep links".

So, if you want a reliable way for making your links always "clickable", here's the workaround: spin-off a web site. When people generate (and share) links, they share web links https://your-server. When they open these links -> the web server redirects them with the exp://... (or your custom) scheme. If users have your app installed - the links will open with your app.

Upvotes: 7

Related Questions