Created
February 25, 2016 17:34
-
-
Save flovilmart/bf64276507d685ae41f6 to your computer and use it in GitHub Desktop.
_PushStatus specification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PushStatus contains information about a push that was sent by an app. Its | |
// BSON format is stored directly in Mongo. Its JSON format is the REST format | |
// exposed to external developers, e.g. "_id" is mapped to "objectId", | |
// "_created_at" is mapped to "createdAt", etc. | |
type PushStatus struct { | |
// ObjectID is a string matching the standard Parse object id format. | |
ObjectID string `bson:"_id" json:"objectId"` | |
// CreatedAt contains the current modification time for this object. | |
CreatedAt TimeString `bson:"_created_at" json:"createdAt"` | |
// UpdatedAt contains the last modification time for this object. | |
UpdatedAt TimeString `bson:"_updated_at" json:"updatedAt"` | |
// PushTime represents the time the push should be sent. For a local push, | |
// it does not have a time zone (e.g. "2014-04-28T13:50:00"). For an | |
// absolute time push, it has a time zone (e.g. "2014-04-28T20:35:00Z"). | |
PushTime string `bson:"pushTime,omitempty" json:"pushTime,omitempty"` | |
// Source is how a push was triggered (e.g. "webui" or "rest"). | |
Source string `bson:"source" json:"source"` | |
// Query is the JSON query to execute over _Installation for push targeting. | |
// It is stored as a string because sub-document types cannot contain "$". | |
Query PushJSONStringEncodedMap `bson:"query" json:"query"` | |
// Payload is the JSON push payload to deliver to devices. | |
Payload PushJSONStringEncodedMap `bson:"payload" json:"payload"` | |
// Title is the title of the push campaign. | |
Title string `bson:"title,omitempty" json:"title,omitempty"` | |
// Expiry is when the push expires, expressed in seconds since the epoch. | |
Expiry int64 `bson:"expiry,omitempty" json:"expiry,omitempty"` | |
// Status is the state of the push send, e.g. "pending", "running", | |
// "succeeded", or "failed". | |
Status string `bson:"status" json:"status"` | |
// NumSent is the number of devices this push was sent to. | |
NumSent int `bson:"numSent" json:"numSent"` | |
// PushHash is the MD5 of the push payload. | |
PushHash string `bson:"pushHash" json:"pushHash"` | |
// Error is the error message associated with a failed push send. | |
Error string `bson:"errorMessage,omitempty" json:"errorMessage,omitempty"` | |
// ExpansionDuration is the time in seconds spent executing the expansion | |
// phase of the push. | |
// WE CAN OMIT THAT | |
ExpansionDuration float64 `bson:"expansionDuration,omitempty" json:"expansionDuration,omitempty"` | |
// SentPerUTCOffset is the number of pushes sent to each UTC offset, where | |
// the UTC offset is a string representing the number of seconds offset from | |
// UTC (e.g. "-43200"). | |
// Not sure that is useful for the initial implementation | |
SentPerUTCOffset map[string]int `bson:"sentPerUtcOffset,omitempty" json:"sentPerUtcOffset,omitempty"` | |
// SentPerType is the number of pushes sent to each type of push network. | |
SentPerType map[string]int `bson:"sentPerType,omitempty" json:"sentPerType,omitempty"` | |
// Experiment contains information about the experiment this push belongs to. | |
// Not required for now | |
Experiment *PushStatusExperiment `bson:"experiment,omitempty" json:"experiment,omitempty"` | |
// PushAudienceId is the ID of the saved push audience this push was sent to. | |
// If if was not sent to a saved push audience, this field is blank. | |
// OMIT for now, We don't have the audience | |
PushAudienceID string `bson:"pushAudienceId,omitempty" json:"pushAudienceId,omitempty"` | |
// ID to group translated push messages. | |
// Not sure we support that yet | |
TranslationID string `bson:"translation_id,omitempty" json:"translation_id,omitempty"` | |
// Corresponding locale for this push. | |
// Not sure we support that yet | |
TranslationLocale string `bson:"translation_locale,omitempty" json:"translation_locale,omitempty"` | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PushStatusExperiment contains information about the experiment this push | |
// belongs experiment to. | |
type PushStatusExperiment struct { | |
// ID is the object ID of the related PushExperiment. | |
ID string `bson:"experiment_id" json:"experiment_id"` | |
// First is the first bucket of the experiment (inclusive). | |
First int `bson:"first" json:"first"` | |
// Last is the last bucket of the experiment (exclusive). | |
Last int `bson:"last" json:"last"` | |
// Group is the group name of the experiment. | |
Group string `bson:"group,omitempty" json:"group,omitempty"` | |
// Type is the experiment type ("time" for a time-based test of the same | |
// payload and "message" for a test that varies the push payload). | |
Type string `bson:"type,omitempty" json:"type,omitempty"` | |
// ParentPushStatusID contains the push status ID of the parent push. | |
ParentPushStatusID string `bson:"parent_push_status_id,omitempty" json:"parent_push_status_id,omitempty"` | |
} |
Wouldnt this be a great place to get the device tokens no longer valid from the feedback, thus also adding the ability to disable the push....
something like this
function handleFeedback(feedbackData) {
feedbackData.forEach(function(feedbackItem) {
console.log("Device: " + feedbackItem.device.toString("hex") + " has been unreachable, since: " + feedbackItem.time);
});
}
// Setup a connection to the feedback service using a custom interval (10 seconds)
var feedback = new apn.feedback({ production: false, interval: 10 });
feedback.on("feedback", handleFeedback);
feedback.on("feedbackError", console.error);
Found this on node-apn.. https://github.com/argon/node-apn/search?utf8=%E2%9C%93&q=feedback
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The fields marked as optional should have the proper type in the database to maintain dashboard compatibility but we don,t have to write anything in there if we feel it's not necessary