Closed nahlebn1k closed 2 months ago
Hey @nahlebn1k - what API call are you making? Have you tried in debug mode?
It might be a case of redownloading your google-services.json file for you app if the analytics service was initialised after downloading the service file.
@russellwheatley Hi, i'm not making any API calls. Firebase documentation states that in-app purchase events logs in Firebase Analytics automatically as Reserved Events - https://rnfirebase.io/analytics/usage#reserved-events. All tests were made in debug mode. google-services.json file wasn't redownloaded.
Here is all App's Firebase related debug logs from app launch to subscription purchase.
2024-09-09 11:43:26.238 11078-11078 FirebaseApp com.sharpshooter I Device unlocked: initializing all Firebase APIs for app [DEFAULT]
2024-09-09 11:43:26.250 11078-11078 FirebaseInitProvider com.sharpshooter I FirebaseApp initialization successful
2024-09-09 11:43:26.251 11078-11078 ReactNativeFirebaseApp com.sharpshooter D received application context.
2024-09-09 11:43:26.362 11078-11141 FA com.sharpshooter I Faster debug mode event logging enabled. To disable, run:
adb shell setprop debug.firebase.analytics.app .none.
2024-09-09 11:43:43.427 24372-11023 FA com.android.vending W Failed to retrieve Firebase Instance Id
2024-09-09 11:43:49.384 24372-11023 FA com.android.vending W Failed to retrieve Firebase Instance Id
2024-09-09 11:43:49.623 11283-11283 FirebaseApp pid-11283 I Device unlocked: initializing all Firebase APIs for app [DEFAULT]
2024-09-09 11:43:49.626 11283-11283 FirebaseInitProvider pid-11283 I FirebaseApp initialization successful
2024-09-09 11:43:52.163 24372-11023 FA com.android.vending W Failed to retrieve Firebase Instance Id
2024-09-09 11:43:53.490 1021-28895 vendor.qti....2-service ven...re.servicetracker@1.2-service I bindService is called for service : com.android.vending/com.google.android.finsky.dfenotification.impl.PhoneskyFirebaseMessagingService and for client com.android.vending
2024-09-09 11:43:53.490 1021-28895 vendor.qti....2-service ven...re.servicetracker@1.2-service I total connections for service : com.android.vending/com.google.android.finsky.dfenotification.impl.PhoneskyFirebaseMessagingServiceare :1
2024-09-09 11:43:53.492 1021-28895 vendor.qti....2-service ven...re.servicetracker@1.2-service I startService() is called for servicecom.android.vending/com.google.android.finsky.dfenotification.impl.PhoneskyFirebaseMessagingService
2024-09-09 11:43:53.495 24372-11466 FirebaseMessaging com.android.vending I FirebaseApp has not being initialized. Device might be in direct boot mode. Skip exporting delivery metrics to Big Query
2024-09-09 11:43:53.497 24372-11466 Finsky com.android.vending I [64927] PhoneskyFirebaseMessagingService.a(171): FCM Handling notificationId=[EAMaEmMyNTdiODVjOTBkMjViMmM6MyCqs87d8sdf8dJKFJKKJ67]
2024-09-09 11:43:53.703 2282-2349 ActivityManager system_server I Start proc 11471:com.google.android.gm/u0a203 for broadcast {com.google.android.gm/com.google.firebase.iid.FirebaseInstanceIdReceiver} caller=com.google.android.gms
2024-09-09 11:43:54.312 1021-2684 vendor.qti....2-service ven...re.servicetracker@1.2-service I bindService is called for service : com.google.android.gm/com.google.android.libraries.hub.firebase.FirebaseMessagingServiceImpl and for client com.google.android.gm
2024-09-09 11:43:54.312 1021-2684 vendor.qti....2-service ven...re.servicetracker@1.2-service I total connections for service : com.google.android.gm/com.google.android.libraries.hub.firebase.FirebaseMessagingServiceImplare :1
2024-09-09 11:43:54.312 1021-2684 vendor.qti....2-service ven...re.servicetracker@1.2-service I startService() is called for servicecom.google.android.gm/com.google.android.libraries.hub.firebase.FirebaseMessagingServiceImpl
@nahlebn1k - see the docs when that event is triggered: https://support.google.com/analytics/answer/9234069?hl=en
This is an automatic event for in app purchasing, you won't see this event in debug mode:
@russellwheatley Oh, sorry, i missed up this line
Analytics ignores events that are flagged as invalid or tests. Learn more about testing Google Play billing.
Is this requirement also can provoke this debug message Failed to retrieve Firebase Instance Id
? Or this errors are not related?
Fairly sure this line is just a warning in android SDK:
Failed to retrieve Firebase Instance Id
I don't think it is related.
Okay, thank you!
Issue
Hello, we are trying to integrate Firebase Analytics for IAP events tracking. After making all steps and building app we tried to make in-app subscription purchase to log Predefined Firebase events. But, unfortunately, got nothing except log
Failed to retrieve Firebase Instance Id
. Other Debug Firebase logs saying thatI FirebaseApp initialization successful
. After callinganalytics().getAppInstanceId().then((id) => console.log(id))
I got my id. But i think FB Analytics not recognizing it while trying to log events. This error occurs on Android real device for now, IOS not tested yet. Can you provide any solution to this problem, please?Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "appName", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint ./src *.js --fix", "lint_action": "eslint ./src *.js", "format": "prettier --write ./src", "start": "react-native start", "test": "jest", "postinstall": "patch-package" }, "dependencies": { "@react-native-async-storage/async-storage": "^1.19.1", "@react-native-clipboard/clipboard": "^1.11.2", "@react-native-community/geolocation": "^3.1.0", "@react-native-community/netinfo": "^11.2.1", "@react-native-firebase/analytics": "^20.4.0", "@react-native-firebase/app": "^20.4.0", "@react-navigation/bottom-tabs": "^6.5.8", "@react-navigation/native": "^6.1.7", "@react-navigation/stack": "^6.3.17", "@reduxjs/toolkit": "^1.9.5", "@shopify/flash-list": "^1.6.2", "buffer": "^6.0.3", "i18next": "^23.3.0", "jszip": "^3.10.1", "postinstall-postinstall": "^2.1.0", "prop-types": "^15.8.1", "react": "18.2.0", "react-i18next": "^13.0.2", "react-native": "0.74.1", "react-native-adjust": "^4.38.1", "react-native-animated-pagination-dots": "^0.1.73", "react-native-ble-manager": "^10.1.5", "react-native-charts-wrapper": "^0.5.11", "react-native-check-box": "^2.1.7", "react-native-compass-heading": "^1.5.0", "react-native-device-info": "^10.7.0", "react-native-document-picker": "^9.0.1", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "^2.15.0", "react-native-html-to-pdf": "^0.12.0", "react-native-iap": "^12.14.0", "react-native-image-crop-picker": "^0.41.2", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-keychain": "^8.1.2", "react-native-localize": "^3.0.2", "react-native-safe-area-context": "^4.10.1", "react-native-screens": "^3.23.0", "react-native-sensors": "^7.3.6", "react-native-share": "^10.2.1", "react-native-sound": "^0.11.2", "react-native-svg": "^13.10.0", "react-native-svg-pan-zoom": "^0.1.2", "react-native-svg-transformer": "^1.1.0", "react-native-ui-lib": "^7.16.0", "react-native-video": "^5.2.1", "react-native-zip-archive": "^6.0.9", "react-redux": "^8.1.1", "redux": "^4.2.1", "redux-persist": "^6.0.0", "reselect": "^4.1.8" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/babel-preset": "0.74.83", "@react-native/eslint-config": "0.74.83", "@react-native/metro-config": "0.74.83", "@react-native/typescript-config": "0.74.83", "@stylistic/eslint-plugin-js": "^1.1.0", "@types/react": "^18.2.6", "@types/react-redux": "^7.1.25", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "babel-plugin-transform-remove-console": "^6.9.4", "eslint": "^8.53.0", "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-react": "^7.33.2", "jest": "^29.6.3", "obfuscator-io-metro-plugin": "^2.1.3", "patch-package": "^8.0.0", "prettier": "^3.0.3", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, "engines": { "node": ">=18" }, "packageManager": "yarn@3.6.4" } ``` #### `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 # Resolve react_native_pods.rb with node to allow for hoisting require Pod::Executable.execute_command('node', ['-p', 'require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )', __dir__]).strip platform :ios, min_ios_version_supported prepare_react_native_project! linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end target 'sharpshooter' do config = use_native_modules! use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true use_react_native!( :path => config[:reactNativePath], # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'sharpshooterTests' do inherit! :complete # Pods for testing end post_install do |installer| # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 react_native_post_install( installer, config[:reactNativePath], :mac_catalyst_enabled => false, # :ccache_enabled => true ) end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import
#import
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
self.moduleName = @"appName";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self bundleURL];
}
- (NSURL *)bundleURL
{
#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 buildscript { ext { buildToolsVersion = "34.0.0" minSdkVersion = 24 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "26.1.10909125" kotlinVersion = "1.9.22" androidXAnnotation = "1.1.0" androidXBrowser = "1.0.0" } repositories { google() mavenCentral() exclusiveContent { filter { includeGroup "com.facebook.react" } forRepository { maven { url "$rootDir/../node_modules/react-native/android" } } } } dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") classpath("com.google.gms:google-services:4.4.2") classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" } } apply plugin: "com.facebook.react.rootproject" ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" apply plugin: "com.google.gms.google-services" /** * This is the configuration block to customize your React Native Android app. * By default you don't need to apply any configuration, just uncomment the lines you need. */ react { /* Folders */ // The root of your project, i.e. where "package.json" lives. Default is '..' // root = file("../") // The folder where the react-native NPM package is. Default is ../node_modules/react-native // reactNativeDir = file("../node_modules/react-native") // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen // codegenDir = file("../node_modules/@react-native/codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js // cliFile = file("../node_modules/react-native/cli.js") /* Variants */ // The list of variants to that are debuggable. For those we're going to // skip the bundling of the JS bundle and the assets. By default is just 'debug'. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. // debuggableVariants = ["liteDebug", "prodDebug"] /* Bundling */ // A list containing the node command and its flags. Default is just 'node'. // nodeExecutableAndArgs = ["node"] // // The command to run when bundling. By default is 'bundle' // bundleCommand = "ram-bundle" // // The path to the CLI configuration file. Default is empty. // bundleConfig = file(../rn-cli.config.js) // // The name of the generated asset file containing your JS bundle // bundleAssetName = "MyApplication.android.bundle" // // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' // entryFile = file("../js/MyApplication.android.js") // // A list of extra flags to pass to the 'bundle' commands. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle // extraPackagerArgs = [] /* Hermes Commands */ // The hermes compiler command to run. By default it is 'hermesc' // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" // // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" // hermesFlags = ["-O", "-output-source-map"] } /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore (JSC) * * 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:+' def gitCommitHash = 'git rev-parse --verify --short HEAD'.execute().text.trim() def gitCommitCount = 'git rev-list HEAD --count'.execute().text.trim().toInteger() android { ndkVersion rootProject.ext.ndkVersion buildToolsVersion rootProject.ext.buildToolsVersion compileSdkVersion rootProject.ext.compileSdkVersion namespace "com.sharpshooter" defaultConfig { applicationId "com.appName" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode gitCommitCount versionName "1.0." + gitCommitCount + "." + gitCommitHash missingDimensionStrategy "store", "play" } signingConfigs { release { if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) { storeFile file(MYAPP_UPLOAD_STORE_FILE) storePassword MYAPP_UPLOAD_STORE_PASSWORD keyAlias MYAPP_UPLOAD_KEY_ALIAS keyPassword MYAPP_UPLOAD_KEY_PASSWORD } } debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" signingConfig signingConfigs.release } } composeOptions { kotlinCompilerExtensionVersion = "1.4.4" } buildFeatures { aidl = true } } //configurations.all { // resolutionStrategy { // force "com.facebook.fresco:fresco:2.5.0" // } //} dependencies { def billing_version = "6.2.0" implementation("com.android.billingclient:billing:$billing_version") implementation 'com.android.installreferrer:installreferrer:2.2' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' implementation files('libs/adjust-android-signature-3.20.1.aar') // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'appName' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' includeBuild('../node_modules/@react-native/gradle-plugin') ``` #### `MainApplication.java`: ```kt package com.appName import android.app.Application import com.facebook.react.PackageList import com.facebook.react.ReactApplication import com.facebook.react.ReactHost import com.facebook.react.ReactNativeHost import com.facebook.react.ReactPackage import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost import com.facebook.react.defaults.DefaultReactNativeHost import com.facebook.soloader.SoLoader class MainApplication : Application(), ReactApplication { init { System.loadLibrary("CoolProp") } override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) { override fun getPackages(): List =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
add(MyAppPackage())
}
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
}
}
```
#### `AndroidManifest.xml`:
```xml
```
Environment
Click To Expand
**`react-native info` output:** ``` System: OS: Windows 11 10.0.22631 CPU: "(12) x64 AMD Ryzen 5 5600H with Radeon Graphics " Memory: 983.02 MB / 13.86 GB Binaries: Node: version: 20.16.0 path: C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: version: 10.8.1 path: C:\Program Files\nodejs\npm.CMD Watchman: version: 20231008.002904.0 path: C:\ProgramData\chocolatey\bin\watchman.EXE SDKs: Android SDK: API Levels: - "33" - "34" Build Tools: - 30.0.3 - 33.0.0 - 33.0.1 - 34.0.0 System Images: - android-33 | Google APIs Intel x86_64 Atom - android-33 | Google Play Intel x86_64 Atom - android-34 | Google APIs Intel x86_64 Atom - android-34 | Google Play Intel x86_64 Atom Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: AI-232.10227.8.2321.11479570 Visual Studio: - 17.7.34031.279 (Visual Studio Community 2022) Languages: Java: 17.0.10 Ruby: Not Found npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.74.1 wanted: 0.74.1 react-native-windows: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: Not found newArchEnabled: Not found ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [x] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - 20.4.0 - **`Firebase` module(s) you're using that has the issue:** - Instance ID, Firebase Analytics - **Are you using `TypeScript`?** - No
React Native Firebase
andInvertase
on Twitter for updates on the library.