解析未为 _User table 调用的订阅处理 handleEvents
Parse SubscriptionHandling handleEvents not being invoked for _User table
我正在尝试订阅 _User table 中的更改,但是当我在 _User 中更改某些内容时 table handleEvents
未调用,我是这样做的:
private var parseLiveQueryClient: ParseLiveQueryClient? = ParseLiveQueryClient.Factory.getClient()
private var subscriptionHandling: SubscriptionHandling<ParseUser>? = null
private val livePointQuery = ParseUser.getQuery()
init {
subscriptionHandling = parseLiveQueryClient?.subscribe(livePointQuery)
subscriptionHandling?.handleSubscribe {
if (it != null){
Log.e("LIVE_QUERY","success") // invoked successfully
}else{
Log.e("LIVE_QUERY","null")
}
subscriptionHandling?.handleEvents { _, event, parseUser ->
Log.e("LIVE_QUERY_EVENT","${event.name}")
if(parseUser != null){
Log.e("LIVE_QUERY",parseUser.objectId)
}else{
Log.e("LIVE_QUERY","user null")
}
}
}
}
Logcat 结果:
ParseLiveQueryClient: Socket onMessage {"op":"subscribed","clientId":163,"requestId":1}
P.S,我成功订阅了其他 table 数据更新,例如:聊天。
已解决!问题不在客户端代码中,而是在服务器端配置中,_User class
没有启用 LiveQuery
,启用后我得到了更新:)
我正在尝试订阅 _User table 中的更改,但是当我在 _User 中更改某些内容时 table handleEvents
未调用,我是这样做的:
private var parseLiveQueryClient: ParseLiveQueryClient? = ParseLiveQueryClient.Factory.getClient()
private var subscriptionHandling: SubscriptionHandling<ParseUser>? = null
private val livePointQuery = ParseUser.getQuery()
init {
subscriptionHandling = parseLiveQueryClient?.subscribe(livePointQuery)
subscriptionHandling?.handleSubscribe {
if (it != null){
Log.e("LIVE_QUERY","success") // invoked successfully
}else{
Log.e("LIVE_QUERY","null")
}
subscriptionHandling?.handleEvents { _, event, parseUser ->
Log.e("LIVE_QUERY_EVENT","${event.name}")
if(parseUser != null){
Log.e("LIVE_QUERY",parseUser.objectId)
}else{
Log.e("LIVE_QUERY","user null")
}
}
}
}
Logcat 结果:
ParseLiveQueryClient: Socket onMessage {"op":"subscribed","clientId":163,"requestId":1}
P.S,我成功订阅了其他 table 数据更新,例如:聊天。
已解决!问题不在客户端代码中,而是在服务器端配置中,_User class
没有启用 LiveQuery
,启用后我得到了更新:)