title: Prevent service worker from running on Safari
body: <p>I've got a service worker that I am using for push notifications in chrome and firefox, how can I exclude the service worker from running on Safari since it's causing exceptions. I've tried a couple of different ways of detecting if the user agent is safari, but it was always detecting as false even though it is Safari.</p>
  
  <p>The last detection method I've used is as following:</p>
  
  <pre><code>// Firefox 1.0+
  var isFirefox = typeof InstallTrigger !== 'undefined';
  
  // Safari 3.0+ "[object HTMLElementConstructor]" 
  var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { 
  return p.toString() === "[object SafariRemoteNotification]"; })
  (!window['safari'] || (typeof safari !== 'undefined' &amp;&amp; 
  safari.pushNotification));
  
  // Internet Explorer 6-11
  var isIE = /*@cc_on!@*/false || !!document.documentMode;
  
  // Edge 20+
  var isEdge = !isIE &amp;&amp; !!window.StyleMedia;
  
  // Chrome 1+
  var isChrome = !!window.chrome &amp;&amp; !!window.chrome.webstore;
  
  // Blink engine detection
  var isBlink = (isChrome || isOpera) &amp;&amp; !!window.CSS;
  
  var ua = navigator.userAgent.toLowerCase();
  var safariWindows = ua.indexOf("safari/") !== -1 &amp;&amp; ua.indexOf("windows") 
  !== -1 &amp;&amp; ua.indexOf("chrom") === -1;
  
  
  if (!isSafari &amp;&amp; !safariWindows) {
   //run service worker
  }
  </code></pre>