Mohammed Atif
Mohammed Atif

Reputation: 4513

How to add multiple url schemes in Expo App without ejecting?

I am going through this link to add deeplink to my Expo App but could not find any document to add multiple schemes. Is it even possible to add multiple schemes in Expo App without ejecting it?

Upvotes: 3

Views: 5507

Answers (4)

Mykyta Chernenko
Mykyta Chernenko

Reputation: 403

This is the only post I found about adding a new url schema, so I'll leave the comment here. In case you need to add a URL schema to your ios without ejecting, just use infoPlist key in app.json

 "ios": {
      ...
      "infoPlist": {
         "CFBundleURLTypes": [
          {
            "CFBundleURLSchemes": ["com.googleusercontent.apps.SOME_URL_1"]
          },
          {
            "CFBundleURLSchemes": ["com.googleusercontent.apps.SOME_URL_2"]
          }
        ]
      }
    },

Upvotes: 1

eyettea
eyettea

Reputation: 1446

You can pass an array of strings instead of just a string in the scheme config property of expo. The documentation has a bug and doesn't explain this. I wrote a post about it.

{
  "expo": {
    "scheme": ["myapp1", "myapp2"]
  }
}

Upvotes: 4

bberak
bberak

Reputation: 302

You can associate multiple URLs to your Expo app without ejecting by configuring the app.json file.

For iOS, you will need to modify the associatedDomains key:

{
    ...
    "ios": {
        ...
        "associatedDomains": ["applinks:mydomain.com", "applinks:myotherdomain.com"]
    }
}

For Android, you will need to modify the intentFilters key:

{
    ...
    "android": {
        ...
        "intentFilters": [{
            "action": "VIEW",
            "autoVerify": true || false,
            "data": [
                { "scheme": "https", "host": "mydomain.com" },
                { "scheme": "https", "host": "myother.com" }
            ]
            "category": ["BROWSABLE", "DEFAULT"]
        }]
    }

Furthermore, depending on your requirements you might need to verify ownership of the domains you want to associate with your app. Both iOS and Android have different (but similar) ways to achieve this. You can find detailed info about the process in Expo's deep linking documentation.

Upvotes: 3

AtulParmar
AtulParmar

Reputation: 4570

For IOS application you can add multiple URL schemes using the following steps.

Add URL scheme in info.plist file by adding the following code. (click on info.plist file right click and open as source code.)

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>one</string>
            <string>two</string>
        </array>
    </dict>
</array>

enter image description here

Upvotes: -1

Related Questions