ChannelOpenLine::getNotificationsWidget

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ChannelOpenLine
  4. getNotificationsWidget
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/sitebutton/channel/channelopenline.php
  • Класс: Bitrix\Crm\SiteButton\Channel\ChannelOpenLine
  • Вызов: ChannelOpenLine::getNotificationsWidget
static function getNotificationsWidget($lang): ?array
{
	$widget = [];
	if (!Loader::includeModule('notifications'))
	{
		return null;
	}
	if (!Notifications\Settings::isScenarioEnabled(Notifications\Settings::SCENARIO_VIRTUAL_WHATSAPP))
	{
		return null;
	}

	$portalCode = Notifications\Alias::getCodeForScenario(Notifications\Settings::SCENARIO_VIRTUAL_WHATSAPP);
	$url = ImConnector\Tools\Connectors\Notifications::getVirtualWhatsappLink($portalCode, $lang);
	$onclick = ImConnector\Tools\Connectors\Notifications::getVirtualWhatsappOnClick($url);
	$widgetParams = [
		'url' => $url,
		'onclick' => $onclick,
		'messages' => ImConnector\Tools\Connectors\Notifications::getWidgetLocalization($lang),
		'disclaimerUrl' => ImConnector\Tools\Connectors\Notifications::getWidgetDisclaimerUrl($lang),
	];
	$widgetParamsEncoded = Json::encode($widgetParams);
	$widget['title'] = Loc::getMessage("CRM_BUTTON_MANAGER_OPENLINE_VIRTUAL_WHATSAPP_TITLE");
	$widget['script'] = ImConnector\Tools\Connectors\Notifications::getWidgetScript();
	$widget['show'] = [
		'js' => [
			'desktop' =>'BX.NotificationsWidgetLoader.init('.$widgetParamsEncoded.').then(function(){window.BX.NotificationsWidget.Instance.show();})',
		],
		'url' => [
			'mobile' => $url,
			'force' => true,
		],
	];
	$widget['hide'] = 'window.BX.NotificationsWidget.Instance.close();';
	$widget['freeze'] = true;
	$widget['classList'] = [
		'ui-icon',
		'ui-icon-service-' . ImConnector\Connector::getIconByConnector('notifications_virtual_wa'),
		'connector-icon-45'
	];

	return $widget;
}

Добавить комментарий