https://kotlinlang.org logo
#announcements
Title
# announcements
j

Joey

11/26/2019, 3:01 AM
Can i have your opinion regarding monitoring/listening location from android and iOS device and using the common to send the data to the server. (This is an MPP/shared library project). Im having a hard time since we dont have plugins or libraries that handles location from multiplatform project. Thanks!
d

darkmoon_uk

11/26/2019, 4:10 AM
It shouldn't be that hard, really - the Location API's of Android and iOS are not that dissimilar for a start.
Both have permissions that can be checked for, a
start
and
stop
lifecycle and a call-back with location to a known position, accuracy, time-stamp etc.
Abstract the common behaviours between the two, into your common source set as an interface e.g.
LocationProvider
. Create a common model
data class
to represent returned locations, too.
Then implement an adapter style class to the API's of the Android and iOS platforms in their respective source-sets e.g.
AndroidLocationProvider
and
iOSLocationProvider
No plugins or libraries needed. 👌
j

Joey

11/26/2019, 4:13 AM
Thank you so much! Appreciate it!
👍 1