Is there a way to automatically send an SMS with Phonegap or Cordova on iOS and Android? If not is there a way to pre fill the text message in the native app so the user just as to confirm the message to be sent?
Just to add to KateMihalikova's answer (I don't have enough rep to add a comment on it) but her answer is correct except for the iOS >= 7 part; iOS 7 body is not supported (I believe only if you have already had history with the SMS number in question will it work, but I've not tested it); however iOS 8 has brought body prefill back: you have to replace the ; that was used for iOS <=6 with an & instead:
iOS 8: sms:+123456789&body=hello there
sms: schema
Android: sms:+123456789?body=hello there
iOS != 7: sms:+123456789;body=hello there
iOS = 7: sms:+123456789 - body is not supported
You can use link or javascript location:
Send SMS
window.location = "sms:+123456789?body=" + encodeURIComponent("hello there");
Default sms app is opened and prefilled with provided data.
Cordova plugin
Some examples:
https://github.com/hazems/cordova-sms-plugin
https://github.com/aharris88/phonegap-sms-plugin
Not tested
9.3.2015 edited with iOS 8
I can confirm that with ios7 the body text will work as long as the number being contacted has an existing chat history.
Related
I am trying to create a link in an email that will open a mobile device's default texting app if pushed. Here is what I have so far:
a href="sms:;?&body=This%20is%20the%20body%20message."
I have tested it and it seems to work on iOS devices as well as some Android devices. However, on a Google Pixel 3, it opens the default messaging app but shows an error which reads Could not start conversation.
How can I change my code to successfully open a conversation with a blank recipient?
After hours of trial and error, I was able to prefill the Pixel (3XL), iOS (simulated in Xcode), and macOS Messages using the following structure:
Pixel: sms://+1${PHONE}/?body=${encodedString}
iOS: sms://+1${PHONE}/&body=${encodedString}
Give this a try from a link, I think you need a number and replace ; with ?
Send SMS
For non iOS you want to use (For your Pixel Example)
sms:phone_number?body=The_Message
For iOS you want to use
sms:phone_number;body=The_Message
Please look at the Signal icon in this screenshot:
My question is how to obtain the same result in a Codename One app. Suppose that my app has a variable like "int unreadMdg", how can I show the number of unread message in the app icon?
We currently only support this on iOS as it wasn't available on any Android device when we launched the feature and is still arguably flaky on Android.
For iOS support you can set the badge value via push notification (see the developer guide) or by using the API:
if(Display.getInstance().isBadgingSupported()) {
Display.getInstance().setBadgeNumber(unreadCount);
}
This is for IOS
Use this to make it displays a specific number
// Objective-C
[UIApplication sharedApplication].applicationIconBadgeNumber = number;
// Swift
UIApplication.shared.applicationIconBadgeNumber = number
I am making application in ionic and one of it's functionality to send mail so i have used plugin
problem is i am not able to generate link for android with gmail version > 6.10
Also tried to send mail using apps Gmail, Outlook, Bluemail every mail client giving different output.
Gmail version 6.10(ok) but 6.11(not generating links)
Outlook giving blank result (not event text as other mail client gives)
Bluemail same as Gmail
I'll be thankful if you have any solution of this.
EDIT
Sorry if you misunderstood "generate link" means using html content(<a href="...">)
Was using the plugin myself also, lots of problems and poorly maintained, just check their Github issues page to confirm, use this instead and you can specify to send via email using .shareViaEmail and include link in there.
Use var bodyText = document.getElementById("aaa").href; to get value for link, surely you must have <div><a href=‘YOURLINK’ id='aaa'>texthere</a></div> in HTML. Then pass it as as a message .shareViaEmail("PASS IT HERE",
I'm trying to send a pre-populated SMS via AS3 in Adobe AIR. It works perfectly on iOS, with the native SMS UI displaying with the pre-populated text. However on Android it's seeing the whole string as the phone number, showing the following error -
Invalid recipients(s): <0123456789&body=Hey! This is a test message.
http://google.com>
The code I'm using -
var number:String = "0123456789"
var callURL:String="sms:"+number+"&body=Hey! This is a test message. http://google.com";
var targetURL:URLRequest = new URLRequest(callURL);
NavigateToURL(targetURL)
1st) The & that you are using should be an ?
sms:+15105550101?body=hello%20there
Refer to RFC 5724 for details.
Note: on iOS8+ the & is correct, for iOS7 and under use an ;
2nd) Certain Android versions are just plain broken when it comes to including a 'body' in an SMS URI. You would need to look up the 'buggy' versions in Google's bug database.
I found a way to read the call log, e.g. incoming call, phone number, duration, etc. Now I am looking for something similar for SMS. How can I read that history for SMS? I don't need the content of the SMS only the date and the target phone number. Any idea?
Thanks,
A.
There is no API for "SMS history" in the Android SDK, sorry.
I have an open source Cordova 2.2.0 example app showing use of a Cordova plug-in for Android to read SMS inbox and sent messages. It uses some undocumented features of Android 4.2.
https://github.com/DavidWalley/CordovaPlugin_AndroidSmsRead
Hope you can use it.