invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

[🐛] 🔥getInitialLink doesn't survive app install on iOS #6810

Closed wc-ab closed 1 year ago

wc-ab commented 1 year ago

Issue

Describe your issue here

useEffect(() => { const loadInitialLink = async () => { const initialLink = await dynamicLinks().getInitialLink(); // initialLink = null

  if (initialLink) {
    await handleDynamicLink(initialLink.url);
  }
};

loadInitialLink();

}, [handleDynamicLink]);


Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "app", "version": "1.35.2", "private": true, "scripts": { "open:android": "nohup emulator -avd Pixel_5_API_31 -noaudio -netdelay none -netspeed full > /dev/null 2>&1 & adb wait-for-device && adb reverse tcp:8081 tcp:8081", "open:ios": "open -a Simulator", "start": "npx react-native start", "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.1.2", "@fortawesome/free-solid-svg-icons": "^6.1.2", "@fortawesome/react-native-fontawesome": "^0.3.0", "@googleapis/androidpublisher": "^3.0.0", "@hookform/resolvers": "^2.5.1", "@react-native-async-storage/async-storage": "^1.15.8", "@react-native-clipboard/clipboard": "^1.11.1", "@react-native-community/datetimepicker": "^6.0.2", "@react-native-firebase/analytics": "^16.5.0", "@react-native-firebase/app": "^16.5.0", "@react-native-firebase/auth": "^16.5.0", "@react-native-firebase/dynamic-links": "^16.5.0", "@react-native-firebase/firestore": "^16.5.0", "@react-native-firebase/functions": "^16.5.0", "@react-native-firebase/messaging": "^16.5.0", "@react-native-firebase/storage": "^16.5.0", "@react-navigation/bottom-tabs": "^6.4.0", "@react-navigation/native": "^6.0.13", "@react-navigation/native-stack": "^6.9.0", "algoliasearch": "^4.14.2", "libphonenumber-js": "^1.10.14", "react": "17.0.2", "react-hook-form": "^7.20.2", "react-instantsearch-hooks": "^6.38.0", "react-native": "^0.68.2", "react-native-contacts": "^7.0.5", "react-native-draggable-flatlist": "^4.0.0", "react-native-geolocation-service": "^5.3.1", "react-native-gesture-handler": "^2.6.2", "react-native-google-places-autocomplete": "^2.4.1", "react-native-image-picker": "^4.10.2", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-permissions": "^3.6.1", "react-native-qrcode-svg": "^6.1.2", "react-native-reanimated": "^2.13.0", "react-native-safe-area-context": "^3.3.2", "react-native-screens": "^3.17.0", "react-native-svg": "^12.4.4", "react-native-video": "^5.2.1", "react-native-view-more-text": "^2.1.0", "yup": "^0.32.9" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "@testing-library/react-native": "^8.0.0", "@types/jest": "^26.0.20", "@types/react-native": "^0.70.3", "@types/react-test-renderer": "^16.9.5", "babel-jest": "^26.6.3", "eslint": "^7.14.0", "jest": "^27.3.1", "metro-react-native-babel-preset": "^0.64.0", "react-test-renderer": "^17.0.2", "typescript": "^4.4.3" }, "resolutions": { "@types/react": "^17" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '12.0' # [START] global abstracts used for all targets # The next line is to use react-native-firebase package $RNFirebaseAsStaticFramework=true # The next line is to use react-native-firebase package use_frameworks! config = use_native_modules! use_react_native!( :path => config[:reactNativePath], # Hermes is now enabled by default. Disable by setting this flag to false. # Upcoming versions of React Native may rely on get_default_flags(), but # we make it explicit here to aid in the React Native upgrade process. :hermes_enabled => false, # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. # :flipper_configuration => FlipperConfiguration.enabled, # An absolute path to your application root. # :app_path => "#{Pod::Config.instance.installation_root}/.." ) # [START] Set up React Native Permissions # Convert all permission pods into static libraries pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} installer.pod_targets.each do |pod| if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-') def pod.build_type; # Uncomment the line corresponding to your CocoaPods version Pod::BuildType.static_library # >= 1.9 # Pod::Target::BuildType.static_library # < 1.9 end end end end # [END] Set up React Native Permissions post_install do |installer| react_native_post_install(installer) # [START] Use ccache to speed up build phase # https://reactnative.dev/docs/build-speed installer.pods_project.targets.each do |target| target.build_configurations.each do |config| # Using the un-qualified names means you can swap in different implementations, for example ccache config.build_settings["CC"] = "clang" config.build_settings["LD"] = "clang" config.build_settings["CXX"] = "clang++" config.build_settings["LDPLUSPLUS"] = "clang++" end end # [END]Use ccache to speed up build phase # [START] This is necessary for Xcode 14, because it signs resource bundles by default # when building for devices. installer.target_installation_results.pod_target_installation_results .each do |pod_name, target_installation_result| target_installation_result.resource_bundle_targets.each do |resource_bundle_target| resource_bundle_target.build_configurations.each do |config| config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' end end end # [END] end # [START] Set up React Native Permissions permissions_path = '../node_modules/react-native-permissions/ios' pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency" pod 'Permission-Camera', :path => "#{permissions_path}/Camera" pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts" pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy" pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse" pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications" pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary" # [END] Set up React Native Permissions # [END] global abstracts target 'Airballoon' do target 'AirballoonTests' do inherit! :complete # Pods for testing end end target 'Debug' do end target 'Development' do end target 'Release' do end ``` #### `AppDelegate.m`: ```objc // N/A #import "AppDelegate.h" // The next line is for firebase #import #import #import #import #import #if DEBUG // #import // #import // #import // #import // #import // #import // static void InitializeFlipper(UIApplication *application) { // FlipperClient *client = [FlipperClient sharedClient]; // SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; // [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; // [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; // [client addPlugin:[FlipperKitReactPlugin new]]; // [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; // [client start]; // } #endif @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]; #if DEBUG // InitializeFlipper(application); #endif // [START] setup firebase [FIRApp configure]; // [END] setup firebase RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; // send bundle id to react native NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier]; NSDictionary *props = @{@"bundleId" : bundleId}; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"App" initialProperties:props]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; // [START] remove white screen after splash screen // https://reactnative.dev/docs/publishing-to-app-store#pro-tips UIStoryboard *sb = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil]; UIViewController *vc = [sb instantiateInitialViewController]; rootView.loadingView = vc.view; // [END] remove white screen after splash screen return YES; } // brige to react native - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } @end ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OS: macOS 12.6.2 CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz Memory: 85.63 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.7.0 - /usr/local/bin/node Yarn: Not Found npm: 8.19.2 - /usr/local/bin/npm Watchman: Not Found Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **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:** - `16.5.0` - **`Firebase` module(s) you're using that has the issue:** - `dynamic-links` - **Are you using `TypeScript`?** - `Y` & `4.4.3`


github-actions[bot] commented 1 year ago

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.