react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

🔥 DynamicLinks iOS: `await dynamicLinks().getInitialLink()` works on debug, but doesn't work on release mode

Open noway opened this issue 5 years ago • 79 comments

Issue

await dynamicLinks().getInitialLink() works in debug mode, but doesn't work in release mode on iOS, on certain iPhones. Please not that the app does not crash, but rather null is returned by await dynamicLinks().getInitialLink() when it should be returning the dynamic link url. onLink seems to be working fine, haven't noticed any issues with that. It is confirmed not to work on iPhone Xs with iOS 12.4.0 (device) and iPhone Xs with iOS 12.2.0 (Simulator). I use preview page in my links. Tested both from Safari via preview page and from Messages/Notes app, but NOT through App Store. See testing matrix:

iPhone Xs with iOS 12.4.0 (device), debug: not tested iPhone Xs with iOS 12.4.0 (device), release: ❌ broken iPhone Xs with iOS 12.2.0 (Simulator), debug: ✅ works iPhone Xs with iOS 12.2.0 (Simulator), release: ❌ broken iPhone Xs with iOS 13.0.0 (Simulator), debug: ✅ works iPhone Xs with iOS 13.0.0 (Simulator), release: ✅ works iPhone 7 Plus with iOS 12.4.1 (device), debug: ✅ works iPhone 7 Plus with iOS 12.4.1 (device), release: ✅ works

This issue is critical because it affects a significant amount of the iOS user base, I think it might be affecting any iPhone X and higher users who haven't updated to iOS 13 yet (i.e. everyone but the early adopters) which is a very substantial percentage of all iOS users.

The issue might be releated to https://github.com/invertase/react-native-firebase/issues/1901, and if so the issue has failed at least 2 Firebase customers, who since have chosen to switch to branch.io instead. See https://github.com/invertase/react-native-firebase/issues/1901#issuecomment-469242110 and https://github.com/invertase/react-native-firebase/issues/1901#issuecomment-477839585

Android is working flawlessly as far as I've tested, with getInitialLink, onLink, install through Play Store all working perfectly. Only issue is iOS.

Code I'm using:

  componentDidMount() {
    this.init()
  }

  init = async () => {
    const initialUrl = await dynamicLinks().getInitialLink()
    this.setState({ dynamicLinkUrl: initialUrl ? initialUrl.url : null })
    console.log('dynamicLinkUrl', initialUrl ? initialUrl.url : null)
    Alert.alert('dynamicLinkUrl', initialUrl ? initialUrl.url : 'null')
    await this.authenticate()
    console.log('this.props.user.id', this.props.user.id)
    this.unsubscribeOnLink = dynamicLinks().onLink(this.onLink)
  }

  onLink = ({ url }) => {
    console.log('onLink url', url, Date.now())
    this.onDynamicLink(url)
  }


Project Files

iOS

Click To Expand

ios/Podfile:

  • [ ] I'm not using Pods
  • [x] I'm using Pods and my Podfile looks like:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'mycoolappapp' do

  # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-ART', :path => '../node_modules/react-native/Libraries/ART'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'mycoolappappTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

target 'mycoolappapp-tvOS' do
  # Pods for mycoolappapp-tvOS
  target 'mycoolappapp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignal', '>= 2.9.3', '< 3.0'
end

AppDelegate.m:

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <RNCPushNotificationIOS.h>
#import <React/RCTLog.h>
#import <RNFBDynamicLinksAppDelegateInterceptor.h>
@import Firebase;

@interface NSString(JB)
-(NSString *) stringValue;
@end

@implementation NSString(JB)
  -(NSString *) stringValue {
  return self;
}
@end


@implementation AppDelegate

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIROptions defaultOptions].deepLinkURLScheme = @"app.mycoolapp";
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure]; // It is recommended to add the line within the method BEFORE creating the RCTRootView
  }

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"mycoolappapp"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:0.08f green:0.10f blue:0.15f alpha:1];

  [[FBSDKApplicationDelegate sharedInstance] application:application
                           didFinishLaunchingWithOptions:launchOptions];
  
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
  return YES;
}

// FYI: Deprecated in iOS 9
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
  BOOL isHandled = [[FBSDKApplicationDelegate sharedInstance] application:application
                                                        openURL:url
                                              sourceApplication:sourceApplication
                                                     annotation:annotation];
  if (!isHandled) {
    isHandled = [[RNFBDynamicLinksAppDelegateInterceptor sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
  }
  return isHandled;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<NSString *, id> *)options {
  BOOL isHandled = [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options];
  if (!isHandled) {
    isHandled = [[RNFBDynamicLinksAppDelegateInterceptor sharedInstance] application:application openURL:url options:options];
  }
  return isHandled;
}

// FYI: Seems to double up the onLink call. But i added a memoized debounce there so should be all good.
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *))restorationHandler {
  return [[RNFBDynamicLinksAppDelegateInterceptor sharedInstance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}

// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
  [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
  [RNCPushNotificationIOS didReceiveLocalNotification:notification];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

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 = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com' }

    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.0")
        classpath 'com.google.gms:google-services:4.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

android/app/build.gradle:

apply plugin: "com.android.application"

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",
 *
 *   // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
 *   bundleCommand: "ram-bundle",
 *
 *   // 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",
    enableHermes: false,  // clean and rebuild if changing
]

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 = false

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

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "app.mycoolapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 236
        versionName "2.3.6"
        multiDexEnabled true
        missingDimensionStrategy 'react-native-camera', 'general'
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            keyAlias 'mycoolapp-android-alias'
            keyPassword 'ugh'
            storeFile file('/Users/ilia/mycoolapp/mycoolapp-release-key-android.jks')
            storePassword 'ugh'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            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:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            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
            }

        }
    }

    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.core:core:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation "com.google.android.gms:play-services-location:16.0.0"
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'

    if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }
}

// 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'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

android/settings.gradle:

rootProject.name = 'mycoolappapp'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ':@react-native-mapbox-gl_maps'
project(':@react-native-mapbox-gl_maps').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-mapbox-gl/maps/android/rctmgl')

include ':app'

MainApplication.java:

package app.mycoolapp;

import com.facebook.FacebookSdk;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import androidx.multidex.MultiDexApplication;

import java.util.List;

public class MainApplication extends MultiDexApplication implements ReactApplication {

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

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      return packages;
    }

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

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

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

AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.mycoolapp"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.VIBRATE" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <!-- Approximate location - If you want to use promptLocation for letting OneSignal know the user location. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!--  Precise location If you want to use promptLocation for letting OneSignal know the user location. -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <application
        android:name=".MainApplication"
        android:allowBackup="true"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:icon="@mipmap/ic_launcher"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true">

        <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled"
            android:value="false"/>
        <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled"
            android:value="false"/>
        <meta-data android:name="com.facebook.sdk.AutoInitEnabled"
            android:value="false"/> <!--OPTIONAL-->

        <activity android:name=".SplashActivity"
            android:label="@string/app_name"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize">
            <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="open.mycoolapp.app" android:scheme="http"/>
                <data android:host="open.mycoolapp.app" android:scheme="https"/>
                <data android:host="emailauth.mycoolapp.app" android:scheme="http"/>
                <data android:host="emailauth.mycoolapp.app" android:scheme="https"/>
            </intent-filter>
        </activity>

        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>

        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
            android:value="mycoolapp app alerts"/>
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
            android:value="Make sound and pop on screen"/>
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
            android:resource="@android:color/white"/>

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>

        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>
</manifest>


Environment

Click To Expand

react-native info output:

System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    Memory: 349.36 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.6.0 - ~/.nvm/versions/node/v12.6.0/bin/node
    npm: 6.11.3 - ~/.nvm/versions/node/v12.6.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: ^0.60.5 => 0.60.5
  • Platform that you're experiencing the issue on:
    • [x] iOS
    • [ ] Android
    • [ ] iOS but have not tested behavior on Android
    • [ ] Android but have not tested behavior on iOS
    • [ ] Both
  • react-native-firebase version you're using that has this issue:
    "@react-native-firebase/app": "^6.0.0",
    "@react-native-firebase/auth": "^6.0.0",
    "@react-native-firebase/dynamic-links": "^6.0.0",
  • Firebase module(s) you're using that has the issue:
    • DynamicLinks
  • 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]

noway avatar Oct 01 '19 07:10 noway

I am experiencing the same issue..

  • I click on a dynamic link, takes me to the appcenter/appstore/testflight.
  • I don't click on install, instead build and launch my app in debug/release mode (both work). The app catches the dynamic link's corresponding deeplink on first launch (as the dynamic link is pasted in the clipboard)
  • However the app with the same code, on deploying to appcenter/appstore/testflight, doesn't recognise the dynamic link (even though it's in the clipboard at the time of install).
  • Another observation is that the clipboard gets cleared off after the launch.
  • However, post installation, when the same dynamic link is clicked from notepad, it takes me into the app, resolves its corresponding deep link and works as expected. If I wanted to achieve this I would have gone with a DEEP LINK instead of a DYNAMIC LINK. This issue beats the entire point of Dynamic link as it doesn't serve the purpose of taking me to the intended user activity.

I have the same config as @noway and this is a very valid issue.

ram95krishh avatar Oct 03 '19 13:10 ram95krishh

Hey @noway.. After a lot of tries, this set up got everything (even first open after install scenario) working for me. Can you check this out and let me know: https://medium.com/@ramakrishnan_89356/firebase-dynamic-links-for-your-react-native-app-ios-setup-only-c6e1f5a7944e

ram95krishh avatar Oct 14 '19 06:10 ram95krishh

@ram95krishh through no power that I actually have, I grant you 10 internet points for writing such an excellent detailed guide for future people :-)

mikehardy avatar Oct 14 '19 14:10 mikehardy

@mikehardy Haha, thanks mate, that means a lot :D

ram95krishh avatar Oct 18 '19 09:10 ram95krishh

This does look like an interesting approach, I gonna need to try it out. Atm we just have broken implementation in production and we remedy it by just trigerring stuff we need on first sign up.

noway avatar Oct 21 '19 03:10 noway

For me the issue wasn't solved with the code in that article. This is because I was using a custom domain and this hasn't been documented properly.

The solution for me was the default code from the rn-firebase docs and adding the custom domain to the Info.plist file:

  <key>FirebaseDynamicLinksCustomDomains</key>
  <array>
    <string>https://my.custom.domain</string>
  </array>

RWOverdijk avatar Oct 21 '19 08:10 RWOverdijk

@RWOverdijk I have this in my project and I still experiencing the issue. This is not just a configuration error, the link works from cold start in iOS13 just fine, the bug seems to be present only on iOS12 for devices without home button.

The most promising workaround so far seems to be using Linking.getInitialURL() alongside firebase.links().getInitialLink()

noway avatar Oct 21 '19 11:10 noway

@noway Pretty sure that's not the case. Have you followed all the other steps? (capability and links in info).

Also, you need a release build (disable debug in build settings).

Update: Linking will work if you forward the results. But this will give you the short url (if you use those) which doesn't help.

RWOverdijk avatar Oct 21 '19 11:10 RWOverdijk

@RWOverdijk yes I have followed capability and Info.plist steps. It works for me on iOS13 in release mode on App Store, but does not in iOS12. This is clearly not a configuration issue?

noway avatar Oct 21 '19 22:10 noway

It works for me on iOS 12 so I think it might be. But I did write a lot of native code for other parts, too.

Maybe your version of React Native is in need of an update? Or maybe I just did something else to make it work and I don't know what. 😄

RWOverdijk avatar Oct 22 '19 06:10 RWOverdijk

I'm using 0.60.5 as specified in the Environment section of this issue.

noway avatar Oct 23 '19 11:10 noway

@RWOverdijk Thanks for pointing that out.. :)

ram95krishh avatar Nov 05 '19 13:11 ram95krishh

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 03 '19 14:12 stale[bot]

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

stale[bot] avatar Dec 18 '19 15:12 stale[bot]

@noway you ever get this solved? Im still struggling with getInitialLink not working on iOS. Android works perfect. onLink works perfect on iOS. its just getInitialLink on iOS that wont. I am on RNF 6.3.4 (latest) and RN0.61.4

alittletf avatar Feb 22 '20 03:02 alittletf

@alittletf we just stopped testing for iOS12

noway avatar Mar 04 '20 22:03 noway

@alittletf Did you find any solution to this? Facing the same issue

Nehal-29 avatar Nov 03 '20 11:11 Nehal-29

I don't know why, but if I manually build main.js and then try to use getInitialLink, it starts working. As a workaround. just an observation.

AkeleyUA avatar Nov 05 '20 14:11 AkeleyUA

I'm still having this issue with devices on both iOS 14 and 13. I specified my custom domain in Info.plist.

  • Works both cold launch and background in debug
  • On release, the link does launch the app, but getInitialLink returns nothing. Linking from background works as expected. Any idea what could be wrong?

zaptrem avatar Jan 31 '21 09:01 zaptrem

  Any idea what could be wrong?

No - best course is to reach into node_modules and add print logging of all arguments prior to making calls into native Objective-C, then similarly inside the Objective-C add print logging of all arguments prior to making calls to firebase-ios-sdk APIs, followed by print logging of all return values as it goes back up from firebase-ios-sdk API return values to native Objective-C return values in javascript up to what you get.

That typically takes about 5 minutes to do (4 minutes to google "how to print to log from objective-c", if you're me, every.time. 1 minute to do it) and should show where expectations are not matching reality

mikehardy avatar Jan 31 '21 16:01 mikehardy

@mikehardy Sorry, staring at Objective-C for 30 minutes has done nothing but burn my eyes. Is there a debug branch I could use or a list of line numbers I can use to paste the print statement?

I thought I could get away with ignoring this issue as React Native's default Linking + the dynamic links parse function works in nearly every other scenario. However, initial install requires Dynamic Links' fancy clipboard scanning which I can only do by using getInitialLink(). Again, it works fine in debug, but not on release.

zaptrem avatar Mar 02 '21 00:03 zaptrem


// add this up at the top
#include <React/RCTLog.h>


// somewhere else in the file
RCTLog(@"Hello world"); // can log anything that can turn into a string, most of the arguments can be strings?

As an aside, I will say even though it may not be helpful - I just reworked the way my "interruptive navigation on startup" works (like, when the app is opened with a link, or by a notification) so I was testing initial links quite heavily. And on iOS in release mode, getInitialLink is working for me. I literally tested it just now and it worked - it is definitely supposed to be working...

mikehardy avatar Mar 02 '21 01:03 mikehardy

@mikehardy

Have you tried the install-survive clipboard feature?

I meant I didn't know where/what to log in Objective C (RNFBDynamicLinksAppDelegateInterceptor.m and RNFBDynamicLinksModule.m) as I could barely understand where functions start and end, let alone which arguments go where/are relevant.

zaptrem avatar Mar 02 '21 01:03 zaptrem

Ooo! I have not tested the install-the-app-then-the-link-goes-in scenario recently as my dev environment is "release mode" and has a full-fledged firebase back-end but is not on the app stores.

It seems like it should be here: https://github.com/invertase/react-native-firebase/blob/f501fffbfc1baabe7fc7ed8185ad0c5be069134d/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m#L119

But this part may get caught up in things as well: https://github.com/invertase/react-native-firebase/blob/f501fffbfc1baabe7fc7ed8185ad0c5be069134d/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.m#L49

I'd be tempted to log all over the place, personally. How exactly are you testing these things from the install? Do you manually install your release build locally after being redirected to the app store ... or? I'm in this area with my app (as mentioned) so if you had a set of steps you're using I might be able to follow along and confirm or deny links are surviving install for me or not

mikehardy avatar Mar 02 '21 01:03 mikehardy

@mikehardy I delete the app, open the dynamic link, click the "open" button in the preview page (since that automatically puts a special link in my clipboard). Then when I'm redirected to the App Store (you can fake this by giving it an AppStore ID for Facebook or something) I click "run" in Xcode (set to "Release" since it weirdly works in dev/debug mode).

zaptrem avatar Mar 02 '21 01:03 zaptrem

Have you tried it not running from xcode? Xcode automatically attaches a debugger which causes other problems (crashlytics test crashes, so may not apply but it is a difference from a real user experience)

mikehardy avatar Mar 02 '21 02:03 mikehardy

@mikehardy The bug is present in the App Store version of our app. For example: https://links.relearn.fyi/1AmPCrhfw5qE7The6

zaptrem avatar Mar 02 '21 02:03 zaptrem

Ooo! I have not tested the install-the-app-then-the-link-goes-in scenario recently as my dev environment is "release mode" and has a full-fledged firebase back-end but is not on the app stores.

It seems like it should be here:

https://github.com/invertase/react-native-firebase/blob/f501fffbfc1baabe7fc7ed8185ad0c5be069134d/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m#L119

But this part may get caught up in things as well:

https://github.com/invertase/react-native-firebase/blob/f501fffbfc1baabe7fc7ed8185ad0c5be069134d/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.m#L49

I'd be tempted to log all over the place, personally. How exactly are you testing these things from the install? Do you manually install your release build locally after being redirected to the app store ... or? I'm in this area with my app (as mentioned) so if you had a set of steps you're using I might be able to follow along and confirm or deny links are surviving install for me or not

I'm still not sure where to log here as I can't even tell what is and isn't a function call with arguments.

zaptrem avatar Mar 02 '21 02:03 zaptrem

@mikehardy I started putting print statements in the ObjC and it seems like the function you mentioned (the app delegate interceptor) isn't even being run.

zaptrem avatar Mar 02 '21 19:03 zaptrem

That would stand to reason if the link is not surviving, although as a negative test, it should run on regular app open or that indicates the wrong bit of control flow has been instrumented

mikehardy avatar Mar 02 '21 20:03 mikehardy