Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 DynamicLinks iOS: await dynamicLinks().getInitialLink() works on debug, but doesn't work on release mode [workaround possible! see comments] #2660

Closed
2 of 7 tasks
noway opened this issue Oct 1, 2019 · 91 comments
Labels
Keep Open avoids the stale bot Resolution: Solution Provided Type: Stale Issue has become stale - automatically added by Stale bot Workflow: Needs Review Pending feedback or review from a maintainer.

Comments

@noway
Copy link

noway commented Oct 1, 2019

EDIT: we think there is a workaround possible - #4548 (comment)

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 #1901, and if so the issue has failed at least 2 Firebase customers, who since have chosen to switch to branch.io instead. See #1901 (comment) and #1901 (comment)

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
  • 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:
    • 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]

@ram95krishh
Copy link

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
Copy link

ram95krishh commented Oct 14, 2019

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

@mikehardy
Copy link
Collaborator

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

@ram95krishh
Copy link

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

@noway
Copy link
Author

noway commented Oct 21, 2019

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.

@RWOverdijk
Copy link

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>

@noway
Copy link
Author

noway commented Oct 21, 2019

@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()

@RWOverdijk
Copy link

RWOverdijk commented Oct 21, 2019

@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.

@noway
Copy link
Author

noway commented Oct 21, 2019

@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?

@RWOverdijk
Copy link

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. 😄

@noway
Copy link
Author

noway commented Oct 23, 2019

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

@ram95krishh
Copy link

@RWOverdijk Thanks for pointing that out.. :)

@stale
Copy link

stale bot commented Dec 3, 2019

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 stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Dec 3, 2019
@stale
Copy link

stale bot commented Dec 18, 2019

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 stale bot closed this as completed Dec 18, 2019
@alittletf
Copy link

@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

@noway
Copy link
Author

noway commented Mar 4, 2020

@alittletf we just stopped testing for iOS12

@Nehal-29
Copy link

Nehal-29 commented Nov 3, 2020

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

@AkeleyUA
Copy link

AkeleyUA commented Nov 5, 2020

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.

@zaptrem
Copy link

zaptrem commented Jan 31, 2021

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?

@mikehardy
Copy link
Collaborator

  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

@zaptrem
Copy link

zaptrem commented Mar 2, 2021

@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.

@mikehardy
Copy link
Collaborator

// 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...

@zaptrem
Copy link

zaptrem commented Mar 2, 2021

@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.

@mikehardy
Copy link
Collaborator

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:

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

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

@zaptrem
Copy link

zaptrem commented Mar 2, 2021

@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).

@mikehardy
Copy link
Collaborator

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)

@austin43
Copy link
Contributor

@EquesMedia Excellent! 😄. I still need to test it but the code injects properly in my AppDelegate. I was actually writing a full app.plugin.js for the dynamic-links package as I checked this thread, and just finished getting the tests + snapshot done. It's basically a copy of the @react-native-firebase/app plugin per #2660 (comment).

@mikehardy Do we want this as an official plugin? If so, I can submit my PR.

@mikehardy
Copy link
Collaborator

@austin43 apologies for the delay, it's Firebase Summit week and I've been working on major new release items.

But yes! A plugin PR would be great to have

if you made an official plugin that implemented that and posted a PR (maybe also with a change to the non-Expo dynamic-links install docs mentioning the issue and the workaround of import / sharedInstance call?) that should help everyone with this until the underlying swizzle issue is figured out

@mikehardy mikehardy changed the title 🔥 DynamicLinks iOS: await dynamicLinks().getInitialLink() works on debug, but doesn't work on release mode 🔥 DynamicLinks iOS: await dynamicLinks().getInitialLink() works on debug, but doesn't work on release mode [workaround possible! see comments] Oct 19, 2022
austin43 added a commit to austin43/react-native-firebase that referenced this issue Nov 1, 2022
mikehardy added a commit that referenced this issue Nov 2, 2022
…orkaround (#6650)

Related #2660

Co-authored-by: Mike Hardy <github@mikehardy.net>
@github-actions
Copy link

github-actions bot commented Dec 5, 2022

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 attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Dec 5, 2022
@mikehardy
Copy link
Collaborator

This is a hot item, and has a workaround at least, but needs investigation

@ilyatsykunov
Copy link

Hi @EquesMedia
I am yet to try your Expo plugin, but I just wanted to ask if you had to use any workarounds in your navigation to resolve the dynamic link, or was just the plugin sufficient?

@EquesMedia
Copy link

EquesMedia commented Dec 19, 2022

Hi @EquesMedia I am yet to try your Expo plugin, but I just wanted to ask if you had to use any workarounds in your navigation to resolve the dynamic link, or was just the plugin sufficient?

The plugin only fixes the bug that causes the dynamic link to not be detected when installing an iOS app via the app store.

If we talk "implementation", to be honest, I've noticed disparities between the data received on Android and iOS depending on where the data is coming from and when, but using the functions of the + react native Linking package, you should be able to capture all the possibilities.

What's next is stuff that I've seen, but haven't had time to understand what or why is was happening due to... being rushed at my work.

Here are the things I had to handle:

  • On Android, I receive the resolved dynamic link directly (aka a deep link). Very convenient.
  • On iOS, I receive the dynamic link url and I have to resolve it using dynamicLinks().resolveLink(url) to get the deep link.
  • On first install iOS, I get this string: com.yourpackage.app://google/link/ and I have to parse it to get deep_link_id which contains my deep link using Linking.parse().

Hopefully it can help you a bit!

@github-actions
Copy link

github-actions bot commented Feb 9, 2023

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 attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Feb 9, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@mikehardy mikehardy added Keep Open avoids the stale bot and removed Type: Stale Issue has become stale - automatically added by Stale bot labels Feb 25, 2023
@mikehardy mikehardy reopened this Feb 25, 2023
@github-actions
Copy link

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 attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Mar 25, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2023
@mikehardy mikehardy reopened this Apr 9, 2023
@mikehardy mikehardy removed the Type: Stale Issue has become stale - automatically added by Stale bot label Apr 9, 2023
@github-actions
Copy link

github-actions bot commented May 7, 2023

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 attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot added the Type: Stale Issue has become stale - automatically added by Stale bot label May 7, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Keep Open avoids the stale bot Resolution: Solution Provided Type: Stale Issue has become stale - automatically added by Stale bot Workflow: Needs Review Pending feedback or review from a maintainer.
Projects
None yet
Development

No branches or pull requests