Sma Ma
Sma Ma

Reputation: 3685

How to get link to redirect to expo app during development

How to get link to redirect to expo app during development?

I have a react native expo app. During development started with èxpo start. Now I like to use OAuth 2.0 authentication. Therefor I need a redirect URL.

My app.json looks like:

{
  "expo": {
    "name": "myapp",
    "scheme": "myapp",
    "slug": "myapp",
    "privacy": "public",

There is a documentation for linking to the app, but it's not clear to me which link to use during development to get redirected to the app launched in expo. https://docs.expo.io/versions/latest/workflow/linking/#linking-to-your-app

I think myapp:// is wrong because the app is still in development using expo start and not deployed as apk as standalone app.

Using https://auth.expo.io/@myuser/myapp resulted in:
enter image description here

Upvotes: 7

Views: 11750

Answers (3)

Fabio Simoes
Fabio Simoes

Reputation: 11

In the newer versions of Expo Go, this feature works for me

 const [request, response, promptAsync] = useAuthRequest(
    {
      clientId: CLIENT_ID,
      scopes: [],
      redirectUri: Linking.createURL(),
    },
    discovery
  );

the Authorization callback URL in the github is the response of Linking.createURL()

Upvotes: 1

Oleg Levin
Oleg Levin

Reputation: 3621

Get the right link value at runtime :

Linking.makeUrl()

will resolve dynamicly according to running environment: dev, standalone app...


Note : Linking from expo-linking does have this method, but Linking from react-native does not.

Upvotes: 6

abdullah farooqui
abdullah farooqui

Reputation: 71

Linking.createURL() is available in [email protected] and higher. If you are using an older version, use Linking.makeUrl() instead.

Upvotes: 7

Related Questions