react-native-batch-push icon indicating copy to clipboard operation
react-native-batch-push copied to clipboard

null is not an object (evaluating 'RNBatch.NOTIFICATION_TYPES')

Open samanthacampisi opened this issue 6 years ago • 2 comments

I'm trying to set up react-native-batch-push in my project.

So far I've followed all the steps in the installation guide and I made it work on iOS.

However, on Android, every time I try to import Batch or BatchPush in my code like this: import { BatchPush, Batch } from "@bam.tech/react-native-batch";

I get an error on Android only:

Screenshot_20200728-121006

So when I go to node_modules/@bam.tech/react-native-batch/dist/BatchPush.js I see this

const RNBatch = react_native_1.NativeModules.RNBatch; exports.AndroidNotificationTypes = RNBatch.NOTIFICATION_TYPES; So, is somehow the native module not being imported correctly? Do I need to follow extra steps for this to work?

@bam.tech/react-native-batch is being used with version 5.2.1 npm version 6.14.7 react-native version 0.60.5

samanthacampisi avatar Jul 28 '20 10:07 samanthacampisi

+1

chris32g avatar Jul 29 '20 11:07 chris32g

Update: it turns out that the package was not linked correctly and that I had to manually add the package in MainApplication.java (I don't really know why react-native link did not do this automatically)

Add the import: import tech.bam.RNBatchPush.RNBatchPackage;

And then add new RNBatchPackage(), in the getPackages() method.

I think it's safe to close the issue now!

samcampisi avatar Jul 29 '20 12:07 samcampisi