Closed mberkom closed 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.
Sorry, busy day, trying to get this published now. This doesn't actually change the API! Good solution. :tada:
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
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 theIntercomAPI
variable to the actual instance ofwindow.Intercom
. Instead, it was just settingIntercomAPI = 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 setwindow.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 towindow.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.