1

I have a simple section in which I want to display something different when the user opens my app through the LinkedIn browser, Skype browser, and other default mobile browsers.

<audio id="audioplayer" playsinline controls loop autoplay hidden>
  <source src="audio/muzyka_meed_loop.mp3" type="audio/mpeg"> 
  Your browser does not support the audio element.
</audio>

<video id="videoplayer" playsinline="" muted="" autoplay="" movieid="1" src="https://meed.audiencevideo.com/videos/mena.mp4?rand=0.33113854266601805" style="opacity: 1;" class="ended"></video>
if (navigator.userAgent.match(/Android/i) ||
  navigator.userAgent.match(/webOS/i) ||
  navigator.userAgent.match(/iPhone/i) ||
  navigator.userAgent.match(/iPad/i) ||
  navigator.userAgent.match(/iPod/i) ||
  navigator.userAgent.match(/BlackBerry/) ||
  navigator.userAgent.match(/Windows Phone/i) ||
  navigator.userAgent.match(/ZuneWP7/i)
) {
  var aud = document.getElementById("audioplayer");
  var vid = document.getElementById("videoplayer");

  if (vid.paused == true) {
    if (aud.paused == false) {
      aud.pause();
    }
  } else if (vid.paused == false) {
    if (aud.paused == true) {
      aud.play();
    }
  }

  if (vid.muted == true) {
    if (aud.muted == false) {
      aud.muted = true;
    }
  } else if (vid.muted == false) {
    if (aud.muted == true) {
      aud.muted = false;
    }
  }
}

I am able to detect all other mobile browsers except for LinkedIn, Skype browsers. What do I need to change to in my code to detect LinkedIn and skype defaults browsers?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
The Dead Man
  • 6,258
  • 28
  • 111
  • 193
  • 1
    I don't believe this is possible. Apps will create WebViews which use a variation of the mobile devices default browser, which you can detect (see [here](https://stackoverflow.com/questions/37591279/detect-if-user-is-using-webview-for-android-ios-or-a-regular-browser)). ***However***, there is no way to know how that WebView was launched, ie. what app the user was in. – Rory McCrossan Sep 18 '19 at 08:19
  • [here's some info google search resulted in for skype](https://blog.paranoidpenguin.net/2015/10/what-is-the-latest-skype-for-business-user-agent-string/) it's 4 years old, but it shows a simple google search will help - at a guess you could look for `UCCAPI/` and `OC/` – Jaromanda X Sep 18 '19 at 08:25
  • @RoryMcCrossan my problem here is audio not playing on the Linkedin browser, and skype browsers, do you know what do I need to do to make audio play on these browsers? – The Dead Man Sep 18 '19 at 08:52
  • It's possible those browsers don't support audio, or have disabled it, as it's very intrusive to automatically play sound as soon as the user enters the page, moreso without the user even making any interaction with the page. – Rory McCrossan Sep 18 '19 at 08:54
  • @JaromandaX thanks, that also does not work and what about Linkedin? – The Dead Man Sep 18 '19 at 09:25

1 Answers1

0

For others that might came here with the same question as me, I solved it with document.referrer

In my case it was fairly easy to spot.

document.referrer
// output: android-app://com.linkedin.android/
PawFV
  • 394
  • 2
  • 8