nhagen / react-intercom

A component to configure and enable Intercom in your react application
MIT License
237 stars 72 forks source link

Resolves issue #18 - Fix for IntercomAPI #20

Closed mberkom closed 8 years ago

mberkom commented 8 years ago

When updating to the latest version of the Intercom messenger, my reference to IntercomAPI stopped working in our app. Same issue as reported in #18. What I discovered was that the .onload function on line 40 was no longer setting the IntercomAPI variable to the actual instance of window.Intercom. Instead, it was just setting IntercomAPI = i. I think this issue cropped up because the Intercom script is loaded in two stages now. The first script that gets loaded, doesn't appear to set window.Intercom, so the code was doing that prematurely.

As a solution, instead of depending on the onload event, I just updated the IntercomAPI export to be a function that passes through to window.Intercom assuming that the Intercom script has successfully initialized. It should accomplish the same thing as before, but be more maintainable long term should Intercom change their script behavior again.

nhagen commented 8 years ago

Thanks for pull request! This is a major API change, so I'll merge this in as a major release corresponding to the updated messenger and add some documentation.

nhagen commented 8 years ago

Sorry, busy day, trying to get this published now. This doesn't actually change the API! Good solution. :tada:

ffxsam commented 8 years ago

I talked to Intercom support about this. They said any developers working on third party packages that use Intercom should subscribe to the developer blog ("intercom-updates" tag) so they're up to speed on any API updates.

https://medium.com/intercom-developers/tagged/intercom-updates