I figured out that following intent-filters are missing from AndroidManifest.xml file while building locally with "ionic cordova" even though cordova-plugin-customurlscheme is configured in build.xml.
<intent-filter>
<action
android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT" />
<category
android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="moodlemobile" />
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT" />
<category
android:name="android.intent.category.BROWSABLE" />
<data
android:scheme=" "
android:host=" "
android:pathPrefix="/" />
</intent-filter>
After adding intent-filters to AndroidManifest.xml made it work. Though this is not an ideal solution.