nhagen / react-intercom

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

window.Intercom('update') #23

Closed petromoldovan closed 7 years ago

petromoldovan commented 7 years ago

@nhagen could you please take a look at the following: I am trying to update outstanding messages for a user but the call Intercom('update'); from https://developers.intercom.com/docs/intercom-javascript does not seem to work.

Here is my code:

    specialButton = () => {
      let that = this;
      window.Intercom('trackEvent', 'someOffer');

      setTimeout(()=> {
          console.log("updated1")
          window.Intercom('update', {"name": "new dude"})
      }, 1000)

      setTimeout(()=> {
          console.log("updated2")
          window.Intercom('update')
      }, 61000)

      window.Intercom('onUnreadCountChange', function(unreadCount) {
          console.log("this is the onUnreadCountChange", unreadCount)
          window.Intercom('show');
      });
    }

do you know what could be the problem? window.Intercom('update', {"name": "new dude"}) does not seem to work as well. The name is not updated.

thank you!!!

nhagen commented 7 years ago

Are you able to see network calls being made to Intercom? This component doesn't do anything special with the window.Intercom object, so its unlikely that the bug is related to this package unless somehow the initialization is not working properly.

If you can't debug this with the network tab, it might be helpful to see where you initialize the intercom user in case intercom isn't associating these updates with a specific user.

petromoldovan commented 7 years ago

that is the thing the Intercom('update') does nothing. No network calls are executed. I tested with original code and it worked. Anyway, thanks!

nhagen commented 7 years ago

Glad you got it working! 👍