Skip to content

このページは翻訳の準備中のため、英語の原文を表示しています。

isIOS

isIOS is a utility function that detects whether the current device is running iOS or iPadOS.

Notes on platform inconsistencies:

  • Prior to iPadOS 13, iPads reported their platform as "iPad" (or matched /iPad/ in UA).
  • Starting from iPadOS 13, Apple changed the platform string to "MacIntel" to make websites treat iPadOS as desktop-class Safari. However, these devices still expose multi-touch capabilities.

Interface

ts
function isIOS(userAgent: string): boolean;

Parameters

  • userAgentstring

    Optional user agent string to check. Defaults to navigator.userAgent.

Return Value

  • boolean

    if the device is running iOS or iPadOS, false otherwise. Returns false on server


Example

tsx
if (isIOS()) {
  // iOS-specific code
  enableIOSOptimizations();
}

// With custom user agent
const isIOSDevice = isIOS(
  'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)'
);

MIT ライセンスの下で配布されています。