Send Push To Target Users

0 votes

Hello, 

I want to use sendPushToTargetUsers.

I read the example, but I don't understand wich fields I must put in the collection.
I put the fields that I need to make the query, but you don't explain this:

1) how the backend take the username to send push notifications

2) if I have 500 users as result of the query, it will send the notification to all 500 users ?

3) how I check if all message are sent ?

Best regards

asked Feb 26, 2015 in App42 Cloud API-BaaS by odf (37 points)

1 Answer

0 votes

Hello Odf,

If you have saved some user profile info in storage and you want to send segmented push based on profile parameter, you have to give the query while calling sendTargetPush User. When you are saving user profile in storage, you have to set username using App42API.setLoggedIn method. Internally sendTargetPush will fetch the docs and gets the username from it and send the message to those users. To know more in details, please have a look at "User Segmentation (Applying Filter)" in thistutorial and let me know if it helps. 

About your second & third query, yes it will send push notification to all your 500 users and you can check the push logs for the same under push notification section. 

Please check & let me know if it helps.

Himanshu Sharma

answered Feb 27, 2015 by hs00105 (2,005 points)
Hello,
I create a new collection with 3 fields: username, regcode, regname

When I call it with this javascript :
    key1 = "regcode";
    value1 = "99";
    var queryBuilder = new QueryBuilder();
    var q1 = queryBuilder.build(key1, value1, Operator.EQUALS);
    app.pushNotificationService.sendPushToTargetUsers(msg, window.APP42_DBNAME, window.APP42_USER_REGIONE_COLLECTION, q1, {
        success: function (object)
        {
            var pushNotification = JSON.parse(object);
            result = pushNotification.app42.response.push;
            console.log("Message is " + result.message);
            console.log("Expiry is " + result.expiry);
        },
        error: function (error) {
        }
    });

I get a 404 error in the Chrome Console with this link:
message:{"app42Fault":{"httpErrorCode":404,"appErrorCode":1711,"message":"Not Found","details":"No target user found for given query"}}

But if I make a the query I get 1 result.

What I do wrong ?

Best regards
Ok Thanks I understand now, I must set loggedinuser when I save with username when I save the document in collection.
Thanks but is not very clear in your documentation.
Best regards
Great to hear that your query has been resolved. Do let us know if you need further information regarding this. Also, thanks for your valuable feedback, will update this in the documentation with important note.

Thanks,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...