I setup ParseServer and Android SDK successfully and I can send and retrieve Objects to and from my database. Now I want to use LiveQuery, I integrated the SDK and followed the tutorial (https://github.com/parse-community/ParseLiveQuery-Android), but somehow it is not working. Can someone help me find the error?
MainActviity:
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.parse.Parse
import com.parse.ParseObject
import com.parse.ParseQuery
import com.parse.livequery.ParseLiveQueryClient
import com.parse.livequery.SubscriptionHandling
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Parse.initialize(Parse.Configuration.Builder(this)
.applicationId("myId")
.server("http://192.168.178.84:1337/parse/")
.build())
// Build Live Query Client
val parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient()
// Build Query
val parseQuery = ParseQuery.getQuery("GameScore")
// Build Live Query Listener
val subscriptionHandling: SubscriptionHandling = parseLiveQueryClient.subscribe(parseQuery)
subscriptionHandling.handleSubscribe {
Toast.makeText(this, "Subscribed", Toast.LENGTH_LONG).show()
}
subscriptionHandling.handleEvents { query, event, data ->
print(event)
}
subscriptionHandling.handleError { query, exception ->
print(exception)
}
/*
This is working fine, means the app can connect to my server
*/
getData.setOnClickListener {
val query = ParseQuery.getQuery("GameScore")
query.getInBackground(
"U8E8PFI7RG"
) { data, e ->
if (e == null) {
textViewName.text = data.getString("playerName")
textViewScore.text = data.getInt("score").toString()
textViewCheatMode.text = data.objectId.toString()
} else {
print(e)
}
}
}
}
}
build.gradle (app) - dependencies
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// Parse Server
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.25.0"
// Parse Server Live Query
implementation 'com.github.parse-community:ParseLiveQuery-Android:1.2.2'
}
neither the toast is displayed nor the other events of subscribtionHandling react
EDIT: I installed parse-server and parse-dashboard along with mongodb on Ubuntu 18.04 and using Android Studio as my Client to connect via app to the database