Import push tokens
Use the REST API to import push tokens
Importing push tokens into WonderPush is done by creating an installation object for each push token. To create an installation you will need to:
- generate an installation ID composed of numeric characters (0-9) or alphabetic characters between
a
andf
, - make an update installation API call.
Generating an installation ID
An hexadecimal hash of the push token is a good installation ID. You can achieve this on the Linux command line like so:
echo -n 'YOUR_PUSH_TOKEN' | shasum | cut -c 1-40
Creating an installation via the API
Once you've generated an installation ID for a given push token, make a update installation API call to create the installation object with the push token.
Here's an example, you'll have to adapt YOUR_INSTALLATION_ID
, YOUR_ACCESS_TOKEN
and YOUR_PUSH_TOKEN
:
curl -XPUT https://management-api.wonderpush.com/v1/installations/YOUR_INSTALLATION_ID \
-d accessToken="YOUR_ACCESS_TOKEN" \
-d userId= \
-d body='{"pushToken": {"data": "YOUR_PUSH_TOKEN"}}'
Please note that the presence of the userId
parameter is mandatory, even with an empty value. You can of course fill it with an appropriate value if you wish.
If you have more data relative to the push token that you want to put inside the Installation object for segmentation, you can use the custom
key to save properties as part of this same call (adapt YOUR_PROPERTY
and YOUR_PROPERTY_VALUE
):
curl -XPUT https://management-api.wonderpush.com/v1/installations/YOUR_INSTALLATION_ID \
-d accessToken="YOUR_ACCESS_TOKEN" \
-d userId= \
-d body='{"pushToken": {"data": "YOUR_PUSH_TOKEN"}, "custom": {"YOUR_PROPERTY": "YOUR_PROPERTY_VALUE"}}'
Updated over 2 years ago