Dışarıya aktar (0) Yazdır
Tümünü Genişlet
EN
Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.

mpns object

Updated: June 6, 2013

Exposes the functionality of the Microsoft Push Notification Service (MPNS) in Microsoft Azure Mobile Services server scripts.

This object contains the following members:

Sends a flip Tile notification to a channel.

noteNote
The sendFlipTile method is only supported for sending notifications to Windows Phone 7.8 and later versions.

sendFlipTile(channel, payload, options)

 

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:

  • backgroundImage - the URI of the background image for the tile.

  • count - the number that appears on the tile.

  • title - the title text of the tile.

  • backBackgroundImage – the URI of the image that is shown on the backside of the tile.

  • backTitle – title for the backside side of the tile.

  • backContent –text for the backside of the tile.

  • id – ID of a related, secondary tile.

  • smallBackgroundImage – the URI for the background image for the tile when it is reduced to its small size.

  • wideBackgroundImage - the URI for the background image for the tile when it is expanded to its wide size.

  • wideBackContent - content for the back tile when the tile is expanded to its wide size.

  • wideBackBackgroundImage – the URI for the image to be on the backside of the tile when the tile is expanded to its wide size.

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.

Undefined.

Sends a tile notification to a channel.

sendTile(channel, payload, options)

 

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:

  • backgroundImage - the URI of the background image for the tile.

  • count - the number that appears on the tile.

  • title - the title text of the tile.

  • backBackgroundImage – the URI of the image that is shown on the backside of the tile.

  • backTitle – title for the backside side of the tile.

  • backContent – text for the backside of the tile.

  • id – ID of a related, secondary tile.

    Only supported for sending notifications to Windows Phone 7.5 and later versions.

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.

Undefined.

Sends a toast notification to a channel.

sendToast(channel, payload, options)

 

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 param field is only supported for sending notifications to Windows Phone 7.5 and later versions.

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' 
}

Undefined.

Sends a raw push notification string to a channel.

sendRaw(channel, payload, options)

 

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.

noteNote
Instead of supplying an object to the payload parameter, you can instead just supply the raw notification string in place of payload.

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' 
}

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);
                    }
                });
            });
        }
    });
}


}

Show:
© 2014 Microsoft