Skip to content

Instantly share code, notes, and snippets.

@AlexPrestonSB
Created November 5, 2019 23:03
Show Gist options
  • Save AlexPrestonSB/21abc8688cf807f4cd3421d3edb29a5e to your computer and use it in GitHub Desktop.
Save AlexPrestonSB/21abc8688cf807f4cd3421d3edb29a5e to your computer and use it in GitHub Desktop.
Snippet showing the shareLocation function
override fun shareLocation(context: Context) {
val lm = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER)
val longitude = location.longitude
val latitude = location.latitude
val result = "$longitude,$latitude"
val params = UserMessageParams()
params.setMessage(result)
params.setCustomType("location")
if (channel != null) {
channel!!.sendUserMessage(params) { userMessage, e ->
if (e != null) {
//Error Handling
} else {
messageCollection?.appendMessage(userMessage as BaseMessage)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment