question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot read property 'UNREAD_CHANGE_NOTIFICATION' of undefined

See original GitHub issue

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

screen shot 2017-06-30 at 19 19 09

I followed all steps of the iOS installation. Could you kindly point me to the right direction?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
irritantcommented, Jul 10, 2017

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);
7reactions
ohtangzacommented, Jul 1, 2017

I had this because the library is not linked well, now solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build error "cannot read property unread change notification of ...
Getting the following build error on iOS, I'm on the latest version of react native, this package and the intercom ios SDK.
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Build error "cannot read property unread change notification of ...
Getting the following build error on iOS, I'm on the latest version of react native, this package and the intercom ios SDK.
Read more >
React: TypeError: Cannot read property 'newValue' of undefined
Issue. Array.prototype.find can return undefined if element isn't found. The find() method returns the value of the first element in the ...
Read more >
How to Prevent the Error: Cannot Read Property '0' of Undefined
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found