After adding the line import Intercom from 'react-native-intercom'; I get the following error:

I followed all steps of the iOS installation. Could you kindly point me to the right direction?
I am also having this issue... by the following instruction here.
I had this because the library is not linked well, now solved.
@ohtangza could you let me know how you linked the library? thanks
I'm stuck on this as well.
Sorry, I'm new to the native eco system but how do you link the library?
Looked in the other thread and someone mentions "lRNIntercom.a" yet this file does not exist in the folder structure.
Please advise what library, what file and how you linked if in Android Studio. Thanks!
edit:
I solved my problem by editing App > build.gradle and changing
buildToolsVersion "23.0.2" to buildToolsVersion "25.0.2"
You also get this when trying to test using Jest. I have tried to mock but then get memory overflow problems.
@grifotv In my case, I run react-native link again and then restarted the packager.
If you encounter this issue while testing with Jest, try this mock:
// jest/mocks/react-native-intercom.js:
const mockReactNativeIntercom = {
registerIdentifiedUser: jest.genMockFn().mockReturnValue(Promise.resolve()),
registerUnidentifiedUser: jest.genMockFn().mockReturnValue(Promise.resolve()),
updateUser: jest.genMockFn().mockReturnValue(Promise.resolve()),
reset: jest.genMockFn().mockReturnValue(Promise.resolve()),
logEvent: jest.genMockFn().mockReturnValue(Promise.resolve()),
handlePushMessage: jest.genMockFn().mockReturnValue(Promise.resolve()),
displayMessenger: jest.genMockFn().mockReturnValue(Promise.resolve()),
hideMessenger: jest.genMockFn().mockReturnValue(Promise.resolve()),
displayMessageComposer: jest.genMockFn().mockReturnValue(Promise.resolve()),
displayMessageComposerWithInitialMessage: jest.genMockFn().mockReturnValue(Promise.resolve()),
displayConversationsList: jest.genMockFn().mockReturnValue(Promise.resolve()),
getUnreadConversationCount: jest.genMockFn().mockReturnValue(Promise.resolve()),
setLauncherVisibility: jest.genMockFn().mockReturnValue(Promise.resolve()),
setInAppMessageVisibility: jest.genMockFn().mockReturnValue(Promise.resolve()),
setupAPN: jest.genMockFn().mockReturnValue(Promise.resolve()),
registerForPush: jest.genMockFn().mockReturnValue(Promise.resolve()),
setUserHash: jest.genMockFn().mockReturnValue(Promise.resolve()),
setBottomPadding: jest.genMockFn().mockReturnValue(Promise.resolve()),
addEventListener: jest.fn(),
removeEventListener: jest.fn()
};
export default mockReactNativeIntercom;
// jest/setup.js:
import mockReactNativeIntercom from './mocks/react-native-intercom';
jest.mock('react-native-intercom', () => mockReactNativeIntercom);
Many thanks @irritant it appears my issue is elsewhere causing jest to fail with an out of memory error now.
I had the same issue, the package is installed and linked, but still receive the same error.
The problem was in the fact, that this package doesn't come with Intercom library, you have to install it yourself.
In my case, I was targeting iOS and after following the instructions here the problem is solved.
https://github.com/intercom/intercom-ios
Just make sure, that after you add a "Run script" in your Build phases, this script is placed after "Embed frameworks"
thanks @NSLS your post was a great help as I also had same problem and resolved (in same manner)
one thing written into the Intercom iOS installation docs, which i needed to change (my builds were failing) was the bash script path. In my app, I had dragged/dropped the Intercom.framework path directly underneath the projects root. ie per this screenshot

because of that, the path to the .sh needed to be as follows:

this might not be obvious to some so thought I'd add it in here. in reality Intercom should add a footnote to their iOS install docs about this.
Thank for the all of instructions above. I still had this issue on iOS after trying everything above. The final steps that fixed the problem, for me, were:
Build your iOS project and try again.
This worked for me.
I'm encountering this issue when I run my first jest test, I have the required lib in iOS and intercom is working just fine
Here is the output
Test suite failed to run
TypeError: Cannot read property 'UNREAD_CHANGE_NOTIFICATION' of undefined
at new IntercomClient (node_modules/react-native-intercom/lib/IntercomClient.js:26:117)
at Object.<anonymous> (node_modules/react-native-intercom/lib/IntercomClient.js:356:16)
at Object.<anonymous> (app/lib/helpers/intercomHelpers.js:5:174)
My test is simple
it('renders correctly', () => {
const tree = renderer.create(
<Login />
).toJSON();
expect(tree).toMatchSnapshot();
});
Anyone have any ideas how to fix this
Something that works for me:
jest.mock('react-native-intercom', () => {}, { virtual: true });
any solution?
Struggling here as well...
Was able to solve using this
For me neither, it does not seem to be related to a configuration problem as it builds and runs just fine on both platforms.
It's only while executing Jest unit tests that are importing react-native-intercom...
Mocking the module did not fix the problem for me
Alleluia, I found how to work around this problem!
Use require for all of your imports importing react-native-intercom in your tests and
jest.mock('react-native-intercom', () => {});
Thank for the all of instructions above. I still had this issue on iOS after trying everything above. The final steps that fixed the problem, for me, were:
- In XCode, in the project navigator right click Libraries ➜ Add Files to [your project's name]
- Go to node_modules ➜ react-native-intercom➜ iOS and add IntercomWrapper.h, IntercomWrapper.m, IntercomEventEmitter.h and IntercomEventEmitter.m.
Build your iOS project and try again.
This worked for me.
In addition to the 4 files listed above, I also added:
Adding the 6 files finally allowed me to import Intercom using import Intercom from 'react-native-intercom' and actually call Intercom Intercom.logEvent('viewed_screen', { extra: 'metadata' }) without getting any red screens.
If you encounter this issue while testing with Jest, try this mock:
// jest/mocks/react-native-intercom.js: const mockReactNativeIntercom = { registerIdentifiedUser: jest.genMockFn().mockReturnValue(Promise.resolve()), registerUnidentifiedUser: jest.genMockFn().mockReturnValue(Promise.resolve()), updateUser: jest.genMockFn().mockReturnValue(Promise.resolve()), reset: jest.genMockFn().mockReturnValue(Promise.resolve()), logEvent: jest.genMockFn().mockReturnValue(Promise.resolve()), handlePushMessage: jest.genMockFn().mockReturnValue(Promise.resolve()), displayMessenger: jest.genMockFn().mockReturnValue(Promise.resolve()), hideMessenger: jest.genMockFn().mockReturnValue(Promise.resolve()), displayMessageComposer: jest.genMockFn().mockReturnValue(Promise.resolve()), displayMessageComposerWithInitialMessage: jest.genMockFn().mockReturnValue(Promise.resolve()), displayConversationsList: jest.genMockFn().mockReturnValue(Promise.resolve()), getUnreadConversationCount: jest.genMockFn().mockReturnValue(Promise.resolve()), setLauncherVisibility: jest.genMockFn().mockReturnValue(Promise.resolve()), setInAppMessageVisibility: jest.genMockFn().mockReturnValue(Promise.resolve()), setupAPN: jest.genMockFn().mockReturnValue(Promise.resolve()), registerForPush: jest.genMockFn().mockReturnValue(Promise.resolve()), setUserHash: jest.genMockFn().mockReturnValue(Promise.resolve()), setBottomPadding: jest.genMockFn().mockReturnValue(Promise.resolve()), addEventListener: jest.fn(), removeEventListener: jest.fn() }; export default mockReactNativeIntercom; // jest/setup.js: import mockReactNativeIntercom from './mocks/react-native-intercom'; jest.mock('react-native-intercom', () => mockReactNativeIntercom);
Worked for me, but I had to replace genMockFn() with fn()
Most helpful comment
If you encounter this issue while testing with Jest, try this mock: