Hello, I am working on a KMM library which require...
# multiplatform
a
Hello, I am working on a KMM library which requires me to get these values from iOS and Android Devices.  • appVersion • connection type: Wifi or cellular • Carrier • Os version • Device model What will be the best way to approach this? Should I ask them at the time of initialization in the Apps or is there another way to get them internally from the KMM project? Happy to elaborate more if this does not make sense.
w
seems a little vague of a question. you could fetch all this information lazily when it is requested if you want
a
Sorry, I should have put more effort in framing it well. What I mean is how can I get these values in a kotlin multi platform project? For instance if I need this data from iOS device , how can I get it in iOS main? Do I need to pass something from iOS app?
w
i can't say for the specifics, but research how to do this from objective-c, and the same principles will apply from your ios kotlin module
🙏 1
g
@Amritansh i think it's platform specific values, you have to use expect-actual feature of KMP in this case. In actual you will implement functions that provide needed values from each platform. https://kotlinlang.org/docs/reference/mpp-connect-to-apis.html
👍 1
s
You would need to use expect actual feature , most of this data on iOS is provided by
UIDevice
class
a
thanks, that makes sense
a
@Santiago Avila,
UIDevice.currentDevice.name
returns only
"iPhone"
when running on a physical iPhone device. Do you know any other solution?