Estimote/react-native-proximity

Cannot read property "initialize" of undefined

Closed this issue · 10 comments

Hi, I've tried to implement the initialisation of the sdk with react native app but i get the error stating
"Cannot read property 'initialize' of undefined"
I've already got the app id and token from the cloud.

anything i missed out?
is there a more sequential documentation about the beacon setup?

thanks in advance

react-native v 0.59.8
android 8.0
react-native-proximity 0.5.0

after looking through the node modules,
i found out that

RNEstimoteProximity.initialize(
      Object.assign({}, config, {
        appId: credentials.appId,
        appToken: credentials.appToken
      })
    );

is not a valid function. Console.log(RNEstimoteProximity) gives me undefined. Please fix it asap

Hi, i tried several times reinstalling and linking the package based on the docs and its still not working as expected. Still showing Cannot read property "initialize" of undefined, i dropped a case on the community forum as well few days ago and no respond from the devs as well.

Kindly gives some advice at least, it seems so difficult to seek for assistance anywhere.

there is a linking mistake on my project, if anyone gone through similar error, check your MainApplication.java to make sure the RNEstimoteProximityPackage is added

there is a linking mistake on my project, if anyone gone through similar error, check your MainApplication.java to make sure the RNEstimoteProximityPackage is added

Can you show me your MainApplication.java code please?

go to your RN project directory, navigate to android -> app -> src -> main -> java -> MainApplication.java. Under code block ReactPackages, make sure the package RNEstimoteProximityPackage() is added

And what should I import in there? This is my MainApplication.java code:

package com.app;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.app.generated.BasePackageList;
import com.swmansion.reanimated.ReanimatedPackage;
import com.swmansion.rnscreens.RNScreensPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;


import org.unimodules.adapters.react.ReactAdapterPackage;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.Package;
import org.unimodules.core.interfaces.SingletonModule;
import expo.modules.constants.ConstantsPackage;
import expo.modules.permissions.PermissionsPackage;
import expo.modules.filesystem.FileSystemPackage;

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

public class MainApplication extends Application implements ReactApplication {
 private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(
   new BasePackageList().getPackageList(),
   Arrays.<SingletonModule>asList()
 );

 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 ReanimatedPackage(),
         new RNGestureHandlerPackage(),
         new RNScreensPackage(),
         new ModuleRegistryAdapter(mModuleRegistryProvider)
     );
   }

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

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

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

import com.estimote.react.RNEstimoteProximityPackage;

under Arrays.<ReactPackage>asList:
new RNEstimoteProximityPackage()

I've tried that but still have this error: package com.estimote.react does not exist. Any idea?

try re-install the package