Hello everyone,
I am trying to send SMS through a Tizen Web application:
index.HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="Tizen Wearable basic template generated by Samsung Wearable Web IDE"/>
<title>Tizen Wearable Web IDE - Tizen Wearable - Tizen Wearable basic Application</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script src="js/main.js"></script>
<link rel="stylesheet" href="./css/jquery.mobile-1.2.0.css"/>
<link rel="stylesheet" href="css/jqm-docs.css"/>
<script type="text/javascript" src="./js/jquery-1.8.2.js"></script>
<script src="js/jqm-docs.js"></script>
<script type="text/javascript" src="./js/jquery.mobile-1.2.0.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<div data-role="page" class="type-interior" data-theme="e">
<div data-role="header" data-position="fixed" data-theme="e">
<h1>SMS</h1>
<a href="index.html" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
</div><!-- /header -->
<div data-role="content" data-theme="e">
<div class="content-primary">
<h2>SMS</h2>
<div id="message">Hello How are you</div><br /><br />
<script type="text/javascript">
function sendSms() {
var sms=$('#message').text();
// Define the success callback.
function messageSent(recipients) {
console.log("The SMS has been sent");
}
// Define the error callback.
function messageFailed(error) {
console.log("The SMS could not be sent " + error.message);
}
// Define service error callback.
function serviceErrorCB(error) {
console.log("Cannot get messaging service " + error.message);
}
// Define the success callback.
function serviceListCB(services) {
if (services.length > 0) {
// SMS sending example
var msg = new tizen.Message("messaging.sms", {plainBody:sms,
to:["+34666666666"]}); // phone number to which the message has to be sent
// Send request
services[0].sendMessage(msg, messageSent, messageFailed);
}
}
tizen.messaging.getMessageServices("messaging.sms",
serviceListCB,
serviceErrorCB);
}
</script>
<a onclick="sendSms()">Send SMS</a>
<!--/content-primary -->
</div><!-- /content -->
<div data-role="footer" class="footer-docs" data-position="fixed" data-theme="e">
</div>
</div><!-- /page -->
</body>
</html>
main.js:
window.onload = function () {
// TODO:: Do your initialization job
// add eventListener for tizenhwkey
document.addEventListener('tizenhwkey', function(e) {
if(e.keyName == "back")
tizen.application.getCurrentApplication().exit();
});
};
I run this code on the Tizen Wearable emulator, and in the console output, I got:
index.html (64) :TypeError: 'undefined' is not an object (evaluating 'tizen.messaging.getMessageServices').
I didn't find out the error, besides where should I put the message which will be sent.
P.S: I also added this privileges into the config.xml file: http://tizen.org/privilege/messaging.write even I didn't found it in the predefined ones!
Thanks in advance!