This method is used to allow applications to register a function handler that can receive — and react to — a message from the system.

Any application is allowed to register a handler to receive 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 the queue even 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.


navigator.mozSetMessageHandler(type, handler);


type is a string that represents the registered handler for which a class of messages.
when the system sends a message, the handler is called, its reception parameters determined by the message type.

Message types

Currently Firefox OS allows you to register handlers for the following messages:

Message type 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-pairing-request f( object unknown ) bluetooth
bluetooth-requestconfirmation f( object unknown ) bluetooth
bluetooth-requestpincode f( object unknown ) bluetooth
bluetooth-requestpasskey f( object unknown ) bluetooth
cdma-info-rec-received ?  
connection ? mobileconnection
first-run-with-sim ?  
headset-button f( object unknown )  
icc-stkcommand f( object command ) settings
networkstats-alarm f( object command ) networkstats-manage
nfc-hci-event-transaction ? nfc
nfc-manager-send-file ? nfc
nfc-manager-tech-discovered ? nfc
nfc-manager-tech-lost ? nfc
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
wifip2p-pairing-request f ( object unknown ) wifi-manage

Browser Compatibility

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

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

alarm API Firefox OS Method Reference Web Activities