Hey guys, would anyone know how to get device mode...
# kotlin-native
t
Hey guys, would anyone know how to get device model name in K/N? Something like this: https://stackoverflow.com/questions/11197509/how-to-get-device-make-and-model-on-ios
s
not really an answer, but I had a similar requirement and I ended up using the phone’s bluetooth name
t
hmm yeah, seems like it possible, just having a hard time translating it to kotlin 🙂
s
oh you’ll have to delegate it to individual platforms
t
actually I just figured it out 🙂
Copy code
override val deviceName: String get() {
        memScoped {
           val q = alloc<utsname>()
            uname(q.ptr)
            val name = NSString.stringWithCString(q.machine, encoding =  NSUTF8StringEncoding)
            return name?:""
        }
    }
thanks for taking a look!
s
huh I didn’t realize that was possible, awesome!
n
just stumbled upon this, thanks for sharing it back then! It looks like at the moment the
val name =
line can be refined to
q.machine.toKString()
.
191 Views