- Source:
Methods
detectAppleDevice(additionalTestopt, nullable) → {String}
Try to determine if the execution context is an Apple device and if so: which type.
We use an escalating test starting with the user agent and then, as a fallback, checking the platform value to determine the general device class (iPhone, iPad ,iPod ,Macintosh). If we get a Macintosh, we double check if the device might be a falsely reporting iPad with iPadOS13+.
You can hook up additional tests by providing an "additionalTest" function as a function parameter, that function takes the evaluated device type at the end of the function and expects a new device type to be returned. Using this, you can tap into the process and handle edge cases yourself.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
additionalTest |
function |
<optional> <nullable> |
null | if set, is executed after determining the device type, takes the current device type as parameter and is expected to return a new one; use this to add edge case tests to overwrite the result in certain conditions |
- Source:
Returns:
- Type
- String
Example
const IS_IOS_DEVICE = ['iphone', 'ipod', 'ipad'].includes(detectAppleDevice());