react-native-firebase-analytics icon indicating copy to clipboard operation
react-native-firebase-analytics copied to clipboard

undefined is not an object (evaluating 'FIRAnalytics.setEnabled)

Open uyu423 opened this issue 8 years ago • 6 comments

image

using react-native-firbase-analytics 1.0.6 using react-native 0.32.0

import React, {
  Component,
  PropTypes,
} from 'react';
import {
  View, 
  StyleSheet,
  ScrollView,
  Alert,
  AlertIOS,
  InteractionManager,
} from 'react-native';
import Analytics from 'react-native-firebase-analytics';
import Dialog from 'react-native-dialog';

// ...

export default class CartPage extends Component {       
  constructor(props) {                                  
    super(props);                                       
    this.state = {                                      
      renderPlaceholderOnly: false,                     
    };                                                  
    props.dispatch(fetchCartInfo(props.serviceType));   
    props.dispatch(fetchMyCouponCount());               
  }                                                     
                                                        
  componentWillMount() {                                
    console.log(Analytics.setEnabled);                  
    Analytics.setEnabled(false);                        
  }                                                     

I trying run this Component. occurring error undefined is not an object (evaluating 'FIRAnalytics.setEnabled)

but console is that.

02-04 19:52:28.531  2896  2959 I ReactNativeJS: [Function: setEnabled]
02-04 19:52:29.127  2896  2959 E ReactNativeJS: undefined is not an object (evaluating 'FIRAnalytics.setEnabled')

Naturally, I included google-service.json file as well. and already run rnpm link what the hell? I think NativeModules.RNFIRAnalytics is undefined. What should I check?

uyu423 avatar Feb 04 '17 10:02 uyu423

I think the rnpm link not correctly. If you are using the latest react native, I am not sure, around >= 0.39. You should add FIRAnalyticsPackage in MainApplication.java rather than MainActivity.java.

import com.evollu.react.fa.FIRAnalyticsPackage;
@Override
protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new FIRAnalyticsPackage(),
          new MainReactPackage()
      );
}

ngothanhtai avatar Feb 07 '17 07:02 ngothanhtai

have same problem on ios ? any comment?

Mactub07 avatar Mar 31 '17 09:03 Mactub07

@Mactub07 I've had problems with Android, and I have not been able to see if iOS is experiencing the same issue.

uyu423 avatar Mar 31 '17 11:03 uyu423

@Mactub07 Can you fixed this in IOS ??

paranat9221 avatar Dec 12 '17 02:12 paranat9221

i'm also having this issue on iOS.

karuzo17 avatar Dec 16 '17 15:12 karuzo17

Same issue in Ios

Naveenkant93 avatar Sep 07 '18 14:09 Naveenkant93