fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.56k stars 946 forks source link

[device_info_plus] Detect ios simulator phone type #273

Closed zeroprofit closed 1 year ago

zeroprofit commented 3 years ago

Hi,

Here's the code to detect ios simulator phone type. Originally, if device is simulator, plugin reports architecture for utsname.machine. Replace (void)handleMethodCall in FLTDeviceInfoPlusPlugin.m under device_info_plus-1.0.1/ios/Classes folder.

(void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  if ([@"getIosDeviceInfo" isEqualToString:call.method]) {
    UIDevice* device = [UIDevice currentDevice];
    struct utsname un;
    uname(&un);

    NSString* machine;
    if([[self isDevicePhysical] isEqualToString:@"true"]) {
      machine = @(un.machine);
    } else {
      machine = [[NSProcessInfo processInfo] environment][@"SIMULATOR_MODEL_IDENTIFIER"];
    }

    result(@{
      @"name" : [device name],
      @"systemName" : [device systemName],
      @"systemVersion" : [device systemVersion],
      @"model" : [device model],
      @"localizedModel" : [device localizedModel],
      @"identifierForVendor" : [[device identifierForVendor] UUIDString],
      @"isPhysicalDevice" : [self isDevicePhysical],
      @"utsname" : @{
        @"sysname" : @(un.sysname),
        @"nodename" : @(un.nodename),
        @"release" : @(un.release),
        @"version" : @(un.version),
        @"machine" : machine,
      }
    });
  } else {
    result(FlutterMethodNotImplemented);
  }
}
ekuleshov commented 2 years ago

This is also related to package_info_plus when installer info on ios could be a simulator. See #78

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

ekuleshov-idexx commented 2 years ago

How is this completed?

qharlie commented 2 years ago

I think it was just closed by the bot, I also need this

ekuleshov commented 2 years ago

@charlie-sanders I know it was, but the lack of owner's response is alerting. @zeroprofit @mhadaily @miquelbeltran could you please reopen this?

miquelbeltran commented 2 years ago

@ekuleshov

If a feature request went stale, it is because we don't have the time and resources to implement it. If you want to invest time implementing it, then we are happy to review any PRs.

Also, please do not directly mention maintainers

ekuleshov commented 2 years ago

@miquelbeltran so, any feature requests maintainers don't have time and resources are going to be auto-closed?

I can look at providing a PR at least for android and iOS for this or a more general enhancement https://github.com/fluttercommunity/plus_plugins/issues/570. But it would be helpful to have maintainers to at least comment/reply on the issues to outline what API changes would be acceptable.