Show TOC

Notification Data Sent Using Push APILocate this document in the navigation structure

The HTTP Push API restnotification provides a mechanism to send push notification to an application that is registered with SAP Mobile Platform Server.

The restnotification API sends native push notifications to applications. This RESTful service provides more flexibility for sending push messages than existing interfaces that are based on HTTP headers or URL parameters. Earlier push interfaces required that you send messages to a registration ID. The restnotification interface also sends the message to a specific user or to all users of a specific application.

The restnotification API allows to send message to multiple recipients. The messages are queued in SAP Mobile Platform Server and sent out asynchronously.

Use HTTP POST method in the notification URL:
On-Premise
http[s]://<host:port>/restnotification/<resource>
Cloud
https://<HMC base URL>/restnotification/<resource>
Application
To send push notification to devices that are registered to an application, use:
On-Premise
http[s]://<host:port>/restnotification/application/<applicationId>
Cloud
https://<HMC base URL>/restnotification/application/<applicationId>
Request example body:
> POST /restnotification/application/123456789 HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 127
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
< HTTP/1.1 201 Created
< Content-Length: 0
< Date: Mon, 05 May 2014 00:29:38 GMT
< Server: SAP
Users and Devices
To send push notification to all the devices registered to a particular user, use:
On-Premise
http[s]://<host:port>/restnotification/application/<applicationId>/user/<userID>
Cloud
https://<HMC base URL>/restnotification/application/<applicationId>/user/<userID>
Request example body:
> POST /restnotification/application/123456789/user/timmitester HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 127
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=C05E58BE3CFC685ABB945D53C2AF14FD; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=4CC5BC2943E5D3A9B5D924888FC28CB060034F0092911A66B9F079047077798C; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:32:35 GMT
< Server: SAP
Registration ID
To send push notification to a device by using an application registration ID, use:
On-Premise
http[s]://<host:port>/restnotification/registration/<applicationRegistrationId>
Cloud
https://<HMC base URL>/restnotification/registration/<applicationRegistrationId>
Request example body:
> POST /restnotification/registration/9f847e51-3242-4899-9193-39b6e840d657 HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 127
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=D541E4898186AB304F506D13C0C3F1D0; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=FDB39F9BAE8A6E1AD4373765A58E094A14B8FDFB8289CC70E51B77A284C50736; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:36:15 GMT
< Server: SAP
Users per application
To send push notification to all the users of an application, use:
On-Premise
http[s]://<host:port>/restnotification/application/<applicationId>/user
Cloud
https://<HMC base URL>/restnotification/application/<applicationId>/user
Request body example:
POST /restnotification/application/123456789/user HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 277
> {
    "notification": {
        "alert": "alertval",
        "badge": 1,
        "data": "testData",
        "sound": "soundval"
    },
    "users": [
        "timmitester",
        "user1",
        "user2"
    ]
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=9AD06173C8AB9FC05FD6AA8DC55BB9AE; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=DFB2D2AC4EBAA4903553EB7C5A0C90870BD4B8F3A3DC19A5FD984673EB1BD646; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:38:32 GMT
< Server: SAP
Registration list
To send push notifications to a list of registrations, use:
On-Premise
http[s]://<host:port>/restnotification/registration
Cloud
https://<HMC base URL>/restnotification/registration
Request body example:
POST /restnotification/registration HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 466
> {
    "notification": {
        "alert": "alertval",
        "badge": 1,
        "data": "testData",
        "sound": "soundval"
    },
    "registrations": [
        "3078e166-f144-4288-9dbc-1d192afe18d8",
        "9f847e51-3242-4899-9193-39b6e840d657",
        "4d1ccdf9-058a-42cf-a625-c4ed48944729",
        "f05dc905-b859-45fa-afdc-da3b630d2b48",
        "282be579-783e-40fb-b376-25bed5e13606"
    ]
}
< HTTP/1.1 201 Created
< Set-Cookie: X-SMP-SESSIDSSO=BCA5FCB41DD7F451410E3E8BB59E8F7A; Path=/; HttpOnly
< Set-Cookie: X-SMP-SESSID=2AC74022B258178ED3A88E4B2FA10AB41093F53C3D0A77976FE6FE076F1E3CC2; Path=/; HttpOnly
< Content-Length: 0
< Date: Mon, 05 May 2014 00:41:52 GMT
< Server: SAP
Customize Push Notification Types
Use customParameters to override the value for a particular notification type. Customize push notification types-alert, badge, data, and sound in the payload by prefixing with:
  • apns
  • bbbis
  • bbbes
  • gcm
  • mpns
  • wns
Example: Push all users to the application 'XYZ'. Issue a POST method on:
> POST /restnotification/application/XYZ HTTP/1.1
> Authorization: Basic cHVzaDpzZWNyZXQ=
> User-Agent: curl/7.36.0
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json;charset=utf-8
> {
 "alert": "alertval",
 "badge": 1,
 "data": "testData",
 "sound": "soundval"
}
Assume that some users have Android devices and the notification type parameter value must be reset. Use customParameters to override the value of the sound parameter:
> {
 "alert": "alertval",
 "badge": 1,
 "customParameters": {
   "gcm.sound": "soundforgcm"
 },
 "data": "testData",
 "sound": "soundval"
}