You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** ## First you will need to create service interactor object, * as a proxy for Live Location services **/privateval liveLocationServiceInteractor =object:LiveLocationServiceInteractorAbs() {
/** Define Your Context **/overrideval context:Context=this@MainActivity
/** GPS Configuration Block **/overrideval gpsConfig:GPSConfig=object:GPSConfig {
overrideval samplingRate:Long=10000
}
/** Notification Configuration Block **/overrideval notificationConfig:NotificationConfig=object:NotificationConfig {
overrideval foregroundServiceID:Int=1003overrideval notificationChannelID:String=CHANNEL_IDoverrideval notificationChannelName:String=CHANNEL_NAMEoverrideval notificationChannelDescription:String=CHANNEL_DESCRIPTIONoverrideval notificationPriority:Int=NotificationCompat.PRIORITY_DEFAULToverrideval iconRes:Int?=null
}
/** Network Configuration Block **/overrideval networkConfiguration:LiveLocationNetworkConfiguration=object:LiveLocationNetworkConfiguration {
overrideval url:String="http://websocket.company.com"/** You can define whether using Socket Communication or RESTFUL Api **/overrideval networkMethod:NetworkMethod=NetworkMethod.RESTFULL/** You can put static payload such athorizations and other header what ever you needed **/overrideval headers:HashMap<String, String> = hashMapOf(
"Header1" to "Bearer aasdasdadadadaa",
"Header2" to "Bearer 23423094029u40932"
)
/** Add descriptor to your message **/overrideval messageDescriptor:String by lazy {
val desc = hashMapOf<String, String>(
"userID" to userID.toString(),
"messagingToken" to messagingToken
)
Gson().toJson(desc)
}
}
/** Bellows are the interfaces you can use to get respond in realtime to your application **/overridefunonServiceStatusChanged(
serviceStatus:LiveLocationServiceInteractor.ServiceStatus
) {
lifecycleScope.launch {
liveLocationRunning.emit(
when (serviceStatus) {
LiveLocationServiceInteractor.ServiceStatus.RUNNING->trueLiveLocationServiceInteractor.ServiceStatus.DEAD->false
}
)
}
}
overridefunonError(
message:String?
) {
lifecycleScope.launch {
liveLocationError.emit(
message
)
}
}
overridefunonReceiveUpdate(
location:LocationResult
) {
if (location.lastLocation ==null) return
lifecycleScope.launch {
this@MainActivity.location.emit(
LatLng(
location.lastLocation!!.latitude,
location.lastLocation!!.longitude
)
)
}
}
}
2. Run
interactor.startService(
notificationTitle ="Live Location",
notificationMessage ="Singularity Live Location"
)