• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. B2G OS APIs
  5. Navigator (Firefox OS extensions)
  6. Navigator.mozSetMessageHandler()

Navigator.mozSetMessageHandler()

In This Article
  1. Syntax
    1. Parameters
  2. Message types
  3. Browser Compatibility
  4. See also

This API is available on Firefox OS for web content or higher privileged applications.

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.

Syntax

navigator.mozSetMessageHandler(type, handler);

Parameters

 
 type
type is a string that represents the registered handler for which a class of messages.
handler
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

  • Desktop
  • Mobile
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

  • navigator.mozHasPendingMessage()
  • Web Activities
  • Discussion on the Mozilla WebAPI mailing list.

Document Tags and Contributors

Tags: 
  • alarm
  • API
  • Firefox OS
  • Method
  • Reference
  • Web Activities
 Contributors to this page: chrisdavidmills, teoli, fscholz, SphinxKnight, ccarruitero, ananony, nikhilm, kscarfone, chucklee, Gene, Sheppy, Jeremie, mounirlamouri
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:43:08 AM
See also
  1. Archive
  2. Related pages for Firefox OS
    1. MozAlarmsManager
    2. MozMobileNetworkInfo
    3. MozWifiP2pGroupOwner