How To integrate MQTT in ionic 4 project

Hi All,
how to integrate MQTT in ionic 4 project
i have tried but failed
it is showing
ERROR Error: Uncaught (in promise): ReferenceError: global is not defined
i have tried
to fixed this but failed again
please help

thanks in advance

Did you successfully implement this?

Yeah, I have managed that through Web socket

1 Like

Could you share with us your solution? or you wanna sell it? contact us

sorry for late reply
install mqtt from here

in your page.ts

import { ConnectionStatus, MqttService, SubscriptionGrant } from '../../ngx-mqtt-client'; // i have copied this folder to app folder

constructor(private mqttService: MqttService,){}

connectMQTT() {
    this.mqttService.status().subscribe((s: ConnectionStatus) => {
      const status = s === ConnectionStatus.CONNECTED ? 'CONNECTED' : 'DISCONNECTED';
      this.status.push(`Mqtt client connection status: ${status}`);
      console.log(`Mqtt client connection status: ${status}`);