Products

Push API Guide: Target Conditions for Sending Push Notifications

Check out our entirely new API extensions made to help you significantly improve the dispatch of push notifications regardless of the sending conditions you want to set up.

January 18 2017

Push notifications are simple lightweight notifications sent over Apple Push Notification Service (APNS) or Google Cloud Messaging (GCM) to any mobile application installed on iOS and Android-powered devices.

We've built entirely new API extensions to help you significantly improve the dispatch of push notifications regardless of the sending conditions you want to set up. The functionality has also been integrated with the Infobip Portal. With this, it doesn't matter if you're sending one notification to multiple addresses or multiple notifications to one or multiple devices, you can choose the flow that best suits your messaging.

Introducing target conditions for sending push notifications

When sending one or multiple notifications to one or more devices you'll need to take some parameters into consideration.  

If you're targeting all devices of a single 'externalUserId' for example, a unique identifier of a user in your system. This entails all devices of a single user registered to the same ID.

We provide you with the possibility to target your recipients by predefined conditions. In this case, you need to keep in mind how each recipient is set up in your system.

Don't forget your mobile application setup prerequisites:

User Data for iOS and for Android.

We will give you an example of how it looks like if the target condition is 'externalUserId'.

POST /push/2/message/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
    "from": "d417d38814740a23f50b5c876e226445-0f700564-abbf-4b5b-beae-86a4ef410904",
    "to": {
        "externalUserId": "customer_21234"
    },
    "text": "This message was sent by targeting the exact externalUserId."
}

However, instead of an "externalUserId" you can use any target field as a condition. Target fields can be:

  • "pushRegistrationId"
  • ''cloudType''
  • "externalUserId"
  • ''GSM''
  • ''email''
  • ''custom field''- customized user data, can be tag or subscription

With this type of targeting, you can achieve the following:

  • target all iOS or Android devices
  • target a particular device
  • target all devices of particular external user ID
  • target all devices linked to a GSM
  • target all devices linked to an email
  • target all devices associated with a particular tag, subscription or another type of custom data

Advanced targeting logic examples

Sometimes targeting only by one criterion is not enough, so we introduced conditional logic which you can use for more precise segmentation of your audience when targeting them with push notifications. Here are some examples of the advanced targeting.

Inclusion of destination target conditions (IN)

Combining two or more different parameters of the same destination target condition is done as shown in this example. With the example below you can create a broadcast to all devices on your application.

POST /push/2/message/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
 "from": "d417d38814740a23f50b5c876e226445-0f700564-abbf-4b5b-beae-86a4ef410904",
 "to": {
       "cloudType": ["APNS", "GCM"]
 },
 "text": "This message was sent by broadcast to all devices installed on your application"
}

Multiple destination address types (AND) 

You can use this condition to target recipient segments by using two or more different filters. The notification will be delivered only to those recipients who satisfy all filtered conditions. In other words, if a recipient matches address type 1 AND address type 2, the push notification will be sent. For example, you can target user's devices with particular externalUserId limited to a single cloudType.

POST /push/2/message/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
    "from": "d417d38814740a23f50b5c876e226445-0f700564-abbf-4b5b-beae-86a4ef410904",
    "to": {
        "cloudType": "APNS",
        "externalUserId": "my-ext_id-1"
    },
    "text": "This message was sent by targeting the exact externalUserId and only for iOS"
}

Multiple destination address types (OR)

In some cases, you may want to segment your recipients by including different filters over multiple destination targeted conditions. By using this method, a recipient will receive the notification if he/she satisfies at least one of the two predefined conditions. For example, you want to target all devices linked to externalUserId or any of listed email:

POST /push/2/message/single HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
    "from": "d417d38814740a23f50b5c876e226445-0f700564-abbf-4b5b-beae-86a4ef410904",
    "to": {
        "$or": [
            {"externalUserId": "my-ext_id-1"},
            {"email": ["myEmail_1@domain.com", "myEmail_2@domain.com"]}
        ]
    },
"text": "This message was sent by targeting all devices which linked to the externalUserId or any of the listed emails"
}

But you don't have to use just one target condition. Instead, we've provided you with the possibility of combining all the conditions listed above. If you want to target all recipients with Android devices which have at least one listed tag mentioned, you'll use OR and AND targeting condition. Simple, no?

Optimize your push initiatives today!

Check out our Push documentation