• Модуль: mobileapp
  • Путь к файлу: ~/bitrix/modules/mobileapp/lib/mobile.php
  • Класс: BitrixMobileAppMobile
  • Вызов: Mobile::initScripts
static function initScripts()
{
	global $APPLICATION, $USER;

	CJSCore::Init();
	CJSCore::Init("db");
	$jsVarsFormat = <<
		(window.BX||top.BX).message({ 'USER_ID': '%s'});
		var appVersion = "%s";
		var platform = "%s";
		var mobileSiteDir = "%s";
	
		
JSCODE;

	$APPLICATION->AddHeadString(
		sprintf($jsVarsFormat,
			$USER->getId(),
			self::$apiVersion,
			self::$platform,
			SITE_DIR
		), false, true);

	if (self::$platform == "android")
	{
		/**
		 * This is workaround for android
		 * We use console.log() to tell the application about successful loading of this page
		 */
		$androidJS = <<
			 	console.log("bxdata://success");
			
JSCODE;

		$APPLICATION->AddHeadString($androidJS, false, true);
	}
	$userAgent = BitrixMainContext::getCurrent()->getServer()->get("HTTP_USER_AGENT");
	if(mb_strpos($userAgent, "WKWebView/BitrixMobile") === false)
	{
		$pgJsFile = "/bitrix/js/mobileapp/__deviceload__/cordova.js?mod=1";
		$APPLICATION->AddHeadString("", false, true);
	}


	$APPLICATION->AddHeadString("", false, true);
	$APPLICATION->AddHeadString("", false, true);


	if (self::$platform == "android")
	{
		$APPLICATION->AddHeadString("", false, false);
	}

	if (!array_key_exists("doNotUseViewPort", $_REQUEST))
	{
		$APPLICATION->AddHeadString(Mobile::getInstance()->getViewPort());
	}

	BitrixMainUIExtension::load([
		'mobile.ajax'
	]);
}