Aadesh Kulkarni Aadesh Kulkarni - 1 month ago 17
Android Question

sending SMS from server in Android Projects

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. ?

Answer

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.