Magento 2.2 - Mobile_detect is not workingMagento2 apache rewrites not working on localRequirejs shim option not workingMagento 2 Active Mobile Menu width calc() issue being doubledjQuery css is not working for mobileMagento 2: setPageSize not working in blockHow to set 2 different themes for Mobile and Desktop in Magento 2.1.7 without changing the core fileObserver and event not workingMagento 2: Desktop css is loading while mobile css not loadingCron jobs not workingHow to use require_once in magento 2

Is there a RAID 0 Equivalent for RAM?

Does grappling negate Mirror Image?

Is it allowed to activate the ability of multiple planeswalkers in a single turn?

Why do Radio Buttons not fill the entire outer circle?

Temporarily disable WLAN internet access for children, but allow it for adults

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Is it ethical to recieve stipend after publishing enough papers?

Change the color of a single dot in `ddot` symbol

What (the heck) is a Super Worm Equinox Moon?

15% tax on $7.5k earnings. Is that right?

How to explain what's wrong with this application of the chain rule?

Quoting Keynes in a lecture

What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?

Isometries between spherical space forms

Permission on Database

What is Cash Advance APR?

Is there a nicer/politer/more positive alternative for "negates"?

The IT department bottlenecks progress, how should I handle this?

C++ copy constructor called at return

Why the "ls" command is showing the permissions of files in a FAT32 partition?

Circuit Analysis: Obtaining Close Loop OP - AMP Transfer function

How can I write humor as character trait?

Which Article Helped Get Rid of Technobabble in RPGs?

What is the English pronunciation of "pain au chocolat"?



Magento 2.2 - Mobile_detect is not working


Magento2 apache rewrites not working on localRequirejs shim option not workingMagento 2 Active Mobile Menu width calc() issue being doubledjQuery css is not working for mobileMagento 2: setPageSize not working in blockHow to set 2 different themes for Mobile and Desktop in Magento 2.1.7 without changing the core fileObserver and event not workingMagento 2: Desktop css is loading while mobile css not loadingCron jobs not workingHow to use require_once in magento 2













3















require_once($directory->getRoot().'/Mobile_Detect.php');
$deviceDetect = new Mobile_Detect;
if ($deviceDetect->isMobile())
echo "<script>alert('MOBILE');</script>";
else
echo "<script>alert('WEB');</script>";



Always in all the device we get only "WEB".










share|improve this question


























    3















    require_once($directory->getRoot().'/Mobile_Detect.php');
    $deviceDetect = new Mobile_Detect;
    if ($deviceDetect->isMobile())
    echo "<script>alert('MOBILE');</script>";
    else
    echo "<script>alert('WEB');</script>";



    Always in all the device we get only "WEB".










    share|improve this question
























      3












      3








      3








      require_once($directory->getRoot().'/Mobile_Detect.php');
      $deviceDetect = new Mobile_Detect;
      if ($deviceDetect->isMobile())
      echo "<script>alert('MOBILE');</script>";
      else
      echo "<script>alert('WEB');</script>";



      Always in all the device we get only "WEB".










      share|improve this question














      require_once($directory->getRoot().'/Mobile_Detect.php');
      $deviceDetect = new Mobile_Detect;
      if ($deviceDetect->isMobile())
      echo "<script>alert('MOBILE');</script>";
      else
      echo "<script>alert('WEB');</script>";



      Always in all the device we get only "WEB".







      magento2 mobile-device






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      AmyAmy

      3279




      3279




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Add a function in any helper:



          public function isMobile()phone


          Then call this helper in your file:



          if($this->helper('VendorModuleHelperData')->isMobile())
          //Do mobile code






          share|improve this answer

























          • Thanks Shoaib, will check your answer and let you know.

            – Amy
            11 hours ago










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266729%2fmagento-2-2-mobile-detect-is-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Add a function in any helper:



          public function isMobile()phone


          Then call this helper in your file:



          if($this->helper('VendorModuleHelperData')->isMobile())
          //Do mobile code






          share|improve this answer

























          • Thanks Shoaib, will check your answer and let you know.

            – Amy
            11 hours ago















          0














          Add a function in any helper:



          public function isMobile()phone


          Then call this helper in your file:



          if($this->helper('VendorModuleHelperData')->isMobile())
          //Do mobile code






          share|improve this answer

























          • Thanks Shoaib, will check your answer and let you know.

            – Amy
            11 hours ago













          0












          0








          0







          Add a function in any helper:



          public function isMobile()phone


          Then call this helper in your file:



          if($this->helper('VendorModuleHelperData')->isMobile())
          //Do mobile code






          share|improve this answer















          Add a function in any helper:



          public function isMobile()phone


          Then call this helper in your file:



          if($this->helper('VendorModuleHelperData')->isMobile())
          //Do mobile code







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 18 hours ago

























          answered yesterday









          Shoaib MunirShoaib Munir

          2,1911828




          2,1911828












          • Thanks Shoaib, will check your answer and let you know.

            – Amy
            11 hours ago

















          • Thanks Shoaib, will check your answer and let you know.

            – Amy
            11 hours ago
















          Thanks Shoaib, will check your answer and let you know.

          – Amy
          11 hours ago





          Thanks Shoaib, will check your answer and let you know.

          – Amy
          11 hours ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266729%2fmagento-2-2-mobile-detect-is-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

          Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?