iOS Code Snippet Getting Device Properties

Discussion in 'iOS Code Snippets' started by Mashiane, May 27, 2015.

Similar threads

B4i Tutorial iBeacons
B4i Tutorial Background Fetch (Downloads)
B4i Code Snippet Full screen apps
B4i Tutorial Share data from your app with ActivityViewController
B4i Tutorial Inline Objective C code
B4i Code Snippet CSBuilder text direction
  1. Mashiane

    Mashiane Expert Licensed User

    This has been sources from questions asked, just consolidated it here...

    Code:
    Sub GetDeviceSystemName As String
        
    ' get the system name of the device
        Dim device As NativeObject
        device = device.Initialize(
    "UIDevice").RunMethod("currentDevice"Null)
        
    Dim name As Object = device.GetField("systemName").AsString
        
    Return name
    End Sub

    Sub GetDeviceModel As String
        
    ' get the device model
        Dim device As NativeObject
        device = device.Initialize(
    "UIDevice").RunMethod("currentDevice"Null)
        
    Dim name As Object = device.GetField("model").AsString
        
    Return name
    End Sub

    Sub GetDeviceName As String
        
    ' get the device name
        Dim device As NativeObject
        device = device.Initialize(
    "UIDevice").RunMethod("currentDevice"Null)
        
    Dim name As Object = device.GetField("name").AsString
        
    Return name
    End Sub

    Sub GetIMEI As String
        
    ' get device unique identifier
        Dim device As NativeObject
        device = device.Initialize(
    "UIDevice").RunMethod("currentDevice"Null)
        
    Dim name As String = device.GetField("identifierForVendor").AsString 
        
    Return name
    End Sub

    Sub GetPackageName As String
       
    ' get your app package name
       Dim no As NativeObject
       no = no.Initialize(
    "NSBundle").RunMethod("mainBundle"Null)
       
    Dim name As Object = no.RunMethod("objectForInfoDictionaryKey:"Array("CFBundleIdentifier"))
       
    Return name
    End Sub

    Sub GetAppName As String
        
    ' get app name
       Dim no As NativeObject
       no = no.Initialize(
    "NSBundle").RunMethod("mainBundle"Null)
       
    Dim name As Object = no.RunMethod("objectForInfoDictionaryKey:"Array("CFBundleDisplayName"))
       
    Return name
    End Sub

    Sub GetVersion As String
       
    Dim no As NativeObject
       no = no.Initialize(
    "NSBundle").RunMethod("mainBundle"Null)
       
    Dim name As Object = no.RunMethod("objectForInfoDictionaryKey:"Array("CFBundleShortVersionString"))
       
    Return name
    End Sub
     
    janderkan, ShaneG30, MikeH and 5 others like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice