Skip to content

Push notification payload

Peter Vojtek edited this page Oct 13, 2016 · 24 revisions

Current inner push notification payload:

  • title - usually username, e.g. John Doe
  • message - message description text (e.g. posted Learn to fly
  • image - notification image URL
  • count - badge count
  • P.V. not sure if we need it here at all
  • additionalData
  • additionalData
    • badgeCount -- the same as count above
  • type -- type of push notification, e.g. boosted_post
  • actions -- action buttons, only on Android
    • example: [{"callback":"app.upvote","icon":"Upvote","title":"Upvote"}]
  • entity
    • target
      • id -- e.g. post ID
      • type -- e.g. post
      • other attributes, e.g. commentID

example:

{"message":"posted: try boost 2","image":"http://powerline-dev.imgix.net/avatars/577cb68e6f276.jpeg?dpr=0.75&h=400&ixlib=php-1.1.0&w=320","title":"Peter10 Is Leader","count":"13","additionalData":{"collapse_key":"do_not_collapse","type":"follow-post-created","additionalData":{"badgeCount":13},"foreground":true,"actions":[{"callback":"app.upvote","icon":"Upvote","title":"Upvote"}],"coldstart":false,"entity":{"target":{"id":350,"body":"try boost 2","image":"577cb68e6f276.jpeg","type":"post","full_name":"Peter10 Is Leader"},"id":2293}}} 

The structure above has following drawbacks:

  • there is type twice, but they have different meaning, one is push notification type and other is entity type..they can be easily mistreated in code
  • badge count is there twice
  • I do not understand why there is additionalData twice : additionalData.additionalData.badgeCount
  • one has to dive deep the reach entity details (i.e. target.entity), which leads to such complicated if conditions
  • push notification type is confusing, sometimes it uses dashes, other times underscores, sometimes there is verb, other times not.

Here is current business logic of processing the push notification data.

Here is example how the notification should look like:

  • title - usually username, e.g. John Doe
  • message - message description text (e.g. posted Learn to fly
  • image - notification image URL
  • additionalData
  • badgeCount - badge count
  • notificationID - notification unique ID
  • notificationType -- type of push notification, e.g. post-boosted
    • use unified format: <entityType>-<verb>, e.g. post-created. use dashes, no underscores.
    • is is own, user prefix own-<entityType>-<verb>
  • actions -- action buttons, only on Android
    • example: [{"callback":"app.upvote","icon":"Upvote","title":"Upvote"}]
  • entity
    • id -- e.g. post ID
    • type -- entity type, e.g. post
    • other attributes, e.g. commentID

Entity types:

  • post
  • user-petition
  • group
  • group-news
  • group-petition
  • group-event
  • group-payment
  • group-payment-crowdfunding
  • group-question
  • announcement
  • user

Push notification type verbs

  • created
  • commented
  • voted
  • signed
  • invited
  • changed