iOS Question Identify when the app is running on Mac M1

marcick

Well-Known Member
Licensed User
Longtime User
Running this code, the Mac M1 looks like an Ipad. How can I detect that is instead a Mac M1 ?

B4X:
    Dim no As NativeObject   
    no = no.Initialize("UIDevice").RunMethod("currentDevice", Null)
    log(no.GetField("model").AsString)
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
There is a class called NSProcessInfo (Obj-C) / ProcessInfo (Swift) that has a boolean var called isiOSAppOnMac. Based on Erel's answer, it doesn't sound like it's implemented in B4i though.

- Colin.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Something like:
B4X:
Private Sub IsAppOnMac As Boolean
    Dim ProcessInfo As NativeObject
    ProcessInfo = ProcessInfo.Initialize("NSProcessInfo").RunMethod("new", Null)
    Return ProcessInfo.GetField("isiOSAppOnMac").AsBoolean
End Sub
Note that it is only available on iOS 14+. What is the output of:
B4X:
Log(Main.App.OSVersion)
on the Mac?
 
Upvote 0
Top