html5+ Specification: Push (Manage push message function) __html

Source: Internet
Author: User
Tags event listener notification center

Push module management pushes message function, can realize online, off-line message push, through Plus.push can get push message management object. 1. Methods 1.1, AddEventListener: Add push message Event listener

void Plus.push.addEventListener (event, Listener, Boolean);

Description: Adds a push message event listener that fires when a specified push event is emitted.

Parameters:

Type: (String) required event types, support event type: "Click"-click the message from the System Message Center to start the application event, receive-Apply the push message event from the push server.

Listener: ( pushreceivecallback ) The required event listener callback function, which is called when a push message is received

Capture: (Boolean) optional whether to capture events, which can be ignored here

return value: void: None

Platform Support: android-2.2+ (Support), ios-4.3+ (support): When the client receives a push message at runtime to trigger the receive event, all offline received push messages enter the system Message Center.

Example:

<! DOCTYPE html>


1.2. Clear: Empty all push messages

void Plus.push.clear ();

Description: Clears all push messages from the system Message Center.

return value: void: No 1.3, CreateMessage: Create local message

void Plus.push.createMessage (content, payload, option);

Description: Creates a push message directly locally and adds it to the System Message Center.

Parameters:

Content: (String) The contents of the text that will be displayed by the required message and displayed in the System Notification Center.

Payload: (String) optional message-hosted data that customizes the data format based on business logic.

Option: ( messageoptions ) optional to create additional parameters for the message, refer to MessageOptions.

return value: void: No 1.4, Getallmessage: Get all push messages

Pushmessage[] Plus.push.getAllMessage ();

Description: Gets any push messages received by the client. Includes only push messages that are displayed in the System Message Center, excluding calls to the Setautonotification (false) method to set messages that are received after the push message is not displayed.

return value: Pushmessage:array[pushmessage] object, push message pushmessage array.

Platform Support: android-2.2+ (Support), ios-4.3+ (not supported): Unable to get a list of messages from the System Message Center, call this method to return an empty array. 1.5, Getclientinfo: Get the Client Push identity information

Clientinfo Plus.push.getClientInfo ();

Note: The client identification information is used for the data submitted to the push server when the business Server sends the push message, which is used to explain the recipient (client) of the sent push message. The client is required to commit to a business Server save at the first run time.

return value: Clientinfo: Client Push Identity information object

Example:

<! DOCTYPE html>


1.6, Setautonotification: Set the program to display messages in the System Message Center

void Plus.push.setAutoNotification (notify);

Note: By default, the program will display in the System Message Center when a push message is received, by which you can turn off the default behavior, receive a push message and not display it in the System Message Center, and listen for processing of the received message through the AddEventListener method's "Receive" event. In this mode, you can create messages that are displayed in the System Message center through the CreateMessage method.

Parameters:

Notify: (Boolean) required to automatically prompt for push messages. The value TRUE or false,true indicates that the push message is displayed automatically, and false is not displayed. The default value is true.

return value: void: None

Platform Support: android-2.2+ (Support): If the program receives a push message when it is not running, it returns the received message when the AddEventListener method listens for a "receive" event after the program starts. Note: A push platform supports this feature only through message transmission, and other messages are still displayed to the system Message Center.

ios-4.3+ (not supported): Cannot modify whether to display offline push messages, when the program is running in the foreground will not be added to the System Message Center, when the program is no longer running the foreground will definitely be added to the system message.

Example:

<! DOCTYPE html>


1.7. Remove: Delete Push message

void Plus.push.remove (Message)

Note: Delete the push message specified by the System Message Center, and then do so after all the messages have been fetched by the Getallmessage method.

Parameters: Message: (pushmessage) You are required to delete the messages object, you can obtain the message by means of the Getallmessage () method.

return value: void: None

Platform Support: android-2.2+ (Support), ios-4.3+ (not supported): Cannot delete a single message, call Clear () method to empty all messages. 2. Object 2.1, Clientinfo:json object, obtain the client identification information

Property:

(1), token: (String type) device token (Unique identification of the iOS device) used to identify the device in the APNs service push. Platform Support android-2.2+ (support): A unique identification number for the device, usually consistent with the ClientID value. ios-4.5+ (Support): The Devicetoken value of the device, which is used when sending a push message to the APNS server.

(2), ClientID: (String type) push service token (device unique identification) used to identify the recipient of the push information. Third-party push server managed device Unique identification, on iOS platform this value is usually different from token; on other platforms this value is usually consistent with the token value.

(3), AppID: (String type) The application identification of the third party push service. Third-party push server management of the application identity, usually need to be registered on a Third-party push server platform for acquisition.

(4), Appkey: (String type) the application key value of the third party push server. Third-party push servers manage application key values that typically require registration on a Third-party push server platform. 2.1, Pushmessage:json object, push Message object

Property:

(1), Title: (String type) The caption displayed by the push message. Platform Support android-2.2+ (support) Ios-all (support):.

(2), Content: (String type) The contents of the push message display.

(3), Payload: (JSON type) push message-hosted data. If the data transferred in a push message does not conform to the JSON format, it is saved as a string type of data.

(4), APS: (JSON type) Apple APNs push protocol data. Platform Support android-2.2+ (not supported): This data is not supported and the return value is undefined. ios-5.0+ (Support): Encapsulates only the data in the standard APNs protocol, and other data is encapsulated in payload. If the message is created from the local API this property value is undefined. 2.1, Messageoptions:json object, the client to create local message parameters

Property:

(1), Title: (String type) The title of the push message. The notification message header displayed in the System Message Center, and the default value is the name of the program. Platform Support Android-all (support), ios-5.0+ (not supported): does not support the setting of message headers, fixed to the name of the program.

(2), Sound: (String type) The beep of a push message, the beep that plays when the message is displayed, the value: "System"-Indicates the use of system notification beep, "None"-Indicates no beep, and the default is "system". Platform Support android-2.3+ (support), ios-5.1+ (support): When the program is running in the foreground, the beep does not take effect. Note: You should usually set a delay time that takes effect when the program is switched to the background to create a local push message.

(3), cover: (Boolean type) Overwrite the message that was last prompted. The desirable value is true or False,true is overridden, false is not overwritten, and the default is the cover value set in permission. Platform Support

Android-all (Support). ios-5.0+ (not supported): Overwrite messages are not supported, only new messages can be created.

(4), When: (Date type) message is displayed on the prompt. Defaults to the current time and, if the delay is displayed, the time when the message is displayed using the delay. Platform Support Android-all (support), ios-5.0+ (not supported): Set message display time is not supported, the system automatically manages the creation time of the message.

(5), Delay: (number type) prompts the message to delay the display time. When the device receives a push message, it can not be displayed immediately, but is delayed for a period of time, the unit of delay is S, the default is 0s, and is displayed immediately. Platform Support: android-2.2+ (Support), ios-4.3+ (support): Do not support the title, cover, when attribute, ignore its property values. 3. Callback Method 3.1, Pushreceivecallback: The client received a push message callback function

void OnReceive (msg) {

Recieved push message code.

}

Parameters: Msg: (String) Mandatory received push information MSG

return value: void: No 3.2, Pushclickcallback: callback function for user to click Push Message Event

void OnClick (msg) {

Clicked push message code.

}

Parameters: Msg: (String) required user clicks Push Info msg

Return value: void: none

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.