Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New iPad OS detected as computer #917

Open
foRsxs opened this issue Jan 17, 2023 · 3 comments
Open

New iPad OS detected as computer #917

foRsxs opened this issue Jan 17, 2023 · 3 comments

Comments

@foRsxs
Copy link

foRsxs commented Jan 17, 2023

Hello! New iPad OS detected as computer. In new version Apple use core like on Mac

@webdesignweisshart
Copy link

Same with Microsoft Surface Go Win 11. Also detected as computer.

@aaronsummers
Copy link

aaronsummers commented Apr 17, 2023

Hello! New iPad OS detected as computer. In new version Apple use core like on Mac

I created a hacky way to detect the new iPad iOS. I found that the version number on a Mac contains a dot (.) and the version number on an iPad contains an underscore(_).

I'm just checking the version for an underscore and setting a global variable.

This may be of use to someone else.

(As a side note: I'm actually using this to set a session cookie within my own site rather than a global variable. But that code is out of scope for this reply.)

       /**
	 * HACKY WAY TO SEE IF WE'RE ON A IOS DEVICE 
	 ** Checking the user agent
	 ** Separate the content between the brackets returned by the user agent 
	 ** Create an array of the mobile device os separated by semicolon
	 ** Check for an underscore which is only used by iOS within the version number 
	 ** @example  '10.1' (Mac OS) / '10_1' (iOS)
	 */
	$mobile_detect = new \Detection\MobileDetect;
	$userAgent     = $mobile_detect->userAgent;
	$explode       = explode( '(', $userAgent );
	preg_match( '#\((.*?)\)#', $userAgent, $match );
	$current_os        = $match[1] ?? '';
	$current_os_array  = explode( '; ', $current_os );
	$mobile_os_version = ( str_contains( $current_os_array[1], '_' ) && str_contains( $current_os_array[1], 'OS X' ) );

	// Create the global variable...
	$GLOBALS['is_new_apple_tablet'] = $mobile_os_version; // @return boolean true || false

@seasoftjapan
Copy link

@aaronsummers
Your idea is very interesting.
But is it really discernible?

However, according to the following article, both OSes seem to use “_”.
https://www.bit-hive.com/articles/20190820

[Safari on iPad + iPadOS13(デスクトップ用Webサイトを表示:On設定時)]
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15

[Safari on macOS Mojave]
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15

I don't have that device so I can't verify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@aaronsummers @seasoftjapan @foRsxs @webdesignweisshart and others