Created
June 26, 2019 03:07
-
-
Save e-lin/e9ebfbf5ab70a859ff29e9eb1023003b to your computer and use it in GitHub Desktop.
Subscribe to a Nearby Message 2 - subscribe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val client = Nearby.getMessagesClient(this) | |
private val messageListener = object : MessageListener() { | |
override fun onFound(message: Message) { | |
// message.content contains payload | |
} | |
override fun onLost(message: Message) {} | |
} | |
client.subscribe(messageListener, subscribeOpts) | |
.addOnSuccessListener(this) { | |
Log.d(TAG, "subscribe success") | |
} | |
.addOnFailureListener(this) { e -> | |
Log.e(TAG, "subscirbe failed", e) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment