mpns object
The feature described in this topic is available only in preview. To use this feature and other new Windows Azure capabilities, sign up for the free preview.
Exposes the functionality of the Microsoft Push Notification Service (MPNS) in Windows Azure Mobile Services server scripts.
This object contains the following members:
sendFlipTile
Sends a flip Tile notification to a channel.
Note |
|---|
| The sendFlipTile method is only supported for sending notifications to Windows Phone 7.8 and later versions. |
Syntax
sendFlipTile(channel, payload, options)
Parameters
| Parameter | Description |
|---|---|
|
channel |
Required channel URI value or array of URI values that indicates the channels to receive the notification. |
|
payload |
Required JSON object that contains the notification information, which includes the following fields:
For more information about the flip Tile template, see Flip Tile template for Windows Phone 8. |
|
options |
Callback that is used to capture the results of the notification:
{
success: success,
error: error
}
Where success is the function that is called after the notification is sent and error is the function that is called when an error occurs. When the push operation succeeds, the success function is passed a JSON object that is populated with the following information:
{
statusCode: http_status_code,
deviceConnectionStatus: 'connection_status',
notificationStatus: 'notification_status',
subscriptionStatus: 'subscription_status',
title: 'title_field',
pushType: 'flipTile',
tileTemplate: 'tile_template'
}
This object also contains fields for all of the push notification options supplied to MPNS. |
Returns
Undefined.
sendTile
Sends a tile notification to a channel.
Syntax
sendTile(channel, payload, options)
Parameters
| Parameter | Description |
|---|---|
|
channel |
Required channel URI value or array of URI values that indicates the channels to receive the notification. |
|
payload |
Required JSON object that contains the notification information, which includes the following fields:
For more information about this Tile template, see Windows Phone OS 7.1 Tile template. |
|
options |
Callback that is used to capture the results of the notification:
{
success: success,
error: error
}
Where success is the function that is called after the notification is sent and error is the function that is called when an error occurs. When the push operation succeeds, the success function is passed a JSON object that is populated with the following information:
{
statusCode: http_status_code,
deviceConnectionStatus: 'connection_status',
notificationStatus: 'notification_status',
subscriptionStatus: 'subscription_status',
title: 'title_field',
pushType: 'tile',
tileTemplate: 'tile_template'
}
This object also contains fields for all of the push notification options supplied to MPNS. |
Returns
Undefined.
sendToast
Sends a toast notification to a channel.
Syntax
sendToast(channel, payload, options)
Parameters
| Parameter | Description |
|---|---|
|
channel |
Required channel URI value or array of URI values that indicates the channels to receive the notification. |
|
payload |
Required object that contains the notification information, which looks like the following:
{
text1: 'Bold text:',
text2: 'normal text',
param: 'NewPage.xaml?item=5'
}
Where text1 and text2 are the toast text strings and param is an optional URI parameter that specifies an XAML page to open in your app, along with any query string parameters. The For more information about sending a toast notification, see Toasts for Windows Phone62d355e3-2cb6-4b16-97b9-76dec5e8b797. |
|
options |
Optional object that is used to capture the results of the notification:
{
success: success,
error: error
}
Where success is the function that is called after the notification is sent and error is the function that is called when an error occurs. When the push operation succeeds, the success function is passed a JSON object that is populated with the following information:
{
statusCode: http_status_code,
deviceConnectionStatus: 'connection_status',
notificationStatus: 'notification_status',
subscriptionStatus: 'subscription_status',
text1: 'toast_text1',
text2: 'toast_text1',
pushType: 'toast'
}
|
Returns
Undefined.
sendRaw
Sends a raw push notification string to a channel.
Syntax
sendRaw(channel, payload, options)
Parameters
| Parameter | Description | ||
|---|---|---|---|
|
channel |
Required channel URI value or array of URI values that indicates the channels to receive the notification. |
||
|
payload |
An application-specific string that is delivered to the client without modification.
{
payload: 'raw notification string'
}
Where payload is the notification string.
|
||
|
options |
Optional object that is used to capture the results of the notification:
{
success: success,
error: error
}
Where success is the function that is called after the notification is sent and error is the function that is called when an error occurs. When the push operation succeeds, the success function is passed a JSON object that is populated with the following information:
{
statusCode: http_status_code,
deviceConnectionStatus: 'connection_status',
notificationStatus: 'notification_status',
subscriptionStatus: 'subscription_status',
payload: 'payload_string',
pushType: 'raw'
}
|
Returns
Undefined.
Mobile Services doesn’t require you to register your app with MPNS to enable authenticated usage. Because of this, you cannot send more than 500 messages per user each day by using MPNS.
The following script uses the mpns object object to send flip tile notifications to a Windows Phone 8 app.
function insert(item, user, request) { request.execute({ success: function() { request.respond(); sendNotifications(); } }); function sendNotifications() { var channelTable = tables.getTable('Channel'); channelTable.read({ success: function(channels) { channels.forEach(function(channel) { push.mpns.sendFlipTile(channel.uri, { title: item.text }, { success: function(pushResponse) { console.log("Sent push:", pushResponse); } }); }); } }); } }
Reference
apns objectgcm object
mpns object
wns object
Concepts
Mobile Services server script reference
Note