Skip to content

Commit

Permalink
feat(device_info_plus): Return model name for iOS and MacOS devices (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vbuberen authored Dec 10, 2024
1 parent 170703b commit 63ca4cd
Show file tree
Hide file tree
Showing 21 changed files with 371 additions and 24 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/device_info_plus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
script: ./.github/workflows/scripts/integration-test.sh android device_info_plus_example

ios_example_build:
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 30
steps:
- name: "Checkout repository"
Expand All @@ -101,7 +101,7 @@ jobs:
run: ./.github/workflows/scripts/build-examples.sh ios ./lib/main.dart

ios_integration_test:
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 30
steps:
- name: "Checkout repository"
Expand All @@ -115,12 +115,12 @@ jobs:
- name: "Start Simulator"
uses: futureware-tech/simulator-action@v4
with:
model: 'iPhone 15'
model: 'iPhone 16'
- name: "Run Integration Test"
run: ./.github/workflows/scripts/integration-test.sh ios device_info_plus_example

macos_example_build:
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 30
steps:
- name: "Checkout repository"
Expand All @@ -133,7 +133,7 @@ jobs:
run: ./.github/workflows/scripts/build-examples.sh macos ./lib/main.dart

macos_integration_test:
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 30
steps:
- name: "Checkout repository"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void main() {
expect(macosInfo.hostName, isNotNull);
expect(macosInfo.arch, isNotNull);
expect(macosInfo.model, isNotNull);
expect(macosInfo.modelName, isNotNull);
expect(macosInfo.kernelVersion, isNotNull);
expect(macosInfo.osRelease, isNotNull);
expect(macosInfo.activeCPUs, isNotNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -451,7 +451,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -579,7 +579,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -628,7 +628,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand All @@ -24,6 +26,8 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -43,9 +47,5 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class _MyAppState extends State<MyApp> {
'systemName': data.systemName,
'systemVersion': data.systemVersion,
'model': data.model,
'modelName': data.modelName,
'localizedModel': data.localizedModel,
'identifierForVendor': data.identifierForVendor,
'isPhysicalDevice': data.isPhysicalDevice,
Expand Down Expand Up @@ -166,6 +167,7 @@ class _MyAppState extends State<MyApp> {
'hostName': data.hostName,
'arch': data.arch,
'model': data.model,
'modelName': data.modelName,
'kernelVersion': data.kernelVersion,
'majorVersion': data.majorVersion,
'minorVersion': data.minorVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Cocoa
import FlutterMacOS

@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: device_info_plus_example
description: Demonstrates how to use the device_info_plus plugin.
version: 1.0.0

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
//
// DeviceIdentifiers.m
// device_info_plus
//
// Created by Volodymyr on 06.11.2024.
//
#import "./include/device_info_plus/DeviceIdentifiers.h"

@implementation DeviceIdentifiers

+ (NSString *)userKnownDeviceModel:(NSString *)identifier {
if ([identifier isEqualToString:@"iPhone6,1"]) {
return @"iPhone 5s";
} else if ([identifier isEqualToString:@"iPhone6,2"]) {
return @"iPhone 5s";
} else if ([identifier isEqualToString:@"iPhone7,2"]) {
return @"iPhone 6";
} else if ([identifier isEqualToString:@"iPhone7,1"]) {
return @"iPhone 6 Plus";
} else if ([identifier isEqualToString:@"iPhone8,1"]) {
return @"iPhone 6s";
} else if ([identifier isEqualToString:@"iPhone8,2"]) {
return @"iPhone 6s Plus";
} else if ([identifier isEqualToString:@"iPhone9,1"] ||
[identifier isEqualToString:@"iPhone9,3"]) {
return @"iPhone 7";
} else if ([identifier isEqualToString:@"iPhone9,2"] ||
[identifier isEqualToString:@"iPhone9,4"]) {
return @"iPhone 7 Plus";
} else if ([identifier isEqualToString:@"iPhone8,4"]) {
return @"iPhone SE";
} else if ([identifier isEqualToString:@"iPhone10,1"] ||
[identifier isEqualToString:@"iPhone10,4"]) {
return @"iPhone 8";
} else if ([identifier isEqualToString:@"iPhone10,2"] ||
[identifier isEqualToString:@"iPhone10,5"]) {
return @"iPhone 8 Plus";
} else if ([identifier isEqualToString:@"iPhone10,3"] ||
[identifier isEqualToString:@"iPhone10,6"]) {
return @"iPhone X";
} else if ([identifier isEqualToString:@"iPhone11,2"]) {
return @"iPhone XS";
} else if ([identifier isEqualToString:@"iPhone11,4"] ||
[identifier isEqualToString:@"iPhone11,6"]) {
return @"iPhone XS Max";
} else if ([identifier isEqualToString:@"iPhone11,8"]) {
return @"iPhone XR";
} else if ([identifier isEqualToString:@"iPhone12,1"]) {
return @"iPhone 11";
} else if ([identifier isEqualToString:@"iPhone12,3"]) {
return @"iPhone 11 Pro";
} else if ([identifier isEqualToString:@"iPhone12,5"]) {
return @"iPhone 11 Pro Max";
} else if ([identifier isEqualToString:@"iPhone12,8"]) {
return @"iPhone SE 2";
} else if ([identifier isEqualToString:@"iPhone13,2"]) {
return @"iPhone 12";
} else if ([identifier isEqualToString:@"iPhone13,1"]) {
return @"iPhone 12 Mini";
} else if ([identifier isEqualToString:@"iPhone13,3"]) {
return @"iPhone 12 Pro";
} else if ([identifier isEqualToString:@"iPhone13,4"]) {
return @"iPhone 12 Pro Max";
} else if ([identifier isEqualToString:@"iPhone14,5"]) {
return @"iPhone 13";
} else if ([identifier isEqualToString:@"iPhone14,4"]) {
return @"iPhone 13 Mini";
} else if ([identifier isEqualToString:@"iPhone14,2"]) {
return @"iPhone 13 Pro";
} else if ([identifier isEqualToString:@"iPhone14,3"]) {
return @"iPhone 13 Pro Max";
} else if ([identifier isEqualToString:@"iPhone14,6"]) {
return @"iPhone SE 3";
} else if ([identifier isEqualToString:@"iPhone14,7"]) {
return @"iPhone 14";
} else if ([identifier isEqualToString:@"iPhone14,8"]) {
return @"iPhone 14 Plus";
} else if ([identifier isEqualToString:@"iPhone15,2"]) {
return @"iPhone 14 Pro";
} else if ([identifier isEqualToString:@"iPhone15,3"]) {
return @"iPhone 14 Pro Max";
} else if ([identifier isEqualToString:@"iPhone15,4"]) {
return @"iPhone 15";
} else if ([identifier isEqualToString:@"iPhone15,5"]) {
return @"iPhone 15 Plus";
} else if ([identifier isEqualToString:@"iPhone16,1"]) {
return @"iPhone 15 Pro";
} else if ([identifier isEqualToString:@"iPhone16,2"]) {
return @"iPhone 15 Pro Max";
} else if ([identifier isEqualToString:@"iPhone17,3"]) {
return @"iPhone 16";
} else if ([identifier isEqualToString:@"iPhone17,4"]) {
return @"iPhone 16 Plus";
} else if ([identifier isEqualToString:@"iPhone17,1"]) {
return @"iPhone 16 Pro";
} else if ([identifier isEqualToString:@"iPhone17,2"]) {
return @"iPhone 16 Pro Max";
// iPads
} else if ([identifier isEqualToString:@"iPad4,1"] ||
[identifier isEqualToString:@"iPad4,2"] ||
[identifier isEqualToString:@"iPad4,3"]) {
return @"iPad Air";
} else if ([identifier isEqualToString:@"iPad5,3"] ||
[identifier isEqualToString:@"iPad5,4"]) {
return @"iPad Air 2";
} else if ([identifier isEqualToString:@"iPad6,11"] ||
[identifier isEqualToString:@"iPad6,12"]) {
return @"iPad 5";
} else if ([identifier isEqualToString:@"iPad7,5"] ||
[identifier isEqualToString:@"iPad7,6"]) {
return @"iPad 6";
} else if ([identifier isEqualToString:@"iPad11,3"] ||
[identifier isEqualToString:@"iPad11,4"]) {
return @"iPad Air 3";
} else if ([identifier isEqualToString:@"iPad7,11"] ||
[identifier isEqualToString:@"iPad7,12"]) {
return @"iPad 7";
} else if ([identifier isEqualToString:@"iPad11,6"] ||
[identifier isEqualToString:@"iPad11,7"]) {
return @"iPad 8";
} else if ([identifier isEqualToString:@"iPad12,1"] ||
[identifier isEqualToString:@"iPad12,2"]) {
return @"iPad 9";
} else if ([identifier isEqualToString:@"iPad13,18"] ||
[identifier isEqualToString:@"iPad13,19"]) {
return @"iPad 10";
} else if ([identifier isEqualToString:@"iPad13,1"] ||
[identifier isEqualToString:@"iPad13,2"]) {
return @"iPad Air 4";
} else if ([identifier isEqualToString:@"iPad13,16"] ||
[identifier isEqualToString:@"iPad13,17"]) {
return @"iPad Air 5";
} else if ([identifier isEqualToString:@"iPad14,8"] ||
[identifier isEqualToString:@"iPad14,9"]) {
return @"iPad Air 11-Inch M2";
} else if ([identifier isEqualToString:@"iPad14,10"] ||
[identifier isEqualToString:@"iPad14,11"]) {
return @"iPad Air 13-Inch M2";
} else if ([identifier isEqualToString:@"iPad2,5"] ||
[identifier isEqualToString:@"iPad2,6"] ||
[identifier isEqualToString:@"iPad2,7"]) {
return @"iPad Mini";
} else if ([identifier isEqualToString:@"iPad4,4"] ||
[identifier isEqualToString:@"iPad4,5"] ||
[identifier isEqualToString:@"iPad4,6"]) {
return @"iPad Mini 2";
} else if ([identifier isEqualToString:@"iPad4,7"] ||
[identifier isEqualToString:@"iPad4,8"] ||
[identifier isEqualToString:@"iPad4,9"]) {
return @"iPad Mini 3";
} else if ([identifier isEqualToString:@"iPad5,1"] ||
[identifier isEqualToString:@"iPad5,2"]) {
return @"iPad Mini 4";
} else if ([identifier isEqualToString:@"iPad11,1"] ||
[identifier isEqualToString:@"iPad11,2"]) {
return @"iPad Mini 5";
} else if ([identifier isEqualToString:@"iPad14,1"] ||
[identifier isEqualToString:@"iPad14,2"]) {
return @"iPad Mini 6";
} else if ([identifier isEqualToString:@"iPad6,3"] ||
[identifier isEqualToString:@"iPad6,4"]) {
return @"iPad Pro 9-Inch";
} else if ([identifier isEqualToString:@"iPad6,7"] ||
[identifier isEqualToString:@"iPad6,8"]) {
return @"iPad Pro 12-Inch";
} else if ([identifier isEqualToString:@"iPad7,1"] || [identifier isEqualToString:@"iPad7,2"]) {
return @"iPad Pro 12-Inch 2";
} else if ([identifier isEqualToString:@"iPad7,3"] || [identifier isEqualToString:@"iPad7,4"]) {
return @"iPad Pro 10-Inch";
} else if ([identifier isEqualToString:@"iPad8,1"] || [identifier isEqualToString:@"iPad8,2"] ||
[identifier isEqualToString:@"iPad8,3"] || [identifier isEqualToString:@"iPad8,4"]) {
return @"iPad Pro 11-Inch";
} else if ([identifier isEqualToString:@"iPad8,5"] || [identifier isEqualToString:@"iPad8,6"] ||
[identifier isEqualToString:@"iPad8,7"] || [identifier isEqualToString:@"iPad8,8"]) {
return @"iPad Pro 12-Inch 3";
} else if ([identifier isEqualToString:@"iPad8,9"] ||
[identifier isEqualToString:@"iPad8,10"]) {
return @"iPad Pro 11-Inch 2";
} else if ([identifier isEqualToString:@"iPad8,11"] ||
[identifier isEqualToString:@"iPad8,12"]) {
return @"iPad Pro 12-Inch 4";
} else if ([identifier isEqualToString:@"iPad13,4"] ||
[identifier isEqualToString:@"iPad13,5"] ||
[identifier isEqualToString:@"iPad13,6"] ||
[identifier isEqualToString:@"iPad13,7"]) {
return @"iPad Pro 11-Inch 3";
} else if ([identifier isEqualToString:@"iPad13,8"] ||
[identifier isEqualToString:@"iPad13,9"] ||
[identifier isEqualToString:@"iPad13,10"] ||
[identifier isEqualToString:@"iPad13,11"]) {
return @"iPad Pro 12-Inch 5";
} else if ([identifier isEqualToString:@"iPad14,3"] ||
[identifier isEqualToString:@"iPad14,4"]) {
return @"iPad Pro 11-Inch 4";
} else if ([identifier isEqualToString:@"iPad14,5"] ||
[identifier isEqualToString:@"iPad14,6"]) {
return @"iPad Pro 12-Inch 6";
} else if ([identifier isEqualToString:@"iPad16,3"] ||
[identifier isEqualToString:@"iPad16,4"]) {
return @"iPad Pro 11-Inch (M4)";
} else if ([identifier isEqualToString:@"iPad16,5"] ||
[identifier isEqualToString:@"iPad16,6"]) {
return @"iPad Pro 13-Inch (M4)";
} else {
return @"Unknown device";
}
}
@end
Loading

0 comments on commit 63ca4cd

Please sign in to comment.