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
william
11/19/2020, 1:04 AM
seems a little vague of a question. you could fetch all this information lazily when it is requested if you want
a
Amritansh
11/19/2020, 1:24 AM
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
william
11/19/2020, 1:27 AM
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
German Politov
11/19/2020, 1:07 PM
@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
Santiago Avila
11/19/2020, 1:53 PM
You would need to use expect actual feature , most of this data on iOS is provided by
UIDevice
class
a
Amritansh
11/19/2020, 2:14 PM
thanks, that makes sense
a
André Mion
05/22/2024, 9:47 AM
@Santiago Avila,
UIDevice.currentDevice.name
returns only
"iPhone"
when running on a physical iPhone device.
Do you know any other solution?