Remote Notification

Endpoint for Social API

Note: Social API includes Appdata API, Blacklist API, People API, Profanity API, Leaderboard API, Remote Notification API.

Mobage Simplified Chinese Platform

Mobage Traditional Chinese Platform

Data Type Definition

RemoteNofication

NameTypeRequired/OptionalDescription
recipientIdUserIdRequiredUser identifier for the notification recipient. This identifier can be a gamertag or a user ID.
payloadObjectRequiredAdditional parameters passed to the device.
payload.messageStringRequiredA UTF-8 formatted string that forms the body of the message.
payload.badgeIntegerOptionalThis number determines the badge used for notifications sent to iOS devices. If no badge is included, no numeric badge is sent. This field has no effect for Android target devices and does not count toward payload size constraints.
payload.soundStringOptionalThe name of the sound in the application bundle to play for notifications on iOS devices. Plays the default sound when the specified sound file is not found or when the value is default. This field has no effect for Android target devices and does not count toward payload size constraints.
payload.collapseKeyStringOptionalThe collapse key to combine multiple messages on an Android device into a single group, displaying the most recent notification only. When no key is specified, all notifications use the same collapseKey. This field has no effect for iOS target devices and does not count toward payload size constraints.
payload.styleStringOptionalA hint that contains the preferred layout style for the system notification tray on Android devices. If no style is given or the provided style is not available, the default Mobage style will be used.  Valid styles are normal and largeIcon. This field has no effect for iOS target devices and does not count toward payload size constraints.
payload.iconUrlStringOptionalThe icon URL that determines the image shown in the notification bar for Android devices for notification payloads that include a style attribute. If this field is not specified, the default Mobage icon image is shown. This field has no effect for iOS target devices and does not count toward payload size constraints.
payload.extrasObjectOptionalCustom 1 level hash of key/value parameters defined by the developer. The string key for each item in this section cannot contain any of the payload's defined key values.

Description

Sends a remote notification, also called a push message, to a user's device.  This API can send a message to a single user or a broadcast message to all users of a given app.

On the Android platform, remote notifications are delivered through the Android Google Cloud Messaging (GCM) infrastructure. On the iOS platform, remote notifications are delivered through Apple's Push Notification Service (APNS). When your app is ready to publish, and you submit it for review, the Mobage platform team automatically enables remote notifications for your app.

Examples of legitimate notifications using the Mobage Push Notifications API include:

  • Inviting a user to the current app.
  • Sending notifications announcing asynchronous app events.
  • Announcing a user-initiated app invitation or challenge.
  • Notifications promoting app features that a user has not yet explicitly engaged.

Examples of notifications that are not compliant with Mobage platform policies include:

  • Notifications promoting other apps.
  • Notifications generated on behalf of a user that are not explicitly approved by the user.

The Mobage platform team monitors the remote notifications sent from your app to make sure that in-app events written to the Mobage Remote Notification API comply with Mobage platform policies.

URI Fragment

/remote_notification/{appId}/@all/{recipientId}

/remote_notification/{appId}/@all 

Supported Formats

JSON

HTTP Method

POST

Request Parameters

 

NameTypeRequired/OptionalParameter TypeDescription

recipientId

UserIdRequiredURI Template VariableThe recipient's userId
appIdAppIdRequiredURI Template Variable

@app or direct value

Request Headers

Any request to the Mobage REST APIs must include the Authorization header. For more details, see How to add the Authorization Header 

Request Body

NameTypeRequired/OptionalDescription
senderIdUserIdRequiredThe sender's userId
payloadRemoteNotificationRequiredThe POST data payload for this remote notification

Response Body

RemoteNotification

Response Status Code

HTTP Status CodesHTTP Status MessageMeaning
200OKData successfully acquired
400Bad RequestCorrupt request data on the client side
401UnauthorizedAuthorization error
403ForbiddenThe resource exists, but access is not possible due to a reason other than an authorization error.
429Too Many RequestsThe number of leaderboard requests exceeds the throttling limit.
500Internal Server ErrorAn error on the API server side
503Service UnavailableThe API cannot be used temporarily

Notes

    1. The delivery of remote notifications is not guaranteed.
    2. The API limits broadcast messages to 1 broadcast every 1 hours. Messages from one user to another are not throttled.
    3. Only a game server can send a broadcast remote notification to all users (@all). You must use game-server specific consumer secret tokens and keys to authenticate this request. Client OAuth sessions are not valid for the purpose of sending @all remote notifications.

 

Example 1. Sending a Remote Notification to a Single User

HTTPS Request
HTTPS Response

 

Example 2. Sending a Broadcast Notification to All Users

HTTPS Request
HTTPS Response

 

Example 3. Sending a Broadcast Notification to Multiple Users (Max:1000 users one time)

HTTPS Request
HTTPS Response

 

How to Add the Authorization Header

Step 1. Create the base string

1. build a string for OAuth parameters:  firstly sort the following parameters alphabetically and URL encode the names and values, then join name and value with "=", finally join name/value pairs with "&" 

ParameterDescriptionValue
oauth_consumer_keyThe Consumer Key for the applicationIssued when resist the application
oauth_nonceUnique value for each requestGenerated on the game server
oauth_signature_methodHash methodOnly HMAC-SHA1 is specifiable
oauth_timestampUNIX timestampGenerated on the game server
oauth_tokenThe token code

oauth_token is obtained from the token credential.

oauth_versionOAuth versionOnly 1.0

2. URL encode the following three parameters.

ParameterDescription
Request MethodHTTP Method to the API Server
API URLURL to the API Server (exclude query parameters)
OAuth ParametersA string Built in previous step

3. join the encoded parameters with "&".

Step 2. Generate the oauth_signature

1. Build a secret by joining the Consumer Secret and  the Token Secret (obtained from the token credential) with "&".

2. Pass the base string and secret to the HMAC-SHA1 hashing algorithm.

3. the output of HMAC-SHA1 hashing algorithm is a binary string. Use base64 encode to produce the signature string.

A tool is provided to verify whether your signature is correct. Refer to Oauth Signature Tool

Step 3. Build the Authorization Header

Follow the steps to build the “Authorization” header:

1. URL encode the parameter names and values in the table below 

2. Double quote the value, join name and value with "=", join name/value pairs with "," 

3. Add realm parameter as an option

4. Add "OAuth " (including the space at the end) to the beginning of the header.

ParameterValue
oauth_consumer_keyIssued when resist the application
oauth_nonceGenerated on the game server
oauth_signatureGenerated on the game server, Refer to Step 2. Generate the oauth_signature
oauth_signature_methodonly "HMAC-SHA1" is specifiable
oauth_timestampGenerated on the game server
oauth_token

oauth_token is obtained from the token credential.

oauth_versionOnly 1.0
Authorization Header Example

 

 

 

PREVIOUS

Profanity

NEXT

Leaderboard