UNPKG

@textback/notification-widget

Version:

TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.

28 lines (21 loc) 1.05 kB
import Channel from './channel.js'; import browserInfo from '../utils/browserInfo.js'; import getLocale from '../../libraries/localization/getLocale.js'; import text from '../../libraries/localization/text.js'; export default class WhatsappbChannel extends Channel { constructor(channelData = {}, deeplink, widget) { super(channelData, deeplink, widget); this.domainPrefix = browserInfo.isMobile() ? 'api' : 'web'; if(channelData.hasOwnProperty('additionalProperties') && channelData.additionalProperties.hasOwnProperty('customDeeplinkValue')) { this.customText = channelData.additionalProperties.customDeeplinkValue; } else { this.customText = null; } } subscribe() { super.subscribe(); let prefixText = text('whatsapp_prefixtext', getLocale()); let deeplink = this.customText ? this.customText : `${prefixText} ${this.deeplink}`; window.open(`https://api.whatsapp.com/send/?phone=+${this.id}&text=${encodeURIComponent(deeplink)}&app_absent=0`, 'whatsappb'); } }