1

I am using device platform library in angular which works fine but for ios 13+ it does not detect if it is ios or not. It will give me result as false.

Code :

import { Injectable } from '@angular/core';
import platform from 'platform';
@Injectable({
  providedIn: 'root'
})
export class DeviceService {
  get isAndroid(): boolean {
    if (navigator.userAgent.match(/Android/i)) {
      return true;
    }
    return false;
  }
  get isIOS(): boolean {
    return platform.os.family === 'iOS';
  }
  get isMobile(): boolean {
    return this.isAndroid || this.isIOS;
  }
  get isSidebarEnabled(): boolean {
    return !this.isMobile;
  }
  get isMobileDevice(): boolean {
    return this.isMobile;
  }
}

How do we fix this for ios 13+. So i have an ipad with the OS version as ios 13.5.1 and in that i always get isIos as false. What could be the reason for this. Other versions it works fine.

ashish
  • 273
  • 1
  • 5
  • 16
  • 1
    Read [this](https://stackoverflow.com/questions/58019463/how-to-detect-device-name-in-safari-on-ios-13-while-it-doesnt-show-the-correct) – Raptor Aug 25 '20 at 07:09
  • @Raptor Thanks for the help. I had one doubt i read this code somewhere but there was a comment on it saying that : "This code above seems reasonable but is not reliable as it will break if there ever is a Mac version with touch support / or if someone potentially uses a touch monitor. I'm not sure if the Platform service should handle iOS13 right now (if it is not reliable). The intention seems to be that Safari on iPad iOS13+ behaves like a desktop Safari browser anyway." Is this ok to use will it affect mac desktop users? – ashish Aug 25 '20 at 07:14

0 Answers0