-
-
Save ThisIsMissEm/ebd79f6cd4f620fc4fa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example Usage: | |
<script type="text/javascript"> | |
if (navigator.device.messaging) { | |
var messaging = ; | |
var message = new navigator.device.messaging.SMS({ | |
to: "+46000000001", | |
body: "Welcome to Atlantis" | |
}); | |
// alternative: message.onsend | |
message.addEventListener("send", function() { | |
alert("The message is being sent"); | |
}); | |
// message.onsent | |
message.addEventListener("sent", function() { | |
alert("The message was sent successfully"); | |
}); | |
// message.onerror | |
message.addEventListener("error", function(error) { | |
alert("There was an error when sending the message."); | |
}); | |
// message.onaborted | |
message.addEventListener("aborted", function() { | |
alert("Sending of message was aborted"); | |
}); | |
message.send(); | |
// Abort sending, just for example: | |
message.abort(); | |
} | |
</script> | |
IDL: | |
// Exposed on navigation.device | |
Device implements DeviceMessaging; | |
[NoInterfaceObject] | |
interface DeviceMessaging { | |
readonly attribute MessagingManager messaging; | |
}; | |
[NoInterfaceObject] | |
interface MessagingManager { | |
SMSMessage SMS(in SMSMessageProperties) | |
MMSMessage MMS(in MMSMessageProperties) | |
EmailMessage Email(in EmailMessageProperties) | |
}; | |
[NoInterfaceObject, Constructor(in DOMString to, in DOMString message, in optional sequence<Blob>)] | |
interface Message { | |
// states | |
const unsigned short UNSENT = 0; | |
const unsigned short SENDING = 1; | |
const unsigned short ABORTED = 2; | |
const unsigned short ERROR = 3; | |
const unsigned short SENT = 4; | |
readonly attribute unsigned short readyState; | |
readonly attribute Date sentTime; | |
// methods | |
boolean send(); | |
void abort(); | |
// event handler attributes | |
attribute Function onsend; | |
attribute Function onsent; | |
attribute Function onerror (in MessagingError error); | |
attribute Function onaborted; | |
}; | |
Message implements EventTarget; | |
[NoInterfaceObject] | |
interface SMSMessage : Message { | |
attribute DOMString|DOMString[] to; | |
attribute DOMString body; | |
attribute sequence<Blob> attachments; | |
}; | |
[NoInterfaceObject] | |
interface SMSMessageProperties { | |
attribute DOMString|DOMString[] to; | |
attribute DOMString body; | |
attribute sequence<Blob> attachments; | |
}; | |
[NoInterfaceObject] | |
interface MMSMessage : Message { | |
attribute DOMString|DOMString[] to; | |
attribute DOMString subject; | |
attribute DOMString body; | |
attribute sequence<Blob> attachments; | |
}; | |
[NoInterfaceObject] | |
interface MMSMessageProperties { | |
attribute DOMString|DOMString[] to; | |
attribute DOMString subject; | |
attribute DOMString body; | |
attribute sequence<Blob> attachments; | |
}; | |
[NoInterfaceObject] | |
interface EmailMessage : Message { | |
attribute EmailAddress|EmailAddress[] to; | |
attribute EmailAddress|EmailAddress[] cc; | |
attribute EmailAddress|EmailAddress[] bcc; | |
attribute DOMString subject; | |
attribute short priority; | |
attribute DOMString body; | |
attribute sequence<Blob> attachments; | |
}; | |
[NoInterfaceObject] | |
interface EmailMessageProperties { | |
attribute EmailAddress|EmailAddress[] to; | |
attribute EmailAddress|EmailAddress[] cc; | |
attribute EmailAddress|EmailAddress[] bcc; | |
attribute DOMString subject; | |
attribute short priority; | |
attribute DOMString body; | |
attribute sequence<Blob> attachments; | |
}; | |
[NoInterfaceObject] | |
interface EmailAddress { | |
attribute DOMString address; | |
attribute DOMString name; | |
}; | |
[NoInterfaceObject] | |
interface MessagingError : GenericError { | |
const unsigned short UNKNOWN_ERROR = 0; | |
const unsigned short INVALID_ARGUMENT_ERROR = 1; | |
const unsigned short TIMEOUT_ERROR = 3; | |
const unsigned short PENDING_OPERATION_ERROR = 4; | |
const unsigned short IO_ERROR = 5; | |
const unsigned short NOT_SUPPORTED_ERROR = 6; | |
const unsigned short PERMISSION_DENIED_ERROR = 20; | |
const unsigned short MESSAGE_SIZE_EXCEEDED = 30; | |
readonly attribute unsigned short code; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment