Search code examples
oculusquest

HTTP request inside override GrabBegin not calling


I override GrabBegin function and try to make a Post request whenever user grab an object. But it looks like the Request was never called. No error or warning issue from the condole. I also tried to print to console by using Debug.Log("Grab Begin") but it was never printed to the console. I am not sure what I am missing. I was still able to grab an object through the VR

public class AromaShooterGrabbable : OVRGrabbable
{
    override public void GrabBegin(OVRGrabber hand, Collider grabPoint) {
        base.GrabBegin(hand, grabPoint);

        RestClient.Post<AromaShooterResponse>(url, new Post {
            duration = 3000,
            channel = 1,
            intensity = 100
        }).Then(response => {
            Debug.Log(response.status);
        }).Catch(error => {
            Debug.Log(error.Message);
        });
    }
}

Solution

  • Answering my own question.

    In AndroidManifest.OVRSubmission.xml add:

    <manifest>
      <uses-permission android:name="android.permission.INTERNET" />
      <application
        android:networkSecurityConfig="@network_sec_config"
      >
    </manifest>
    

    In network_sec_config.xml add:

    <domain-config cleartextTrafficPermitted="true">
      <domain includeSubdomains="true">*</domain>
    </domain-config>
    <base-config cleartextTrafficPermitted="true"></base-config>