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
{{ message }}
This repository was archived by the owner on Jun 13, 2023. It is now read-only.
let liveQueryClient = ParseLiveQuery.Client()
private var subscription: Subscription<PChatRoom>?
var chatRoomsQuery: PFQuery {
if isPrivate {
return (PChatRoom.query()?
.whereKey("name", containsString: PUser.currentUser()?.objectId)
.whereKey("private", equalTo: true)
.whereKey("belongsToUser", equalTo: PUser.currentUser()!)
.orderByDescending("createdAt"))!
} else {
return (PChatRoom.query()?
.whereKey("isPrivate", equalTo: false)
.orderByDescending("createdAt"))!
}
}
override func viewDidLoad() {
super.viewDidLoad()
getExistingRooms()
subscribeToUpdates()
}
func subscribeToUpdates() {
subscription = liveQueryClient
.subscribe(chatRoomsQuery)
.handle(Event.Created) { _, room in
self.addRoom(room)
}
}
func getExistingRooms() {
chatRoomsQuery.findObjectsInBackground().continueWithBlock() { task in
if let chatRooms = task.result as? [PChatRoom] {
for room in chatRooms {
self.arrayOfChatRooms.append(room)
}
self.tableView.reloadData()
}
return nil
}
}
Messages.swift
let liveQueryClient = ParseLiveQuery.Client()
private var subscription: Subscription<PChatMessage>?
var chatQuery: PFQuery {
if isPrivate {
return (PChatMessage.query()?
.whereKey("room", equalTo: room)
.whereKey("private", equalTo: true)
.whereKey("belongsToUser", equalTo: PUser.currentUser()!)
.orderByDescending("createdAt"))!
} else {
return (PChatMessage.query()?
.whereKey("isPrivate", equalTo: false)
.whereKey("room", equalTo: room)
.orderByDescending("createdAt"))!
}
}
override func viewDidLoad() {
super.viewDidLoad()
getExistingMessages()
subscribeToUpdates()
}
func getExistingMessages() {
chatQuery.findObjectsInBackground().continueWithBlock() { task in
if let chatLog = task.result as? [PChatMessage] {
for message in chatLog {
self.addMessage(message.author.objectId!, text: message.message)
}
self.finishReceivingMessage()
}
return nil
}
}
func subscribeToUpdates() {
subscription = liveQueryClient
.subscribe(chatQuery)
.handle(Event.Created) { _, message in
self.incomingMessage(message)
}
}
Nearly identical liveQueries in both classes.
ChatRooms.swift works fine and receives live updates.
When calling subscribe in Messages.swift, the console outputs only "140725914386528"
and breakpoints at throw LiveQueryErrors.InvalidJSONError(json: json, expectedKey: key) in Operation.swift
func jsonValue<T>(json: [String:AnyObject], _ key: String) throws -> T {
guard let value = json[key] as? T
else {
**throw LiveQueryErrors.InvalidJSONError(json: json, expectedKey: key)**
}
return value
}
What might be causing this to be thrown?
The text was updated successfully, but these errors were encountered:
I have same problem when use conditions with Date or Location. I think they not support. In you case I think you have error because use this conditions ".whereKey("belongsToUser", equalTo: PUser.currentUser()!) "
Please check it
Running latest versions of parse server and iOS SDK.
Server setup:
ChatRooms.swift
Messages.swift
Nearly identical liveQueries in both classes.
ChatRooms.swift works fine and receives live updates.
When calling subscribe in Messages.swift, the console outputs only "140725914386528"
and breakpoints at throw LiveQueryErrors.InvalidJSONError(json: json, expectedKey: key) in Operation.swift
What might be causing this to be thrown?
The text was updated successfully, but these errors were encountered: