I'm opening the native SMS composer in Android and want to pre-populate the SMS body. I tried...
Titanium.Platform.openURL('sms:?body=hello world!');
....but it adds hello world! to the contact field. Is there any way to add to the body?
for android, you can use intent to send sms...
Example
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_VIEW,
type : 'vnd.android-dir/mms-sms',
});
intent.putExtra('sms_body', <body text>);
intent.putExtra("address", <number>);
try {
Ti.Android.currentActivity.startActivity(intent);
} catch (ActivityNotFoundException) {
Ti.UI.createNotification({
message : "Error"
}).show();
}
and for iphone you can use this module to send sms.
Related
I am using sms method in html to send my message (Hello & Welcome) through android default messaging app.
Here is my code:
<a href="sms:001234567890?body=Hello%20%26%20Welcome">
<button>
Say Hello,
</button>
</a>
I have expect Hello & Welcome
But android default messaging app is only showing Hello not & Welcome (full message body)
I have also tried:
%26&&&&
But it's still not showing.
Try this
<a href="sms:001234567890?body=Hello+%26+Welcome">
Refer this
I think you have discovered a bug!
Note the differences here (&, %):
IOS:
Send an SMS
Android:
Send an SMS
You can combine these to support both like so:
Send a SMS message
Now... This has been quite a pain. I've even been able to crash Android Messenger... I am able to find little to no documentation about SMS links.
Specifically there is problems with &. The below i am inserting an exclamation mark and it is working fine.
Send a SMS message
You can use this method for encode when sending message and decode to show by given methods.
private String encodeMessage(String message) {
message = message.replaceAll("&", ":and:");
message = message.replaceAll("\\+", ":plus:");
return StringEscapeUtils.escapeJava(message);
}
private String decodeMessage(String message) {
message = message.replaceAll(":and:", "&");
message = message.replaceAll(":plus:", "+");
return StringEscapeUtils.unescapeJava(message);
}
Hi I would like to know if there is something to send a whatsapp message using javascript or something I was searching but I did not find any new post. This is not for any special purpose. I found this but it only works if you have whatsapp web. I was thinking on clicking on a link to send a default message to a default number
Send Message
Just make use of this function in web browser to get it running as you want.
Note: You need to run the code manually through browser console with an opened conversation in WhatsApp
(web version).
function sendMessage(message){
const mainEl = document.querySelector('#main')
const textareaEl = mainEl.querySelector('div[contenteditable="true"]')
if(!textareaEl) {
throw new Error('There is no opened conversation')
}
textareaEl.focus()
document.execCommand('insertText', false, message)
textareaEl.dispatchEvent(new Event('change', { bubbles: true }))
setTimeout(() => {
(mainEl.querySelector('[data-testid="send"]') || mainEl.querySelector('[data-icon="send"]')).click()
}, 100)
}
Ref: https://github.com/Matt-Fontes/SendScriptWhatsApp/blob/main/shrekSendScript.js
I find this way is a better way to send a msg to WhatsApp unknowing number.
// github: omar-bakhsh
function send_handle(){
let num=document.getElementById("number").value;
let msg= document.getElementById("msg").value;
let name= document.getElementById("name").value;
var win = window.open(`https://wa.me/${num}?text=I%27m%20api%20msg%20hello%20${name}%20friend%20${msg}`, '_blank');
// win.focus();
}
<div>
<h3>whatsapp send app </h3>
<h6>add number without space like 17272912606 not <strike>+1 (727) 2912606 </strike></h6>
<input id="number" type="numric" placeholder="phone 966506666666" >
<input id="name" type="text" placeholder="name" >
<input id="msg" type="text" placeholder="type msg" >
<button onclick="send_handle()">send</button>
You can do this:
Send Message
Whatsapp dosen't support sending messages from the PC. Every message has to come from a Phone. Whatsapp web is just redirecting the messages to your phone wich is then sending the message. If you use their api you only can let users send a message to any number via Whatsapp using their phone. To predetermine the message use:
https://api.whatsapp.com/send?phone=whatsappphonenumber&text=urlencodedtext
more: https://faq.whatsapp.com/en/android/26000030/?category=5245251
On the WhatsApp developers hub, they demonstrated a walkthrough guide on how to opt-in for a developer account on meta, and create an app so can make api calls if you want to use WhatsApp programmatically,
Short version:
Register as a Meta Developer
Enable two-factor authentication for your account
Create a Meta App: Go to developers.facebook.com > My Apps > Create App.
Select the "Business" type and follow the prompts on your screen.
Scroll down to find the "WhatsApp" product and click Set up.
Select an existing Business Manager, if you don't the wizard will guide you to create one.
Next screen will show you a demo.
If you need a listener when your number receive a message or reply, you should register webhooks.
Add your phone number to use it programmatically. and it shouldn't be connected with WhatsApp at all, neither personal or business.
for more details follow the getting started guide:
https://business.whatsapp.com/developers/developer-hub
It's impossible to do it with HTML link. Whatsapp has no official API. But you can find (or write it by yourself) some script to emulate user actions on the site web.whatsapp.com. For example, this one (I did not test it).
I would like to implement a App in Phonegap with the Adobe Phonegap Builder under http://build.phonegap.com. And I would like to use the Plugin https://build.phonegap.com/plugins/2420 to send SMS.
In my config.xml stay:
<gap:plugin name="com.cordova.plugins.sms" version="0.1.2" />
The Adobe PhoneGap Builder shows this plugin as integrate plugin.
My next action was to download and add the /www/sms.js from https://github.com/cordova-sms/cordova-sms-plugin/tree/48d9630 and include this in the index.html
Then I add to a JavaScript function like the example on Git:
var message = "Testing SMS by sending it to ";
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without open any other app
}
};
var success = function () {
alert('Message sent successfully');
};
var error = function (e) {
alert('Message Failed:' + e);
};
sms.send("MY Handy number", "sms", options, success, error);
In a other Post I found that replace
var exec = require('cordova/exec');
with
var exec = cordova.exec
can help, but it do not work.
Ok .
i have "fix" it.
there must the first include js, in this order.
Also its important that the file sms.js is not exists.
In the config.xml
you must put in:
an that is it. :)
I'm not able to send a message with facebook using the Cordova Plugin.
function fbMessage(description){
var options = {
method: "send",
caption: '',
link: '',
description: description,
to: '100003725222912'
};
facebookConnectPlugin.showDialog(options,
function(dialogSuccess) {
},
function(dialogFaliure) {
})
}
the message doesn't compare in the page.
I'm sure I connect to facebook with my application.
The Error is:
Error Domain = com.facebook.sdk.share Code = 202 "The operation couldn't be completed. (com.facebook.sdk.share error 202.)" UserInfo=0x7967aa0{com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Message dialog is not available.}
If you install Facebook Messenger App, the error message doesn't appear anymore and the send dialog shows up. It works on smartphones. For android tablets, you need to fill the name, caption and description as well, only the link and method won't work. In iPad, however, it seems to not work yet.
I have a chrome Apps use push notification of GCM. I have a problem, when i don't login account on chrome. I can't receive registerId from GCM. I think a idea. When registerId empty, i show notification, request user login to chrome and show login page account on chrome. But because of security concerns , the chrome does not allow access to its setting from external links . How is open "chrome://settings/" from external links? Can register to gcm, If i don't want login account on chrome?
My code:
function setValue()
{
//var thongtin=$('#status').val();
//var thongtin = document.getElementById('status').innerText;
if(registrationId == "")
{
// Pop up a notification to show notification.
chrome.notifications.create(getNotificationId(), {
title: 'CLOUD MONITOR',
iconUrl: 'gcm_128.png',
type: 'basic',
message: 'You must sign in account gmail on google chrome!'
}, function() {});
//event click to notification
chrome.notifications.onClicked.addListener(function() {
window.location.href = "chrome://settings/"
});
}
else
{
//http://mtraffic.longvan.net/device_register?regId=" +registrationId+"&device=android
//document.getElementById('webviewSendData').src = "http://192.168.64.246:8080/register?REGID=" +registrationId+"&DEVICE=desktop";
document.getElementById('webviewSendData').src = "http://mtraffic.longvan.net/device_register?regId="+registrationId+"&device=android";
//document.getElementById('webviewSendData').src = "http://192.168.64.124:8080/monitor/device_register?regId=" +registrationId+"&device=android";
//var url = "http://192.168.64.124:8080/monitor/device_register?regId=" +registrationId+"&device=android";
//httpGet(url);
//alert(thongtin);
//document.getElementById('status').innerHTML="Infomation New";
// Pop up a notification to show notification.
}
}
This code don't run.
chrome.notifications.onClicked.addListener(function() {
window.location.href = "chrome://settings/"
});
I fix code as Derek 朕會功夫.
chrome.notifications.onClicked.addListener(function() {
chrome.tabs.create({url: "chrome://settings/"});
});
And receive error notify: Error in event handler for notifications.onClicked:TypeError: Can't read property 'create' of underfined.
I'm afraid at the moment it's not possible.
Chrome Apps don't have access to tabs/windows API that can open privileged pages; that's why Derek's suggestion does not work.
In future, they may be a way to do this with chrome.browser API. See this feature request, this proposal, and please leave feedback there with your use case.