sending SMS from server in Android Projects - android

I am making an Android App that takes food orders from customers for home delivery.
When the order is confirmed, I want the App to send an SMS to the Customer and the Hotel about the Order summary.
I am new to Android so pardon me for asking newb questions.
I tried Android's SMSManager to send the SMS.
public void sendthisSMS(String phoneNo, String msg) {
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, msg, null, null);
Toast.makeText(getApplicationContext(), "Message Sent",
Toast.LENGTH_LONG).show();
} catch (Exception ex) {
Toast.makeText(getApplicationContext(),ex.getMessage().toString(),
Toast.LENGTH_LONG).show();
ex.printStackTrace();
}
}
This works great. But The problem is,Using this code, the SMS amount(0.5 Rs) is getting debited from the customer's Phone.
The App should send the SMS for free.I'm using a server for storing data of the App and its users.
How to implement this SMS thing on the server end so that The server bears the SMS fee and not the User using the App. ?

You are executing this method from your customer's phone. It is indeed logical to think that the balance gets reduced from the customer's phone. If you do not want to send the SMS from their phone, you have to use a SMS Gateway, such as this one. You have to pay for each SMS sent through this gateway.
So the net result is either you pay or your customer pays. If you are from a startup and want to minimize costs, I'd suggest you to include a disclaimer above your Order Now button stating that an SMS would be sent, and the customer will be charged for that.
The other option is to send an email to the 10 digit mobile number using this list, as #EliSadoff said in the comments.

Related

How to send sms to multiple people you have a history with using URL launcher flutter

I am using following code:
//Sms phone number
String num1='123';
String num2='456';
String msg='Hello world';
final sms = Uri.parse('sms:${num1},${num2}?body=${msg}');
if (await canLaunchUrl(sms)) {
await launchUrl(sms);
} else {
throw 'Could not launch $sms';
}
This will send a msg to the numbers 123 & 456.
However if one of these numbers is already in my contacts or I've previously texted them this will open up my chat with them and only send the msg to this number and therefore cancel out sending the msg to the other recipient.
So basically I cannot send to multiple recipients if I already have a history with one of them.
How can I go through with the sms instead of it opening my history with one of those contacts?
You could use one or booth of those packages.
I would fetch all the previous send messages and iterate though so see if there is one message with an equal phone number as of my current one.
SMS - To get the previous send Messages
Contacs Service - To get all your Contacts

Xamarin.Android: Check SMS Status

In my Xamarin.Android app I send SMS using the following code :
send.Click += (s, e) =>
{
SmsManager.Default.SendTextMessage(number.Text, null, message.Text, null, null);
}
And in another button, I want to check which messages are delivered and which are not, to send undelivered message again.
How can I :
Find messages? Is there an ID (a unique one for each sms) or I should find messages by Number and Text?
Check the status of each message?
Please try the parameters sentIntent and deliveryIntent. Both are PendingIntents that will be broadcasted upon successful sending and delivery to the recipient. Upon building your intent you can add some id from your app that helps you identify which sms was sent/not sent.
To see how to query the SMSProvider, take a look at
this StackOverflow anwer.
The answer above uses Telephony.Sms.Inbox. I suggest trying to access Telephony.Sms.Conversations, which according to the doc contains all sent text-based SMS messages. As the class extends android.provider.Telephony.TextBasedSmsColumns, you should be able to query several error codes and status.

send bulk sms on android sms app using api from another provider

I have a bulk sms site http://esmsafrica.com now I am building a sms app that will use the same API so that users registered on the site can still view there balance and send sms, I understand to use default smsmanager for android is below code, I have also searched on android developer page yet nothing seems to help, can someone let me know how to go about this, would I need to import any code from my site? I believe it should look like below code. I have a valid API code, username and password.
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, senderID, message, sentPI, deliveredPI);

Send automatic message via android app

I'm just wondering is it possible to send a Message from the app without using actionView or actionSend ( meaning no asking for chooser to send via google or hotmail etc.. ) from the Intent ?
what I want to make is like a TextView and a Button
the user will enter a text in the textview and then click the Button to send the message, then the message will be automiatlly sent to the developer ( me )
I hope what I'm thinking of is possible.
I'm not sure what kind of message you are trying to send, but you can use the SMS feature of the phone to send not only a SMS, but an email, too.
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("1"+yourPhoneNumber, userPhoneNumber, message, null, null);
You can replace phone numbers with emails and it will work without user interaction (unlike sending an email through an email client which cannot be done automatically). You can try it out by texting your own email. For your specific situation, you could set up a developer email that handles all of these messages that you are trying to send. The only issue with this is that you may not know who you are receiving messages from. For example, if you send a SMS -> email, it might show up as from something#vz.com or something. However, you can mitigate this by including addition info in the message payload itself.
Yes, it is possible. You can use the internet connection to have the message saved to some cloud storage or something. Personally, I prefer using Parse.com because they have an amazing API that saves you a lot of hassle.
Just add the message from the EditText to a ParseObject and call the saveEventually() method. As soon as the internet is back on, the message will be sent to your cloud storage.

Android: How to send SMS to email account

The stock Android text messaging app allows you to send SMS to an email account instead of a phone number. How is this done? I tried the following code and it failed.
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("myaccount#gmail.com", null, textMsg, sentPI, null);
This other question seems to be related How to send SMS message reply to email address?
... but the accepted answer says
Each cell carrier has a specific SMS number that you can send a text message to in a certain format. This is called a "SMS Gateway".
I want to send to my gmail account, not to AT&T.
Sorry, seems I misread the answer. Looks like my carrier (AT&T) will send the email for me. What puzzles me is how an app could work for different carriers?

Categories

Resources