Skip to content

Commit

Permalink
fix: show correct device info for ios app runs on M1 mac (#379)
Browse files Browse the repository at this point in the history
* Fix AMP-41556 device info for app runs on M1 mac

Mac with M1 CPU can run ios app, the hw.machine will return iPad platform tag. In the getPlatformString method, added a boolean value isiOSAppOnMac, if it's true and target os is not osx, use hw.model instead of hw.machine.
  • Loading branch information
bohan-amplitude authored Jan 20, 2022
1 parent b8a0d51 commit 7a75adb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Sources/Amplitude/AMPDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,17 @@ + (NSString *)generateUUID {
}

+ (NSString *)getPlatformString {
#if !TARGET_OS_OSX
const char *sysctl_name = "hw.machine";
#else
const char *sysctl_name = "hw.model";
#if TARGET_OS_IOS
BOOL isiOSAppOnMac = NO;
if (@available(iOS 14.0, *)) {
isiOSAppOnMac = [NSProcessInfo processInfo].isiOSAppOnMac;
}
if (!isiOSAppOnMac){
sysctl_name = "hw.machine";
}
#elif TARGET_OS_TV || TARGET_OS_WATCH
sysctl_name = "hw.machine";
#endif
size_t size;
sysctlbyname(sysctl_name, NULL, &size, NULL, 0);
Expand Down

0 comments on commit 7a75adb

Please sign in to comment.