Skip to content

🔥 Dynamic link first open attribution not working on IOS #1899

Closed
@harrydema

Description

@harrydema

Issue

First of all i am not facing issues when i click over a link, my app is opened properly.

I am trying to attribute a campaign, source and medium to a dynamic link install on IOS.

I first open the dynamic link and click over the "open" button on the preview.page.link of the dynamic link. The link is copied to the clipboard.

Then I install the app via XCode and i checked that the dynamic link is fired on the javascript side. The ios function that was fired was application:openURL:options and as i debugged it this was the url:

com.example.app://google/link/?deep_link_id=https%3A%2F%2Fhola%2Ecom%2Ftest&match_type=unique&match_message=Link%20is%20uniquely%20matched%20for%20this%20device%2E

image

If i click on a dynamic link, and my app is already installed the attribution works properly. The IOS function fired is application:continueUserActivity:restorationHandler

image

If I check on firebase the event has lots of (direct), which means the attribution failed:

image


Project Files

iOS

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'

target 'ExampleAPp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for ExampleApp
  pod 'Firebase/Core', '~> 5.15.0'
  pod 'Firebase/Auth', '~> 5.15.0'
  pod 'Firebase/Messaging', '~> 5.15.0'
  pod 'Fabric', '~> 1.7.13'
  pod 'Crashlytics', '~> 3.10.7'
  pod 'Firebase/Database', '~> 5.15.0'
  pod 'Firebase/DynamicLinks', '~> 5.15.0'

  pod 'GoogleSignIn', '~> 4.2.0'
  pod 'FBSDKCoreKit', '~> 4.35.0', :modular_headers => true
  pod 'FBSDKLoginKit', '~> 4.35.0', :modular_headers => true
  pod 'FBSDKShareKit', '~> 4.35.0', :modular_headers => true
  pod 'AppsFlyerFramework'

  pod 'TwilioVideo', '~> 2.5.6'

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

end

target 'ExampleApp-tvOS' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for ExampleApp-tvOS

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

end

# The following is needed to ensure the "archive" step works in XCode.
# It removes React from the Pods project, as it is already included in the main project.
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

AppDelegate.m:

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import <Firebase.h>
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNFirebaseLinks.h"
#import "RNFirebaseMessaging.h"
#import "RNFirebaseNotifications.h"
#import <React/RCTLinkingManager.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <AppsFlyerLib/AppsFlyerTracker.h>
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
#import "RNSplashScreen.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIROptions defaultOptions].deepLinkURLScheme = @"com.example.app";
  [FIRApp configure];
  [RNFirebaseNotifications configure];
  [FIRDatabase database].persistenceEnabled = YES;
  NSURL *jsCodeLocation;
  
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"ExampleApp"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [RNSplashScreen show];
  [Fabric with:@[[Crashlytics class]]];
  return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  BOOL handled = [RCTLinkingManager
                  application:application
                  openURL:url
                  sourceApplication:sourceApplication
                  annotation:annotation
                  ];
  return handled;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
  NSLog(@"Hola1: %@", url);
  BOOL handled = [[RNFirebaseLinks instance]
                  application:application
                  openURL:url
                  options:options
                  ] || [RCTLinkingManager
                        application:application
                        openURL:url
                        options:options
                        ] || [[FBSDKApplicationDelegate sharedInstance]
                              application:application
                              openURL:url
                              sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                              annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
                              ] || [RNGoogleSignin
                                    application:application
                                    openURL:url
                                    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                    annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
                                    ];
  
  return handled;
}

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray *))restorationHandler {
  BOOL handled = [[RNFirebaseLinks instance]
                  application:application
                  continueUserActivity:userActivity
                  restorationHandler:restorationHandler
                  ] || [RCTLinkingManager
                        application:application
                        continueUserActivity:userActivity
                        restorationHandler:restorationHandler
                        ];
  
  return handled;
}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                                                       fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

@end

Android

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->

Environment

  • 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
  • If known, the version of the platform are you experiencing the issue on:
    • ADD_SOMETHING_HERE e.g. iOS 10 or Android API 28
  • Operating System:
    • MacOS, version: N/A
    • Windows, version: N/A
    • Other, please specify: N/A
  • Build Tools:
    • Xcode 10
  • React Native version:
    • 0.57.8
  • React Native Firebase library version:
    • 5.2.0
  • Firebase module(s) you're using that has the issue:
    • N/A
    • Authentication
    • Analytics
    • Cloud Firestore
    • Cloud Messaging (FCM)
    • Crashlytics
    • Dynamic Links
    • Functions Callable
    • In App Messaging
    • Indexing
    • Invites
    • Instance ID
    • ML Kit
    • Notifications
    • Performance Monitoring
    • Realtime Database
    • Remote Config
    • Storage
  • Are you using TypeScript?
    • No
    • Yes, version: N/A
  • Are you using Expo, e.g. ExpoKit?
    • No
    • Yes, I've not ejected
    • Yes, but I have ejected to ExpoKit
    • Yes, but I have ejected to vanilla React Native
    • Expo version: N/A

Think react-native-firebase is great? Please consider supporting the project with any of the below:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: StaleIssue has become stale - automatically added by Stale bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions