1
  • I am trying to include intercom npm package in my code base
  • but I am getting below error.
  • can you guys tell me how to fix it.
  • providing my code snippet below

app/app.component.ts(192,17): error TS2339: Property 'init' does not exist on type 'Intercom'.

package https://www.npmjs.com/package/ng-intercom

ngOnInit(): void {

    this.intercom.init({
        app_id: "mobilecode",
        // Supports all optional configuration.
        widget: {
            "activator": "#intercom" 
        }
    });
  • providing whole code here since my codebase is huge

https://hastebin.com/nafocafaze.js

Lorenzo Montanari
  • 958
  • 1
  • 15
  • 19
  • Have you imported `IntercomModule` into corresponding module ? console log intercom object and share an output. since it's not `undefined`, something get's injected to it. – tchelidze Jan 17 '18 at 08:39

2 Answers2

1

In your app-module:

import { IntercomModule } from 'ng-intercom';

@NgModule({
  imports: [
    ...
    IntercomModule.forRoot({
      appId: <your_app_id>, // from your Intercom config
      updateOnRouterChange: true // will automatically run `update` on router event changes. Default: `false`
    })
  ...
  ]
})
axl-code
  • 2,192
  • 1
  • 14
  • 24
1

I got it working (in 1.0.0-beta.11) by using update() instead of init(). What I did was change the line inside ngOnInit()

from

this.intercom.init({

to

this.intercom.update({

The whole block will then look like:

ngOnInit() {
  this.intercom.update({
    app_id: <app_id>,
    // Supports all optional configuration.
    widget: {
      "activator": "#intercom"
    }
  });
}

Hope this helps!

(Another quickfix is downgrading to 1.0.0-beta.10 where init() does work.)

epoxy
  • 189
  • 1
  • 2
  • 8
  • I found out that the correct way to do it is to use the boot method instead like: **this.intercom.boot();** More explanation on this in the issue on their github: https://github.com/CaliStyle/angular2-intercom/issues/33 – epoxy Jan 29 '18 at 09:52