Trigger Push Notifications

Notification Types

Add Message and Notify

Background

After a user adds a pass you may want to send them a message related to the pass and ensure they are notified about it. Using the Add Message API request with a message_type equal to TEXT_AND_NOTIFY the following occurs:

  1. A "Message" item is added to the "back of pass" (aka Details Template) and a push notification is sent to users with the pass saved.
  2. Once the user taps the notification it opens Google Wallet to the front of the pass (a.k.a. Card view) and the user will see a callout at the top of the screen with a "View Message" button.
  3. Clicking the callout will take users to the back of the pass, where new unread messages are highlighted.

Some considerations when sending messages with notifications to users

  • Users must have notifications enabled for their passes to receive the push notifications related to messages.
  • Messages may contain URIs to your website or app. Hyperlinks must be a website or app related to the pass. It is a violation of the Acceptable Use Policy to send users to links not related to the pass.
  • You may send a maximum of 3 messages that trigger a push notification in a 24 hour period. Google may throttle your push notification delivery quota if it deems you are spamming your users.
  • The push notification users see on their lock screen is controlled by Google Wallet.
  • You can use the UPDATE or PATCH methods to edit or remove message data using the regular class or object endpoint.

Integration Steps

When you want to notify users about a new issuer message added using the AddMessage API, you will need to update the AddMessageRequest so that the Message which contains your new text has the MessageType TEXT_AND_NOTIFY instead of TEXT.

Example JSON Request to add message and notify in a Passes Class

  …
  "id": ISSUER_ID.CLASS_ID",
  "message":
    {
        "header":"My Class message header",
        "body": "My Class message body with a <a href="https://wallet.google">Hyperlink<\a>",
        "id": "message_id",
        "message_type": "TEXT_AND_NOTIFY"
    },
  …

Example JSON Request to add message and notify in a Passes Object

  …
  "id": OBJECT_ID",
  "classId": "ISSUER_ID.CLASS_ID",
  "message":
    {
        "header":"My Object message header",
        "body": "My Object message body with a <a href="http://play.google.com/store/apps/details?id=com.google.android.apps.maps">Hyperlink<\a>",
        "id": "message_id",
        "message_type": "TEXT_AND_NOTIFY"
    },
  …

Example Response to add message and notify for a Pass Class

  // The updated resource
  …
    {
      "kind": "walletobjects#walletObjectMessage",
      "header": "My Object message header",
      "body": "My Object message body with a <a href="http://play.google.com/store/apps/details?id=com.google.android.apps.maps">Hyperlink<\a>",
      "id": "message_id",
      "messageType": "textAndNotify"
    },
  …

Exception handling

Any attempts to notify more than 3 times will yield a QuotaExceededException response. Any further updates to the pass can be set using "TEXT" instead of "TEXT_AND_NOTIFY" as discussed in the Integration Steps.