Skip to content

Instantly share code, notes, and snippets.

@marshall
Created June 22, 2012 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshall/2975729 to your computer and use it in GitHub Desktop.
Save marshall/2975729 to your computer and use it in GitHub Desktop.
WebSmsIndicator example
// This example shows the WIP API in https://bugzilla.mozilla.org/show_bug.cgi?id=736710
// Note: mozSms access requires the URL to be in the dom.sms.whitelist
// I tested with the statusbar by adding the "sms" permission category to Gaia's system app in gaia/apps/system/manifest.webapp
var sms = window.navigator.mozSms;
sms.addEventListener("indicator", function onindicator(event) {
var indicator = event.message.indicator;
if (indicator.active) {
// show indicator
}
if (indicator.messageCount > 0) {
// show message count
}
// voicemail callback number is in the indicator's owning message:
var callbackNumber = event.message.sender;
// some older voicemail systems won't give you an exact messageCount, but they can give a "Return Call" message in the SMS message body
var returnCallMessage = event.message.body;
if (returnCallMessage) {
// display return call message
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment