React-native-firebase: Error: Use setDomainUriPrefix() instead, setDynamicLinkDomain() is only applicable for *.page.link and *.app.goo.gl domains.

Created on 22 May 2019  路  6Comments  路  Source: invertase/react-native-firebase


Issue



I'm trying to create a dynamic link.
I get this error when using firebase.links.DynamicLink() method:

const dynamicLink = new firebase.links.DynamicLink(
      `https://search.blip.fun/for/@${this.props.data.id}`,
      'https://search.blip.fun',
    ).android
      .setPackageName('com.midone')
      .android.setMinimumVersion(8)
      .android.setFallbackUrl('https://blip.fun');

console message:

Error: Use setDomainUriPrefix() instead, setDynamicLinkDomain() is only applicable for *.page.link and *.app.goo.gl domains.


Project Files






iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:

# N/A
#### `AppDelegate.m`:
// N/A


Android

Click To Expand

#### `android/build.gradle`:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 27
        supportLibVersion = "27.1.1"
        playServicesVersion = "15.0.1"
    }
    repositories {
        google()
        jcenter()
        maven { url "https://dl.bintray.com/android/android-tools/" }
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        maven { url "https://dl.bintray.com/android/android-tools/" }
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
//        maven { url "https://google.bintray.com/exoplayer" } // to resolve exoplayer error
    }
}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex')) {
                details.useVersion "27.1.1"
            }
        }
    }
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion "28.0.3"
            }
        }
    }
}

#### `android/app/build.gradle`:
apply plugin: "com.android.application"
// react native firebase crashlytics
apply plugin: "io.fabric"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
        entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = true

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.midone"
        minSdkVersion 16 // was 21
        targetSdkVersion 27 //was 22
        versionCode 9
        versionName "1.1.7"
        multiDexEnabled true // added
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a": 1, "x86": 2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    jcenter()

    maven {
        url  "https://adcolony.bintray.com/AdColony"
    }
}

dependencies {
    // react native firebase
    implementation "com.google.firebase:firebase-invites:16.1.1"
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true
    }
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation project(':react-native-firebase')
    // react native share
    implementation project(':react-native-share')
    // metrix
    implementation fileTree(include: ['*.jar'], dir: './../../node_modules/@metrixorg/react-native-metrix/android/libs')
    implementation project(':@metrixorg/react-native-metrix')
    // react native device info
    implementation project(':react-native-device-info')
    // react native interactable
    implementation project(':react-native-interactable')
    // react native fetch blob
    implementation(project(':react-native-fetch-blob')) {
        transitive = false
    }
    // react native audio toolkit
    implementation(project(':react-native-audio-toolkit')) {
        transitive = false
    }
    // realm
    implementation project(':realm')
    // react native video
    implementation project(':react-native-video')
    // react native music control
    implementation project(':react-native-music-control')
    // react native admob
    implementation project(':RNAdMob')
    implementation 'com.applovin:applovin-sdk:8.1.4'
    implementation 'com.google.ads.mediation:applovin:8.1.4.0'
    implementation 'com.adcolony:sdk:3.3.8'
    implementation 'com.google.ads.mediation:adcolony:3.3.8.0'
    // gif support
    implementation 'com.facebook.fresco:animated-gif:1.3.0'
    // version conflict resolutions
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.google.android.gms:play-services-analytics:16.0.8'
    implementation "com.google.android.gms:play-services-base:16.1.0"
    // react native
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.facebook.react:react-native:+'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

#### `android/settings.gradle`:
rootProject.name = 'midone'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-share'
project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')
include ':@metrixorg/react-native-metrix'
project(':@metrixorg/react-native-metrix').projectDir = new File(rootProject.projectDir, '../node_modules/@metrixorg/react-native-metrix/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-interactable'
project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/android')
include ':RNAdMob'
project(':RNAdMob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-admob/android')
include ':realm'
project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
include ':react-native-music-control'
project(':react-native-music-control').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-music-control/android')
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-audio-toolkit'
project(':react-native-audio-toolkit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-audio-toolkit/android/lib')
include ':app'

#### `MainApplication.java`:
package com.midone;

import android.app.Application;

import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
import io.invertase.firebase.links.RNFirebaseLinksPackage;
import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.RNFirebasePackage;
import cl.json.RNSharePackage;
import cl.json.ShareApplication;
import ir.metrix.reactnativesdk.MetrixReactNativePackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.wix.interactable.Interactable;
import com.sbugert.rnadmob.RNAdMobPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.brentvatne.react.ReactVideoPackage;
import com.futurice.rctaudiotoolkit.AudioPackage;
import com.tanguyantoine.react.MusicControl;
import io.realm.react.RealmReactPackage;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication, ShareApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
              new MainReactPackage(),
              new RNFirebaseAnalyticsPackage(),
              new RNFirebaseLinksPackage(),
              new RNFirebaseCrashlyticsPackage(),
              new RNFirebaseNotificationsPackage(),
              new RNFirebaseMessagingPackage(),
              new RNFirebasePackage(),
              new RNSharePackage(),
              new MetrixReactNativePackage(),
              new RNDeviceInfo(),
              new Interactable(),
              new RNAdMobPackage(),
              new AudioPackage(),
              new RealmReactPackage(),
              new RNFetchBlobPackage(),
              new ReactVideoPackage(),
              new MusicControl()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }

  @Override
  public String getFileProviderAuthority() {
    return BuildConfig.APPLICATION_ID + ".provider";
  }
}

#### `AndroidManifest.xml`:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.midone">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:name=".MainApplication"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="false"
        android:theme="@style/AppTheme"
        android:resource="@drawable/notification_icon"
        tools:ignore="GoogleAppIndexingWarning">
        <receiver
            android:name="com.midone.InstallReceiver"
            android:permission="android.permission.INSTALL_PACKAGES"
            android:exported="true" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>
        <service android:name="com.google.android.gms.analytics.CampaignTrackingService"
            android:enabled="true"
            android:exported="false" />
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-9749869740844916~1439146970"/>
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/notification_icon" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorAccent" />
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustPan"
            android:launchMode="singleTop"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
            </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:host="search.blip.fun" android:scheme="https"/>

            </intent-filter>
        </activity>
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

        <activity android:name="com.applovin.adview.AppLovinInterstitialActivity"
            android:configChanges="orientation|screenSize"/>

        <activity android:name="com.applovin.adview.AppLovinConfirmationActivity"
            android:configChanges="orientation|screenSize"/>
        <activity android:name="com.adcolony.sdk.AdColonyInterstitialActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:hardwareAccelerated="true"/>

        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>

        <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>
</manifest>


Environment

Click To Expand

**`react-native info` output:**

Environment:
  OS: macOS 10.14.4
  Node: 8.15.0
  Yarn: Not Found
  npm: 6.4.1
  Watchman: 4.9.0
  Xcode: Xcode 10.1 Build version 10B61
  Android Studio: 3.2 AI-181.5540.7.32.5056338

Packages: (wanted => installed)
  react: ^16.3.1 => 16.3.1
  react-native: ^0.55.3 => 0.55.3
- **Platform that you're experiencing the issue on**: - [ ] iOS - [] Android - [ ] **iOS** but have not tested behavior on Android - [x] **Android** but have not tested behavior on iOS - [ ] Both - **`Firebase` module(s) you're using that has the issue:** - Dynamic Links - **Are you using `TypeScript`?** - `N`




Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Links 馃搶 pin

Most helpful comment

I think the issue is now caused by android.setMinimumVersion(8) because in the docs it says that the minimumVersion is expected to be a number but in io/invertase/firebase/links/RNFirebaseLinks.java:272 minimumVersion is being parsed as a string:

 androidParameters.setMinimumVersion(Integer.parseInt(androidData.getString("minimumVersion")));

To get around that, pass the minimum version as a string instead:

    const dynamicLink = new firebase.links.DynamicLink(
     `https://search.blip.fun/for/@${this.props.data.id}`,
      'https://search.blip.fun'
    ).android
      .setPackageName('com.midone')
      .android.setMinimumVersion('8') // <--  add this as a string instead
      .android.setFallbackUrl('https://blip.fun')

Also, if you are using iOS, make sure that you pass the URL without https.

    const dynamicLink = new firebase.links.DynamicLink(
      `https://search.blip.fun/for/@${this.props.data.id}`,
      Platform.OS === 'ios' ? 'search.blip.fun' : 'https://search.blip.fun'
    ).android
      .setPackageName('com.midone')
      .android.setMinimumVersion('8')
      .android.setFallbackUrl('https://blip.fun')

Let me know if this helps!

All 6 comments

Happening with me too. Any updates?

I managed to get it to work by applying the changes in the PR: https://github.com/invertase/react-native-firebase/pull/2051

cc @Salakar for v6.

Changed android/src/main/java/io/invertase/firebase/links/RNFirebaseLinks.java Line 222:
from => builder.setDynamicLinkDomain(linkData.getString("dynamicLinkDomain"));
to => builder.setDomainUriPrefix(linkData.getString("dynamicLinkDomain"));

now I get this error:
Error: java.lang.Double cannot be cast to java.lang.String

BTW, I'm using react-native-firebase v5.2.5

I think the issue is now caused by android.setMinimumVersion(8) because in the docs it says that the minimumVersion is expected to be a number but in io/invertase/firebase/links/RNFirebaseLinks.java:272 minimumVersion is being parsed as a string:

 androidParameters.setMinimumVersion(Integer.parseInt(androidData.getString("minimumVersion")));

To get around that, pass the minimum version as a string instead:

    const dynamicLink = new firebase.links.DynamicLink(
     `https://search.blip.fun/for/@${this.props.data.id}`,
      'https://search.blip.fun'
    ).android
      .setPackageName('com.midone')
      .android.setMinimumVersion('8') // <--  add this as a string instead
      .android.setFallbackUrl('https://blip.fun')

Also, if you are using iOS, make sure that you pass the URL without https.

    const dynamicLink = new firebase.links.DynamicLink(
      `https://search.blip.fun/for/@${this.props.data.id}`,
      Platform.OS === 'ios' ? 'search.blip.fun' : 'https://search.blip.fun'
    ).android
      .setPackageName('com.midone')
      .android.setMinimumVersion('8')
      .android.setFallbackUrl('https://blip.fun')

Let me know if this helps!

@ahmadghizzawi Thanks a lot bro!

Was this page helpful?
0 / 5 - 0 ratings