I saw loot of questions about how to send push notifications to passbook, but I didn't find correct answer how should look like request. I have created passbook/wallet coupon, I have received POST request from apple with "pushToken" in payload and device id in URL. My coupon pass.json include next field:
{
"key" : "TestDiscount",
"label" : "Discount",
"value" : "1%",
"changeMessage": "Discount updated to %#."
}
Now I try to update Discount value in coupon, but I don't now how :( After lot of test I did it, but I didn't so when it happend, so now I know that is possible because I did it, but don't how how I did it :) Could you explain me how is should look like push request? Do I need to use device id any where ? So the correct payload is : {"pushToken":"token which I received from apple","TestDiscount":"newValue"} ? And where/when I have to use authenticationToken from my coupon pass.json. I'm really stuck
You need to send an empty payload in the push request.
When the device receives it, it will call your web service, first to get the list of serials for that device that need updating, and then to download a full pkpass bundle containing new data.
If the value for your TestDiscount key is different to the value in the old pass, then the change message will show.
Related
I want to be able to design a storeCard that works as a punch card. Every time someone buys a bread one more punch will need to appear on his pass.
Should looks something similar to the design below.
The image withe the circles is strip#2x.png. What is the best way to update that? I am thinking to change the image with a new one every time I sent push notification and the pass gets an update. But from the documentation I am not sure if I can do that... from the documentation:
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/Updating.html#//apple_ref/doc/uid/TP40012195-CH5-SW1
To send the list of serial numbers, do the following:
Look at the registrations table, and determine which passes the device is registered for.
Look at the passes table, and determine which passes have changed since the given tag. Don’t include serial numbers of passes that the device didn’t register for. If no update tag is provided, return all the passes that the device is registered for. For example, you return all registered passes the very first time a device communicates with your server.
Compare the update tags for each pass that has changed and determine which one is the latest. Return the latest update tag to the device.
Respond with this list of serial numbers and the latest update tag in a JSON payload. For example:
{
"serialNumbers" : ["001", "020", "3019"],
"lastUpdated" : "1351981923"
}
How can I approach this? Do I try to update the whole pass every time when a new push message comes? Is that how the update is done or just some bits of the json file (pass.json) are changed? Is there more clever way to achieve this?
I was trying to alert a custom group using incoming webhook in slack.I can able to alert user using <#user>, but with group any of the following format is not working
<!cgroup>
<#cgroup>
What i am missing here. Thanks in advance.
I got this working by adding a link_names attribute to my JSON payload. For example, POSTing this to my Slack hook URL:
{
"text": "#myusergroup Hello",
"link_names": 1
}
Caused users in #myusergroup to be notified by the message.
From Slack documentation.
For paid account there is an additional command for User Groups that
follows the format <!subteam^ID|handle>. (subteam is literal text. ID
and handle are replaced with the details of the group.) These indicate
a User Group message, and should cause a notification to be displayed
by the client. User Group IDs can be determined from the
usergroups.list API endpoint. For example, if you have a User Group
named happy-peeps with ID of S012345, then you would use the command
<!subteam^S012345|happy-peeps> to mention that user group in a
message.
It is working great
I currently creating an app where the users can add a posting without logging into the app or using any credentials.
Other users of the app can open the app and directly comment on the posts(the comments are an array of the post object).
I read the parse docs and I believe that this will use advance targeting. I saw PFInstallation.currentInstallation() for advanced targeting but I believe that is based on the users class and I am not using the Parse.com users class
What I would like to do is to send a push notification to the original poster when a comment is added to their post... So, I was wondering how I would go completing that?
Thanks!
It couldn't be easier,
Installation has a "user" column. Just make a query that matches the "user" of interest. So, your code will look something like this....
if ( .. comment made, need to send a push .. )
{
console.log(">>> 'comment' was added....");
var query = new Parse.Query(Parse.Installation);
query.equalTo('user', .. whoWroteThePost .. );
alert = "Wow! You have a new comment on a post you wrote!!!";
Parse.Push.send(
{
where:query,
data:{ alert: alert, badge: "Increment" }
});
return;
}
Note that you said ...
"What I would like to do is to send a push notification to the original poster when a comment is added to their post... "
In that sentence you speak of the "original poster". So, that's going to be a variable like originalPoster. So this line of code
query.equalTo('user', .. whoWroteThePost .. );
will be
query.equalTo('user', originalPoster );
Note that this is extremely common, and you can find endless examples on the web! Here's just one: example
Note that:
Parse's term "advanced targeting" is very confusing.
To phrase the same thought another way,
Parse's 'channels' are just silly, ignore them.
That is to say, simply ignore the "channels" nonsense, and just search on users. It's easier and less confusing than the channels business, which is just an extra field you have to fill-out al the time.
It's just one of those weird things about Parse.
I've never used the "non-advanced targeting" - it's stupid and pointless. And the "advanced" targeting is trivial to use: assuming you can write cloud code at all you can do "advanced" targeting. If you can write a query in cloud code, you can do "advanced" targeting.
Essentially,
query.equalTo('user', .. whoWroteThePost .. );
Note that, of course, you may have to first look up who wrote the post, and then from there you can make the query for the Push.
Note, in this process it makes:
no difference at all if the user is anonymous.
You can and should go ahead and send pushes, in the same way.
Advanced targeting is not done against users. It's just that is the easiest way to show an example.
You need to store the installation against the objects you want to push to. So in this case store the installation against the post. Then when the comment comes in you can send a notification to the installation connected to the post it relates to.
I think you are looking something called anonymous users. There is almost impossible to send notification without user's data. But, Parse.com provides something called anonymous users so that app users are not necessary to sign up in order to fully function something user related operations.
Then, you will need to store some information in order to find the target.
Parse.com Anonymous Users
I can send a regular push just fine but cannot figure out to send a "rich" push. I've read Apples "Local and Push Notification Programming Guide" 5 times and it makes no mention of sending anything other than an alert, badge and sound. I cannot find any documentation for rich push in the developer center.
I must be looking for the wrong thing, maybe someone else has been down this road already?
You won't send a whole HTML content directly in your notification, but you can send "rich push" in the sense that you can send additional data in your Push Notifications, and not just alert, badge and sound: you can send any other key you want/need. (just put them outside of the aps entry of your JSON, like at the root of the JSON object).
Only limitation is that you are limited to 255 characters, so that's not designed to provide sthg like a large HTML file for example. Just to provide some additional keys of your choice, like for example an URL, some fields to describe internal ids of objects you want to display, etc.
Everything is described here in the Local and Push Notifications Programming Guide: look at the paragraph called "Examples of JSON Payloads", where they add dummy parameters like "acme1" and "acme2".
So applied to your case your could have a payload like that for your Push notification:
{
"aps" : { "alert" : "Message received from Bob" },
"rich-text-url" : "http://yourserver/message/1234"
"id-of-object-to-show" : 456
}
The only thing to keep in mind is the 255 characters limit.
(Note: obviously the descriptive keys in my example above are only for explanation but one generally choose shorter key names like url and id instead to shorten the overall payload)
The way I have understood idempotency thus far is basically: If I send 10 identical PUTs to a server the resulting additional resources created will be identical to if I had sent a single PUT statement.
What I take this to mean is that the following implementation would adhere to this:
[AcceptVerbs(HttpVerbs.Put)]
ContentResult User(){
//parse XML that was sent to get User info
//User has an e-mail address which is unique to the system
//create a new user in the system only if one for this e-mail address does not exist
return Content(something, "text/xml");
}
There now if I sent 10 PUTs with XML for User data and they all contain the same e-mail address, only one user will be created.
However, what if they send 10 requests (for whatever reason) and they are all different, but the e-mail is the same. If the first request doesn't make it through then the data of the 2nd request will be used to create the user, and the following 8 requests will be ignored. Is there a flaw here? Or should I literally only ignore requests that are explicitly identical in every way and instead send back an error saying the user already exists if they use the same e-mail address?
Also, what kind of response should be sent from a such PUT statement? Info about the user? Maybe an ID to manipulate them with other API calls? Or perhaps it should just say "success" or "fail: [error details]"?
Your question doesn't reveal the URL where the PUT request is sent to. This is actually very important as it is not the email address within the XML data that dictates whether a new resource is created or an old one updated but the URL that you are sending the request to.
So, if you send PUT to /users/jonh.doe#foo.com/ it either creates the user john.doe#foo.com or updates it if it was already in the system.
Similaraly, if you send PUT to /users/123/ (using id instead of email) it will create or update user 123. However, in this case if the email has to be unique and somebody sends PUT /users/456/ and within that XML is the same email as what the user 123 already has, you have to respond with 409 Conflict.
If the user already exists with the same email address, then the 2nd and subsequent PUT operations should update the data for that resource. The success or failure should be communicated in the status code. If the update succeeds, respond with "200 OK", or "204 No Content"; you can return some information, but don't expect caches to store it as if it were the new representation you would obtain from a GET. If you do not intend for that resource to ever accept a PUT operation other than the first one, then respond instead with "405 Method Not Allowed", with an explanation in the response body. Use "409 Conflict" (again, with an explanation in the response body) if the submitted representation might replace the resource, but can't because it's particular fields cannot be reconciled with the existing state.