Navigator.mozSetMessageHandler()

Summary

This method is used to allow applications to register a function handler to message from the system in order to react to them.

Any application is allowed to register to any message but some messages will only be delivered to applications that have the corresponding permission. For example, an sms-received message will only be delivered to an application that has the sms permission.

Contrary to DOM events, system messages will stay in queue if the application has no handler for them. You can check if your application has queued messages by calling navigator.mozHasPendingMessage() with the appropriate type as a parameter. When a message handler is set, all queued messages will be asynchronously delivered to the application.

Syntax

navigator.mozSetMessageHandler(type, handler);

Parameters

type
A string representing the kind of message the app wants to register a handler function for.
handler
A function that is called when a message is sent by the system. The kind of parameters the function will accept depends on the type of message.

Message type

Firefox OS currently allows registration for the following messages:

Message name Handler signature Permission
activity f( MozActivityRequestHandler request )  
alarm f( object unknown ) alarms
bluetooth-cancel f( object unknown ) bluetooth
bluetooth-dialer-command f( object unknown ) bluetooth
bluetooth-hfp-status-changed f( object unknown ) bluetooth
bluetooth-opp-transfer-start f( object unknown ) bluetooth
bluetooth-opp-transfer-complete f( object unknown ) bluetooth
bluetooth-opp-receiving-file-confirmation f( object unknown ) bluetooth
bluetooth-opp-update-progress f( object unknown ) bluetooth
bluetooth-pairedstatuschanged f( object unknown ) bluetooth
bluetooth-requestconfirmation f( object unknown ) bluetooth
bluetooth-requestpincode f( object unknown ) bluetooth
bluetooth-requestpasskey f( object unknown ) bluetooth
headset-button f( object unknown )  
icc-stkcommand f( object command ) settings
notification f( object unknown )  
push f( object registration ) push
push-register f (  ) push
sms-received f( SmsMessage sms ) sms
sms-sent f( SmsMessage sms ) sms
telephony-call-ended f( object call ) telephony
telephony-new-call f( ) telephony
ussd-received f( object ussd ) mobileconnection
wappush-received f( object wappush ) wappush

Specification

Specification Status Comment
Unknown Working Draft Defines the system messaging interfaces.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support Not supported Not supported Not supported Not supported Not supported
Feature Android Firefox OS Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Not supported 1.0 Not supported Not supported Not supported Not supported

See also

Document Tags and Contributors

Contributors to this page: Sheppy, kscarfone, teoli, Gene, mounirlamouri, Jeremie, nikhilm, chucklee
Last updated by: nikhilm,