React-native-firebase: [ iOS ] _reactNativeFirebase2.default.analytics is not a function ?

Created on 8 Sep 2017  ·  11Comments  ·  Source: invertase/react-native-firebase

Out of the 6.3K installs / month, I admit I need help to figure out how to install and use react-native-firebase.

After a day of effort, I am missing something. I am a CocoaPod and Firebase newbie.

The following results in red box error:

import firebase from 'react-native-firebase';
...
firebase.analytics().setCurrentScreen('test screen');

screen shot 2017-09-07 at 8 51 56 pm

Environment

  1. Application Target Platform: iOS
  2. Development Operating System: macOS Sierra
  3. Build Tools: Xcode 8.3.3, iOS 9.3
  4. React Native version: 0.42.3
  5. RNFirebase Version: 2.2.0
  6. Firebase Module: pod 'Firebase/Analytics'

Podfile:

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

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

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

  # [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 "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',
    # Add any other subspecs you want to use in your project
  ]

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

I can put a breakpoint in RNFirebase init function and hit it.

I added GoogleService-Info.plist to my app and call [FIRApp configure] from didFinishLaunchingWithOptions.

What could I be missing?

Is there other required initialization in javascript besides the import ?

Why _reactNativeFirebase2.default.analytics is not a function ???

Troubleshooting tips are much appreciated.

-Ed

Waiting for User Response

All 11 comments

Hey, are you initializing firebase before you're using it? In the usage tab
in the docs (v2 not v3).

On 8 Sep 2017 03:06, "Eddie" notifications@github.com wrote:

Out of the 6.3K installs / month, I admit I need help to figure out how to
install and use react-native-firebase.

After a day of effort, I am missing something. I am a CocoaPod and
Firebase newbie.

The following results in red box error:

import firebase from 'react-native-firebase';
...
firebase.analytics().setCurrentScreen('test screen');

[image: screen shot 2017-09-07 at 8 51 56 pm]
https://user-images.githubusercontent.com/6115047/30192824-69a7961c-940f-11e7-83ba-0678f75a2fdb.png
Environment

  1. Application Target Platform: iOS
  2. Development Operating System: macOS Sierra
  3. Build Tools: Xcode 8.3.3, iOS 9.3
  4. React Native version: 0.42.3
  5. RNFirebase Version: 2.2.0
  6. Firebase Module: pod 'Firebase/Analytics'

Podfile:

Uncomment the next line to define a global platform for your project

platform :ios, '9.3'

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

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

# [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 "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',
# Add any other subspecs you want to use in your project
]

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

I can put a breakpoint in RNFirebase init function and hit it.

I added GoogleService-Info.plist to my app and call [FIRApp configure]
from didFinishLaunchingWithOptions.

What could I be missing?

Why _reactNativeFirebase2.default.analytics is not a function ???

Troubleshooting tips are much appreciated.

-Ed


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/397, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAzZXnkhDyQAq_68u14gKFLXSxdrymInks5sgKEQgaJpZM4PQmrD
.

If you've already initialized like @Ehesp mentioned and it's still not working then try clearing your xcode derived data and rebuilding - seems to be the bane of peoples lives lately on ios+firebase:

https://stackoverflow.com/questions/38016143/how-to-delete-derived-data-in-xcode-8

@Ehesp Thank you! Thank you!

  • Sadly I did not notice the published NPM package version did not match the github version.
  • I also did not notice the Version: drop-down on the doc pages at upper-right.

Until v3 is published to NPM I expect this may frustrate developers new to react-native-firebase.

Perhaps add a reference to the v2 docs be added to the README.md until v3 is published?

v2 Documentation | iOS Install Guide | Android Install Guide | FAQs | Feature Requests

Thank you for sharing your work!

Your documentation is outstanding ( when the developer is reading the correct version :-).

Sorry - this is off-topic.

I can only find location down to the country resolution in Firebase Analytics console?

After finally getting firebase working, I was excited about using all the features like FCM and database. I expect marketing will make me go back to using Google Analytics because they want city resolution they had in Google Analytics.

image

I thought this would happen, so added that bar at the top a while back, guessing people are missing it heh, will think of something else. 🙈

Also Firebase analytics doesn't currently support geographic drill down at the moment, but you can easily use both GA and FB-A together, we've done the same in our apps. Here's the one we use: https://github.com/idehub/react-native-google-analytics-bridge

@Salakar Thank you. Yes I did not see that at all. I was all focussed on setup and getting it working.

I'd hate to clutter your beautiful readme and docs, but I expect other new adopters of react-native-firebase may get caught in this as well. Really, the docs * are * beautiful.

I was using react-native-google-analytics-bridge a couple of days ago.

However, I had this nagging fear I might be missing out by not facing the future and switching to Firebase so I tried your react-native-firebase.

Using react-native-firebase it was very easy to get messaging working.
Much easier and quicker than getting Urban Airship to work.
I am eager to try Firebase storage, database, etc.

I may take your advice and use both. Use react-native-google-analytics-bridge just for the city location data and react-native-firebase for everything else.

Question: So if you want Firebase location at the city level, then you have to purchase a BigQuery subscription and then muck around writing API queries?

@esutton correct, I believe at the moment that's the only way to get down to city level is via BigQuery - bit 💩.

Worst case scenario using both is Firebase may eventually support it - then you can just drop the GA one anyway.

Also if this is a new project you might as well use v3 (can follow the migration guide from v2 to v3 there, nothing major), it's stable and will be the norm soon: http://invertase.link/next then you can go back to importing firebase anywhere etc and all the other goodies and enhancements v3 comes with. If you wanted to of course 😛

@Salakar Is v3 currently stable enough for production use?

I am marching to an early October release date for iOS then November-ish for Android.

I was thinking about whether I should use v3 since this is a new app that has not made first release yet.

Several of us are using v3 for prod apps, check out the discord chat, couple of discussions on their about v3. Should also long since be released when October rolls on by.

But feel free to use either, no pressure, just looking for early adopters ha, is generally faster performance wise and lots of little QoL things baked in.

Migrating from v2 to v3 at a later date is just as easy so no worries.

Will also close this issue now, feel free to chat with us/other devs on discord or god forbid gitter =D.

March on! ⚡️

Hii, i am getting white screen on ios and _reactNativeFirebase2.default.analytics is not a function this is the error.
How have you solved this
I am using v2

@ab987cd

Using v2.0.5

import Firebase from 'react-native-firebase';

const firebase = new Firebase();

firebase.analytics().setCurrentScreen('test screen');
Was this page helpful?
0 / 5 - 0 ratings