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.69k stars 2.21k forks source link

applyActionCode and checkActionCode not working #588

Closed malikoum94 closed 6 years ago

malikoum94 commented 6 years ago

Issue

Hi,

I try to use firebase.auth(). verifyPhoneNumber (phoneNumber) and after firebase.auth(). applyActionCode (code) or firebase.auth(). checkActionCode (code) but both aren't working and all other function work good!

firebase.auth(). verifyPhoneNumber (phoneNumber) return this, but send the code:

{ verificationId: a big hash string, code: null, error: null, state: 'sent' }

firebase.auth(). applyActionCode (code) and firebase.auth(). checkActionCode (code) always return this:

image image

And my code look like this:

firebase
        .auth()
        .checkActionCode(code)
        .then(codeInfo => {
          console.log('====================================')
          console.log(codeInfo)
          console.log('====================================')
        })
        .catch(e => {
          console.log('====================================')
          console.log(e)
          console.log('====================================')
        })

My Podfile:

# Uncomment this line to define a global platform for your project

platform :ios, '9.0'

install! 'cocoapods', :deterministic_uuids => false

target 'Voxist' do

  # Pods for Voxist
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
  'BatchedBridge', # Required For React Native 0.45.0+
  'Core',
  'DevSupport',
  'RCTText',
  'RCTNetwork',
  'RCTWebSocket',
  # Add any other subspecs you want to use in your project
  ]

# Required by RNFirebase
pod 'Firebase/Core'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'

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

# [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
pod 'Firebase/AdMob'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Crash'
pod 'Firebase/Database'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'

pod "HockeySDK", :subspecs => ['AllFeaturesLib']

pod 'Analytics'
pod 'Segment-Localytics'
pod 'Segment-Mixpanel'

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

end

post_install do |installer|
    installer.pods_project.targets.each do |target|

        if target.name == "React"
            target.remove_from_project
        end
    end
end

My app/build.gradle:


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,
 *
 *   // 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/**"]
 * ]
 */

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.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 26
    buildToolsVersion "26.0.1"

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    defaultConfig {
        applicationId "com.voxist"
        minSdkVersion 19
        targetSdkVersion 23
versionCode 1141
versionName "0.51.0"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
      release {
        storeFile file(MYAPP_RELEASE_STORE_FILE)
        storePassword MYAPP_RELEASE_STORE_PASSWORD
        keyAlias MYAPP_RELEASE_KEY_ALIAS
        keyPassword MYAPP_RELEASE_KEY_PASSWORD
      }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    dexOptions {
        javaMaxHeapSize "3g"
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // 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]
            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
            }
        }
    }
}

repositories {

        mavenCentral()
        maven { url 'http://maven.localytics.com/public' }
           flatDir {
        dirs 'libs'
    }

}

dependencies {
    compile project(':react-native-blur')
    compile project(':react-native-orientation')
    compile project(':react-native-call-detection')
    compile "com.android.support:appcompat-v7:26.0.1"
    compile project(':lottie-react-native')
    compile project(':react-native-fs')
    compile project(':react-native-image-resizer')
    compile project(':react-native-image-picker')
    compile project(':react-native-billing')
    compile project(':react-native-proximity')
        compile(name: 'appverify', ext: 'aar')
    compile project(':instabug-reactnative')
      compile 'me.leolin:ShortcutBadger:1.1.18@aar'
  compile project(':react-native-bugfender')
  compile(project(':react-native-firebase')) {
    transitive = false
  }
  compile "com.google.firebase:firebase-core:11.4.2"

  // If you are receiving Google Play API availability issues, add the following dependency
  compile "com.google.android.gms:play-services-base:11.4.2"
  compile 'com.google.android.gms:play-services-auth-api-phone:11.4.2'
  // RNFirebase optional dependencies
  compile "com.google.firebase:firebase-ads:11.4.2"
  compile "com.google.firebase:firebase-analytics:11.4.2"
  compile "com.google.firebase:firebase-auth:11.4.2"
  compile "com.google.firebase:firebase-config:11.4.2"
  compile "com.google.firebase:firebase-crash:11.4.2"
  compile "com.google.firebase:firebase-database:11.4.2"
  compile "com.google.firebase:firebase-messaging:11.4.2"
  compile "com.google.firebase:firebase-perf:11.4.2"
  compile "com.google.firebase:firebase-storage:11.4.2"
    compile project(':react-native-device-info')
  compile project(':react-native-fetch-blob')
  compile project(':react-native-music-control')

  compile project(':realm')
  compile project(':react-native-svg')
  compile fileTree(dir: "libs", include: ["*.jar"])
  compile 'com.facebook.react:react-native:+'
  compile 'com.android.support:appcompat-v7:23.0.1'
  compile project(':RNSound')
  compile project(':react-native-contacts')
  compile project(':react-native-code-push')
  compile project(':react-native-hockeyapp')
  compile project(':ReactNativeLocalization')
  compile project(':react-native-segment-io-analytics')
  compile project(':react-native-splashscreen')
  compile project(':react-native-linear-gradient')
  compile project(':instabug-reactnative')
  compile project(':react-native-audio')

  compile 'com.localytics.android:library:4.0+'
  compile 'com.android.support:support-v4:23.1.0'
  compile 'com.android.support:design:25.3.1'
  compile 'com.android.support:multidex:1.0.0'
  compile('com.segment.analytics.android.integrations:localytics:+') {
    transitive = true
  }
}

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

This issue is on both OS and can't avoid this, have you any solution?

Thanks

Environment

  1. Application Target Platform: Both
  2. Development Operating System: macOS High Sierra
  3. Build Tools: Xcode 9.0.1, Android Studio 3.0, Android SDK version 23 to 27
  4. React Native version: 0.49.+ or 0.50.1
  5. RNFirebase Version: 3.0.6
  6. Firebase Module: auth
Salakar commented 6 years ago

@malikoum94 thanks for reporting, I can see what the issue is so will get a patch version out today for this. Issue also applies to confirmPasswordReset as well as the 2 methods you mentioned above.

chrisbianca commented 6 years ago

@malikoum94 As an aside, what is your use case for applyActionCode or checkActionCode? I've not come across why these might be used before and just wanted to check that you're not just trying to log the user in? If you are then there is now a verifyPhoneNumber example on the docs:

https://rnfirebase.io/docs/v3.1.*/auth/phone-auth#verifyPhoneNumber

malikoum94 commented 6 years ago

Hi guys,

@Salakar thanks it will be appreciate!

@chrisbianca my use case is not to log in the user just verify his phone so on iOS i can't verify is phone number because the event of verifyPhoneNumber send null for the code. For log in the user i use signInWithPhoneNumber but i have to add some number on one account so i just need to log in with one and for other phone just verify.

chrisbianca commented 6 years ago

This was fixed as part of v3.1.1