Integrating with Expo Projects

Installation instructions

After installing the package, add the config plugin to the plugins array of your app.json or app.config.js. Then rebuild your app as described in the "Adding custom native code" guide.

In your app.json plugins array:

{
  ... 
  "plugins": ["@viro-community/react-viro"]
}

Using GVR, OVR_MOBILE, and/or AR on android

In order to change the XR mode on android, you can configure the plugin as follows:

Using one other option

{
 ...
 "plugins": [
    [
      "@viro-community/react-viro",
      {
        "androidXrMode": "GVR" // or "AR" or "OVR_MOBILE"
      }
    ]
  ],
}

Using multiple options

{
 ...
 "plugins": [
    [
      "@viro-community/react-viro",
      {
        "androidXrMode": ["GVR", "AR", "OVR_MOBILE"]
      }
    ]
  ],
}

You will also need to configure the android AppManifest.xml with some extra properties for this to work correctly.

1. Generate the android folder

expo prebuild --clean -p android --no-install

2. Modify AppManifest.xml

Add the code found under step 6 of the "For VR" step of the Install Android guide to your AppManifest.xml.

For VR

  • If your app supports Cardboard or Daydream, you should add them as a category to the intent-filter in your activity:
<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <!-- Add the following line for cardboard -->
    <category android:name="com.google.intent.category.CARDBOARD" />
    <!-- Add the following line for daydream -->
    <category android:name="com.google.intent.category.DAYDREAM" />
</intent-filter>
  • To support GearVR, you need to add the following under the <application> node:
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>

For API level 30 or above

If you are targetting API Level 30 or above, make sure to add the following lines to the <manifest>:

<queries>
    <package android:name="com.google.ar.core" />
</queries>

Running your expo app

iOS

expo run:ios will generate the ios/ folder and will run pod install in the project.

expo run:ios -d <device id | device name>

Android

expo run:android