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.73k stars 2.22k forks source link

🔥Firebase auth onAuthStateChange not working on IOS && android release build #2472

Closed Tochukwuibe closed 5 years ago

Tochukwuibe commented 5 years ago

Issue

Describe your issue here

I am experiencing something very strange with the firebase auth onAuthStateChange listener. The listener works perfectly fine when i am testing the app in debug mode. However, once I do a release build the listener only fires once and never again, meaning that when a user sign's in or when they logout, the listener never fires again. I have to close the app and reopen it in order for it to have the appropriate auth state. I haven't the slightest idea why this is happening. I even tried updating all of the firebase IOS dependencies to 6.3.0, however the issue still persists.


Project Files

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # Uncomment the next line to define a global platform for your project platform :ios, '9.0' target 'Skiffel' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! # react native maps rn_path = '../node_modules/react-native' rn_maps_path = '../node_modules/react-native-maps' # react native maps # Pods for Skiffel pod 'Firebase/Core', '~> 5.20.1' pod 'Firebase/Auth', '~> 5.20.1' pod 'Stripe', '~> 14.0.0' pod 'Firebase/Storage', '~> 5.20.1' pod 'Firebase/Firestore', '~> 5.20.1' pod 'Firebase/Messaging', '~> 5.20.1' pod 'react-native-video', :podspec => '../node_modules/react-native-video/react-native-video.podspec' # react native maps pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec" pod 'React', path: rn_path, subspecs: [ 'Core', 'CxxBridge', 'DevSupport', 'RCTActionSheet', 'RCTAnimation', 'RCTGeolocation', 'RCTImage', 'RCTLinkingIOS', 'RCTNetwork', 'RCTSettings', 'RCTText', 'RCTVibration', 'RCTWebSocket', ] pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec" pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec" pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec" pod 'react-native-maps', path: rn_maps_path pod 'react-native-camera', :path => '../node_modules/react-native-camera', subspecs: [ 'BarcodeDetectorMLKit' ] pod 'react-native-image-resizer', :path => '../node_modules/react-native-image-resizer' pod 'react-native-branch', :path => '../node_modules/react-native-branch' pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage' post_install do |installer| installer.pods_project.targets.each do |target| if target.name == 'react-native-google-maps' target.build_configurations.each do |config| config.build_settings['CLANG_ENABLE_MODULES'] = 'No' end end if target.name == "React" target.remove_from_project end targets_to_ignore = %w(React yoga) if targets_to_ignore.include? target.name target.remove_from_project end end end # react native maps # pod 'tipsi-stripe', :path => '../node_modules/tipsi-stripe' target 'SkiffelTests' do inherit! :search_paths # Pods for testing end end target 'Skiffel-tvOS' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! # Pods for Skiffel-tvOS target 'Skiffel-tvOSTests' do inherit! :search_paths # Pods for testing end end ``` #### `AppDelegate.m`: ```objc /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import #import "RNFirebaseNotifications.h" #import "RNFirebaseMessaging.h" #import #import "AppDelegate.h" #import #import #import @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Firebase initilization [FIRApp configure]; [RNFirebaseNotifications configure]; // Uncomment this line to use the test key instead of the live one. #ifdef DEBUG [RNBranch useTestInstance]; #endif // DEBUG [RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES]; RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"Skiffel" initialProperties:nil]; 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]; return YES; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } // Functions for Branch.io - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { return [RNBranch.branch application:app openURL:url options:options] || [[UIApplication sharedApplication] openURL:url]; } - (BOOL)application:(UIApplication *)app continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray * _Nullable))restorationHandler { return [RNBranch.branch continueUserActivity:userActivity]; } // Functions for notificatios - (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]; } @end ```

Environment

Click To Expand

**`react-native info` output:** ``` React Native Environment Info: System: OS: macOS High Sierra 10.13.6 CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 2.27 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 25, 28, 29 Build Tools: 28.0.3, 29.0.1 IDEs: Android Studio: 3.2 AI-181.5540.7.32.5056338 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.9 => 0.59.9 npmGlobalPackages: react-native-cli: 2.0.1 ``` - **Platform that you're experiencing the issue on**: - [x] iOS - [ ] Android - [x] **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:** - `5.4.2` - **`Firebase` module(s) you're using that has the issue:** - ` Auth` - **Are you using `TypeScript`?** - `Y`


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]

Ehesp commented 5 years ago

Hello - does this still happen if you run it locally as a production build?

Tochukwuibe commented 5 years ago

Yes it does, If i run it (the release build) locally on a real Iphone or if I run it on an emulator. The issue still persists.

Tochukwuibe commented 5 years ago

I just ran the app on android and found that the behavior is also the same on android I am not sure what is going on. Here are screenshots of important files in the app.

Ehesp commented 5 years ago

Please format the above!

mikehardy commented 5 years ago

I see you are on react-native >= 0.59.3, why not upgrade to react-native-firebase v.5.5.6 and the newest SDKs + AndroidX + jetifier? I would say that's a tough change, but it actually is not I don't believe. There are some breaking changes to pay attention to that are documented in the react-native-firebase v5.5.x release notes, but in general it all works well, for me

I demonstrate the dependencies you need to get it done in my demonstrator https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-rn59.sh

I can say that I'm not excited about spending any reproduction effort on old versions - enough time to keep current ones working...

Tochukwuibe commented 5 years ago

Sorry it's not letting me format those files correctly. However the issue is the same on IOS and android. I am not sure what to do.

Tochukwuibe commented 5 years ago

@mikehardy I created a separate branch and made the update to react-native-firebase 5.5.6 as well as updated all the dependencies on IOS pods to 6.3.0. This made no difference, I assumed that since upgrading it did not fix the issue on IOS, it wasn't worth going through the trouble of updating and testing on android.

mikehardy commented 5 years ago

it's not so much that it won't fix this particular issue, it's that any reproductions will need to be on current code + libraries, to make sure we can reproduce and that a fix will actually work. Troubleshooting old code is usually inefficient. Pods are 6.6.0 now by the way :-).

mikehardy commented 5 years ago

I would focus on one at a time though - I like the idea (for your time efficiency) of just working iOS on current versions then, once it's isolated it may be no update was really required, or it may be that it is, but you can defer the android update

Tochukwuibe commented 5 years ago

ok ill update the rn-firebase dependencies

Tochukwuibe commented 5 years ago

@mikehardy Is it safe to go by what the official documentation says? On there it is still 6.3.0 :-)

Tochukwuibe commented 5 years ago

I have upgraded all react native firebase dependencies to the latest versions (as seen on the official documentation: https://rnfirebase.io/docs/v5.x.x/getting-started) sad to say that the situation has not changed. It works perfectly fine with the debug build, but breaks in release build.

Tochukwuibe commented 5 years ago

I would add the code snippet but when i paste it, it's never properly formatted

Ehesp commented 5 years ago

Can you help debug? Look at native logs? Maybe add some logs here onwards: https://github.com/invertase/react-native-firebase/blob/v5.x.x/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java#L127

mikehardy commented 5 years ago

for formatting triple-ticks is what you want - above and below pods 6.6.0 are in the docs just because updating them every time is rough - plenty of other stuff to do. But unless they flag a breaking change in the firebase-ios-sdk release notes it's okay to update

Tochukwuibe commented 5 years ago

I made the upgrade to 6.6.0, the issue is still the same

-IOS PODFILE

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

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

  # react native maps
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'
  # react native maps

  # Pods for Skiffel
  pod 'Firebase/Core', '~> 6.6.0'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'

  pod 'Firebase/Auth', '~> 6.6.0'
  pod 'Stripe', '~> 14.0.0'
  pod 'Firebase/Storage', '~> 6.6.0'
  pod 'Firebase/Firestore', '~> 6.6.0'
  pod 'Firebase/Messaging', '~> 6.6.0'
  pod 'react-native-video', :podspec => '../node_modules/react-native-video/react-native-video.podspec'

  # react native maps
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"
  pod 'react-native-maps', path: rn_maps_path

  pod 'react-native-camera', :path => '../node_modules/react-native-camera',  subspecs: [
    'BarcodeDetectorMLKit'
  ]

  pod 'react-native-image-resizer', :path => '../node_modules/react-native-image-resizer'

  pod 'react-native-branch', :path => '../node_modules/react-native-branch'

  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'react-native-google-maps'
        target.build_configurations.each do |config|
          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
        end
      end
      if target.name == "React"
        target.remove_from_project
      end

      targets_to_ignore = %w(React yoga)

      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

    end
  end
  # react native maps

  # pod 'tipsi-stripe', :path => '../node_modules/tipsi-stripe'

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

end

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

  # Pods for Skiffel-tvOS

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

end

-PACKAGE.JSON

{
  "name": "skiffel",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "ios": "react-native run-ios --simulator=\"iPhone 6\" ",
    "android": "react-native run-android",
    "build-ios": "",
    "build-android": "",
    "postinstall": "rm -rf node_modules/react-native-gifted-chat/node_modules/react-native-video"
  },
  "dependencies": {
    "@react-native-community/async-storage": "1.6.1",
    "axios": "0.19.0",
    "dinero.js": "^1.6.0",
    "formik": "1.5.4",
    "geofirestore": "3.3.1",
    "react": "16.8.3",
    "react-native": "0.59.9",
    "react-native-action-sheet": "2.2.0",
    "react-native-animatable": "1.3.2",
    "react-native-branch": "3.0.1",
    "react-native-calendars": "1.27.0",
    "react-native-camera": "2.11.1",
    "react-native-copilot": "2.4.3",
    "react-native-dropdownalert": "3.10.0",
    "react-native-elements": "1.1.0",
    "react-native-firebase": "5.5.6",
    "react-native-geolocation-service": "2.0.1",
    "react-native-gesture-handler": "1.1.0",
    "react-native-gifted-chat": "0.8.0",
    "react-native-image-picker": "0.28.1",
    "react-native-image-resizer": "1.0.1",
    "react-native-keyboard-aware-scroll-view": "0.8.0",
    "react-native-launch-navigator": "1.0.4",
    "react-native-lightbox": "0.8.0",
    "react-native-loading-spinner-overlay": "1.0.1",
    "react-native-maps": "0.24.2",
    "react-native-masked-text": "^1.12.4",
    "react-native-modal-datetime-picker": "6.1.0",
    "react-native-modal-popover": "0.0.12",
    "react-native-qrcode-svg": "5.1.2",
    "react-native-read-more-text": "1.1.0",
    "react-native-reanimated": "1.0.0",
    "react-native-responsive-screen": "1.2.1",
    "react-native-scrollable-tab-view": "0.10.0",
    "react-native-svg": "9.4.0",
    "react-native-swiper": "1.5.14",
    "react-native-tab-view": "2.0.3",
    "react-native-vector-icons": "6.4.2",
    "react-native-video": "4.4.1",
    "react-navigation": "3.6.1",
    "react-redux": "7.0.3",
    "redux": "4.0.1",
    "redux-saga": "1.0.2",
    "reselect": "4.0.0",
    "rn-placeholder": "1.3.3",
    "rxjs": "6.3.3",
    "tipsi-stripe": "7.5.0",
    "update-js": "1.7.1",
    "uuid": "3.3.2",
    "yup": "0.27.0"
  },
  "devDependencies": {
    "@babel/core": "7.4.5",
    "@babel/runtime": "7.4.5",
    "@types/dinero.js": "^1.4.1",
    "@types/jest": "24.0.11",
    "@types/react": "16.8.12",
    "@types/react-native": "0.57.42",
    "@types/react-native-calendars": "1.20.5",
    "@types/react-native-elements": "0.18.0",
    "@types/react-native-swiper": "1.5.10",
    "@types/react-native-tab-view": "1.0.5",
    "@types/react-native-vector-icons": "^6.4.0",
    "@types/react-redux": "7.0.6",
    "@types/react-test-renderer": "16.8.1",
    "@types/redux": "3.6.0",
    "@types/redux-saga": "^0.10.5",
    "@types/yup": "^0.26.13",
    "babel-jest": "24.8.0",
    "jest": "24.8.0",
    "metro-react-native-babel-preset": "0.54.1",
    "react-native-svg-transformer": "^0.12.1",
    "react-test-renderer": "16.8.3",
    "typescript": "3.4.2"
  },
  "jest": {
    "preset": "react-native"
  }
}

-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()
    }
    dependencies {
        // classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.android.tools.build:gradle:3.3.2'
        // changed to 3.3.2 from 3.2.1 for firebase
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        // Add jitpack repository (added by tipsi-stripe)
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

// Global configuration versions for Maps
ext {
    // compileSdkVersion   = 26
    // targetSdkVersion    = 26
    // buildToolsVersion   = "28.0.3"
    // supportLibVersion   = "28.0.0"
    // googlePlayServicesVersion = "16.1.0" // or set latest version
    androidMapsUtilsVersion = "0.5+"
}

-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",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

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

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

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

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

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.skffl.skiffel"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 10000
        versionName "1.0.0"
        missingDimensionStrategy 'react-native-camera', 'general'
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        release {
            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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            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
            }
        }
    }
}

dependencies {
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-branch')
    implementation project(':react-native-action-sheet')
    implementation project(':react-native-image-resizer')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-geolocation-service')
    implementation project(':react-native-launch-navigator')
    implementation project(':react-native-camera')
    implementation project(':react-native-video')
    implementation project(':react-native-maps')
    implementation project(':tipsi-stripe')
    implementation project(':react-native-firebase')
    implementation project(':react-native-svg')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-vector-icons')

    // CHANGED FOR BRANCH
    // implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "io.branch.sdk.android:library:3.0.4"
    // CHANGED FOR BRANCH

    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules

    // for geolocation
    implementation 'com.google.android.gms:play-services-location:16.0.0'

    implementation "com.google.android.gms:play-services-base:16.1.0" // for firebase
    implementation "com.google.firebase:firebase-core:16.0.9" // for firebase

    implementation "com.google.firebase:firebase-auth:17.0.0"
    implementation "com.google.firebase:firebase-storage:17.0.0"
    implementation "com.google.firebase:firebase-firestore:19.0.0"

    // for notificatios
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

}

// 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'
}

// firebase setup
apply plugin: 'com.google.gms.google-services'

-MAINAPPLICATION.JAVA

package com.skffl.skiffel;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import io.branch.rnbranch.RNBranchPackage;
import io.branch.referral.Branch;
import com.actionsheet.ActionSheetPackage;
import fr.bamlab.rnimageresizer.ImageResizerPackage;
import uk.co.workingedge.RNLaunchNavigator.RNLaunchNavigatorPackage;
import org.reactnative.camera.RNCameraPackage;
import com.gettipsi.stripe.StripeReactPackage;

import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;

import com.swmansion.reanimated.ReanimatedPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.horcrux.svg.SvgPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.brentvatne.react.ReactVideoPackage;
import com.agontuk.RNFusedLocation.RNFusedLocationPackage;
import com.imagepicker.ImagePickerPackage;
import io.invertase.firebase.storage.RNFirebaseStoragePackage;
import io.invertase.firebase.firestore.RNFirebaseFirestorePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;

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

public class MainApplication extends Application implements ReactApplication {

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

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new AsyncStoragePackage(),
            new RNBranchPackage(),
            new ActionSheetPackage(),
            new RNLaunchNavigatorPackage(),
            new RNCameraPackage(),
            new StripeReactPackage(),
            new RNFirebasePackage(),
            new ReanimatedPackage(),
            new RNGestureHandlerPackage(),
            new VectorIconsPackage(),
            new SvgPackage(),
            new RNFirebaseAuthPackage(),
            new MapsPackage(),
            new ReactVideoPackage(),
            new RNFusedLocationPackage(),
            new ImagePickerPackage(),
            new RNFirebaseStoragePackage(),
            new RNFirebaseFirestorePackage(),
            new ImageResizerPackage(),
            new RNFirebaseMessagingPackage(),
            new RNFirebaseNotificationsPackage()
      );
    }

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

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

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

    // ADDED FRO BRACH
    Branch.getAutoInstance(this);
  }
}

import com.facebook.react.ReactActivity;

import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactRootView; import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView; import io.branch.rnbranch.*; import android.content.Intent;

public class MainActivity extends ReactActivity {

/**
 * Returns the name of the main component registered from JavaScript.
 * This is used to schedule rendering of the component.
 */
@Override
protected String getMainComponentName() {
    return "Skiffel";
}

// CHANGES FOR BRANCH

  @Override
  protected void onStart() {
      super.onStart();
      RNBranchModule.initSession(getIntent().getData(), this);
  }

  @Override
  public void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      setIntent(intent);
  }

// CHANGES FOR BRANCH

@Override
protected ReactActivityDelegate createReactActivityDelegate() {
    return new ReactActivityDelegate(this, getMainComponentName()) {
        @Override
        protected ReactRootView createRootView() {
          return new RNGestureHandlerEnabledRootView(MainActivity.this);
        }
};

} }

mikehardy commented 5 years ago

Hmm - sorry that had no effect, even though I didn't think it was really going to fix it per se

If it were an android issue I'd bet it was proguard but we're focused on iOS here. Have you tried using a debug javascript bundle on the release iOS build, or vice-versa - a release javascript bundle in the debug build? That might isolate native code vs javascript. I'm just brainstorming though - I usually try to decompose problems kind of binary search but I don't have a lot of ideas here, or a good idea what I'd do to keep pursuing it either way

Tochukwuibe commented 5 years ago

@mikehardy I'm not exactly sure how to do that, could you please advise?

mikehardy commented 5 years ago

for ios you can generate a bundle like this from my project's package.json: `"ios-bundle": "npm run pre-render && tsc && npx react-native bundle --entry-file='./index.ios.js' --bundle-output='./ios/index.ios.bundle' --dev=false --platform='ios' --assets-dest='./ios/build'"

Then if you run react-native start-ios but kill the metro packager, you'll use that bundle you made instead of anything over the network. If you add --dev false to the bundle arguments you get a release bundle (it defaults to --dev true). That way you can try to check the difference between release and debug in the javascript bundling.

Likewise, you can alter the bundle arguments in the build step for release mode and make it --dev true there to try a release ios build but a dev bundle to go the other way

Not sure where it will lead but it will tell you which side of the house has the problem right? that's a start

Tochukwuibe commented 5 years ago

Alright, give me some time pls. I'll need to take care of some other tasks before I can try this.

Tochukwuibe commented 5 years ago

Ok so I ended up creating a new RN app using version 0.60.4 and used the updated version of all firebase dependencies. So far I have not noticed this issue in the release build. I am not sure what it was that caused it. I know that being able to reproduce errors can really help you guys out. So let me know if you'd like me to provide more info.

mikehardy commented 5 years ago

I'm happy to hear it's working! I'd say move on if you are not sure what's causing it, I was out of ideas myself. But if something comes to you later of course report back :-)

khalilTN commented 4 years ago

I think i can help you with some infomations. I had this same problem on iOS only, on android all is perfect. Authentication never finishes, i had to close app and repoen it to find that authentication passed and so i can access my main screen. I'm on React-native@0.60.0(just upgraded from 0.59.10), React-native-firebase@5.5.6 and Firebase iOS SDK 6.8.0. I upgraded React-native-firebase to 5.6.0 and Firebase iOS SDK to 6.13.0. The problem is gone.

crystalneth commented 4 years ago

I am experiencing this with react-native-firebase 6.4.0. Event fires only once, then I need to reload the app.

crystalneth commented 4 years ago

Sorry, nvm. I was calling GoogleSignin.signOut() and not calling auth().signOut(), leaving the firebase and google auth states out of sync.