iPhoneX detection on device and in simulator

  1. Without our ability to detect the iPhone X skin in the simulator, all of my custom code to nicely place UI elements around the top inset cannot be seen unless I see it on an actual device. So, is there a way to detect iPhone X skin from within our code?

  2. is this code the definitive test if an actual device is an iPhone X? Or how should it be adjusted?

      local f=(string.find( system.getInfo(“architectureInfo”),“iPhone10,3”)~= nil) or
      (string.find(system.getInfo(“architectureInfo”),“iPhone10,6” )~= nil)

      if f==true then
        – true means this code runs if on an actual iPhone X+ device, including future phones with insets?
      end
 

If you’re using SSK (https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/system/#actual-device-flags), just do this:

if( oniPhoneX ) then -- your special iPhoneX code end

You can detect this yourself using this code:

local actualWidth = math.floor((display.actualContentWidth/display.contentScaleX)+0.5) local actualHeight = math.floor((display.actualContentHeight/display.contentScaleY)+0.5)   local function matchesWH(width,height) return( (width == actualWidth and height == actualHeight) or (height == actualWidth and width == actualHeight) ) end local oniPhoneX = ( string.find( architectureInfo, "iPhone10,3" ) ~= nil ) or ( string.find( architectureInfo, "iPhone10,6" ) ~= nil ) or (system.getInfo("environment") == "simulator" and matchesWH(1125,2436) )

(SOLVED) based upon your response, I can conclude that to test if a device is on iPhoneX, I would use the following…

if (system.getInfo(“platform”)==“ios” and (string.find( system.getInfo(“architectureInfo”),“iPhone10,3”)~= nil) or (string.find(system.getInfo(“architectureInfo”),“iPhone10,6” )~= nil)) or (system.getInfo(“environment”)==“simulator” and display.viewableContentHeight==2436 and display.viewableContentWidth==1125) then

  – CODE would go here if 1) actual device is iOS and iPhoneX and 2) if in simulator mode running iPhoneX skin
end

If you’re using SSK (https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/system/#actual-device-flags), just do this:

if( oniPhoneX ) then -- your special iPhoneX code end

You can detect this yourself using this code:

local actualWidth = math.floor((display.actualContentWidth/display.contentScaleX)+0.5) local actualHeight = math.floor((display.actualContentHeight/display.contentScaleY)+0.5)   local function matchesWH(width,height) return( (width == actualWidth and height == actualHeight) or (height == actualWidth and width == actualHeight) ) end local oniPhoneX = ( string.find( architectureInfo, "iPhone10,3" ) ~= nil ) or ( string.find( architectureInfo, "iPhone10,6" ) ~= nil ) or (system.getInfo("environment") == "simulator" and matchesWH(1125,2436) )

(SOLVED) based upon your response, I can conclude that to test if a device is on iPhoneX, I would use the following…

if (system.getInfo(“platform”)==“ios” and (string.find( system.getInfo(“architectureInfo”),“iPhone10,3”)~= nil) or (string.find(system.getInfo(“architectureInfo”),“iPhone10,6” )~= nil)) or (system.getInfo(“environment”)==“simulator” and display.viewableContentHeight==2436 and display.viewableContentWidth==1125) then

  – CODE would go here if 1) actual device is iOS and iPhoneX and 2) if in simulator mode running iPhoneX skin
end