Properties are key/value pairs you can use to describe a user.
Built-in properties
WonderPush SDKs automatically collects some properties from user devices.
Custom properties
You can attach your own properties to a user. Common examples of properties are:
- the age of the user,
- the user's full name,
- a customer's all-time revenue.
Properties can be tested in segment criteria, and they can also be used to Personalize push notifications (like calling the user by his/her name in a notification).
There are many ways to add custom properties:
- Client-side, using one of our SDKs
- Server-side, by calling the REST API
- In response to a user click on a notification
Property names
Property names are subject to the following rules:
- they are prefixed according to their value type. For example, string properties have names that start with
string_
. See available prefixes below. - they must only contains letters, numbers and the underscore
_
character.
Available prefixes are:
Prefix | Usage |
---|---|
| An integer value between -128 and 127, inclusive. |
| An integer value between -32,768 and 32,767, inclusive |
| An integer value between -231 and 231-1, inclusive. |
| An integer value between -263 and 263-1, inclusive. |
| An single precision floating point number. |
| An double precision floating point number. |
| A boolean value, either |
| A string value. Values above 128 characters will be ignored. |
| A UTC timestamp in milliseconds, a Here are valid examples: |
| A geographic localisation given as latitude and longitude, or geohash. Value as an object: |
Setting properties on the client side
All our SDKs allow you to set properties. The method/function is called putProperties
. Here's a simple example where we set the user's name and age:
JSONObject properties = new JSONObject();
properties.put("string_name", "John Doe");
properties.put("int_age", 32);
WonderPush.putProperties(properties);
WonderPush.putProperties([
"string_name": "John Doe",
"int_age": 32
]);
[WonderPush putProperties:@{
@"string_name": @"John Doe",
@"int_age": @32
}];
window.WonderPush = window.WonderPush || [];
WonderPush.push(function () {
WonderPush.putProperties({
"string_name": "John Doe",
"int_age": 32
});
});
WonderPush.putProperties({
"string_name": "John Doe",
"int_age": 32
});
You can also use the convenient addProperty()
, removeProperty()
, setProperty()
, unsetProperty()
to write properties. Check them out for the Android SDK, iOS SDK and Website SDK.
Setting properties on the server side
This is easily achieved using the PATCH /installation/{installationId} call of our REST API.
In the following example we set the user's full name and age. Adapt YOUR_ACCESS_TOKEN and YOUR_INSTALLATION_ID.
curl --request PATCH \
--url 'https://management-api.wonderpush.com/v1/applications/_/installations/YOUR_INSTALLATION_ID?accessToken=YOUR_ACCESS_TOKEN' \
--header 'content-type: application/json' \
--data '{"body":{"custom":{ \
"string_name":"John Doe", \
"int_age":32}}}'
Setting properties in response to a user click on a notification
Just head over to the Compose tab of the Create/edit notification page and choose Add action and Update installation for the notification itself or for any button.
Updated about a year ago
What's Next
Geo-targeting |