Swift Parse: How to send notification to specific device / objectId

I'm trying to send a notification to a specific user in my users table, but my function didn't work and I don't understand why.

func testPush(){
    let message = "Alert !!"
    let id = "88yhi9j0"

    var data = [ "title": "Some Title",
        "alert": message]

    var userQuery: PFQuery = PFUser.query()
    userQuery.whereKey("objectId", equalTo: id)
    var query: PFQuery = PFInstallation.query()
    query.whereKey("currentUser", equalTo: userQuery)

    var push: PFPush = PFPush()
    push.setQuery(query)
    push.setData(data)
    push.sendPushInBackground()
}

      

Does anyone have any ideas?

+1


source to share


1 answer


The problem is on the line:

query.whereKey("currentUser", equalTo: userQuery)

      

It should be:



query.whereKey("currentUser", matchesQuery: userQuery)

      

Hope this solves the problem.

+5


source







All Articles