Parse Cloud: Send Push to a single user

后端 未结 3 613
灰色年华
灰色年华 2020-12-30 14:09

I\'m using Parse and I can\'t make this method to work.

The idea is to send push to a single user with an already known user identifier from any platform within \'Cl

3条回答
  •  独厮守ぢ
    2020-12-30 14:48

    This works well for me, but you have to link your users with your installations before:

    var query = new Parse.Query(Parse.User);
    query.equalTo('username', 'Sento');
    // Find devices associated with these users
    var pushQuery = new Parse.Query(Parse.Installation);
    // need to have users linked to installations
    pushQuery.matchesQuery('user', query);
    
    
    Parse.Push.send({
        where: pushQuery,
        data: {
            aps: {
                alert: "Test",
                sound: ""
            }
        }
    }, {
        success: function () {
            response.success("Hello world!");
        },
        error: function (error) {
            response.error(error);
        }
    });
    

提交回复
热议问题