Languages

Menu
Sites
Language
SMS feature

I would like to have a feature in WebApp as follows.

 

There is a content and I need to get it copied to the SMS Body and then the user the add recipents and send the message.

 

I used <a href="sms:?body=Message"> but didnt worked.Can any one help me out how to make this?

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

17 Replies
Marco Buettner
use follow html
Content
js function messageSent(recipients) { for (var i = 0; i < recipients.length; i++) { console.log("The SMS has been sent to " + recipients[i]); } } // Define the error callback. function messageFailed(error) { console.log("The SMS could not be sent " + error.message); } // Define the success callback. function serviceListCB(services) { if (services.length > 0) { var msg = new tizen.Message("messaging.sms", {plainBody: $("#smsContent").text(), to: [recipents]}); // Send request services[0].sendMessage(msg, messageSent, messageFailed); } } tizen.messaging.getMessageServices("messaging.sms", serviceListCB);
Marco Buettner
sorry html structure looks like
message
Marco Buettner
<div id="smsContent">message</div>
Atma Ram
Where I sould paste this? I tried to paste in main.js under js folder and in HTML added
message
The page shows only "message" as a text.
Atma Ram
What would be the HTML for calling this?
konduri sai swathi
Hi, Do you want to use the text entered by user as SMS? . Then try the below code HTML :
<input type="text" id="message"/>
And then retrieve the text entered by user and add it to the SMS as below JavaScript :
var sms=$('#message').val();
// Define the success callback.
 var messageSentCallback = function(recipients) {
   console.log("Message sent successfully to " + recipients.length + " recipients.");
 }

 // Define the error callback.
 function errorCallback(err) {
   console.log(err.name + " error: " + err.message);
 }
 
 function serviceListCB(services) {
   if (services.length > 0) {
      var msg = new tizen.Message("messaging.sms", {plainBody: sms}); // "sms" is the text retrieved
      services[0].sendMessage(msg, messageSentCallback, errorCallback);
   }
 }

 tizen.messaging.getMessageServices("messaging.sms",
                                    serviceListCB,
                                    errorCallback);
And if you want to copy the text already present in the application then try the below code HMTL :
<div id="message">Hello</div>
Then copy the text from div as below and use the same procedure as above to sent message JavaScript :
var sms=$('#message').text();
Atma Ram
Hi, I would like to copy the text from my application. I would like to have a link on the page. "Send as SMS" and when user clicks it, the message should get copied to SMS body. Please find the page code below,will this work and is it correct?. SMS

Birthday SMS

Home

SMS

Hello How are you?
konduri sai swathi
Hi, The Html part of the code you pasted is not readable. Please replace "<" with "&lt;" and ">" with "&gt;" in the html code while you post it. As you said you can try the below code HTML :
<div id="message">Hello</div>
<a onclick="sendSms()">Send SMS</a>
JavaScript :
function sendSms() {
// paste the code to retrieve text and send sms
}
Atma Ram
Hi, I tried doing what you said. Check out the code below. When I click nothing happens <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <title>SMS</title> <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> <link rel="stylesheet" href="css/style.css"/> </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() { // paste the code to retrieve text and send sms var sms=$('#message').val(); // Define the success callback. var messageSentCallback = function(recipients) { console.log("Message sent successfully to " + recipients.length + " recipients."); } // Define the error callback. function errorCallback(err) { console.log(err.name + " error: " + err.message); } function serviceListCB(services) { if (services.length > 0) { var msg = new tizen.Message("messaging.sms", {plainBody: sms}); // "sms" is the text retrieved services[0].sendMessage(msg, messageSentCallback, errorCallback); } } tizen.messaging.getMessageServices("messaging.sms", serviceListCB, errorCallback); } </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>
konduri sai swathi
Hi, Place the whole code after init() in main.js file instead of placing it in the html itself. Paste the below Javascript code in main.js and the html code should be in index.html which is the same as i suggested in my previous post.
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);
 
Atma Ram
Tried. Still no success. The page doens't respond anything.
konduri sai swathi
Have you added the privilege "message.write" ??
Atma Ram
yep. I have added http://tizen.org/privilege/messaging.write in config.xml privileges
Atma Ram
Anyone help me out....
Marco Buettner
the code works fine, but don't forget you can not send a sms from device, simulator or emulator to a real number because you have no sim card support :)
Atma Ram
Hi Marco, Nice to hear it, but I dont know where I am doing mistake. The page doesn't respond at all when I tap on the link for SMS. I hope you understand, my idea is to copy the test in the SMS body and then user can add Recipents and send SMS. Let me know if the working of the page is like this. If you can, can u send me the full code and file's?
Marco Buettner
To check if it works (until the send progress) I recommend to replace console.log with alert. I have often problems with console.log that it doesn't show on the console view :)