Android Question [SOLVED] Mobile device call by server

ThePuiu

Active Member
Licensed User
Longtime User
Hi,
I have a .NET application on a rented server. It is desired that when inserting a new registration in a table, an SMS will be sent automatically.
Since I have no physical access to the server, I was thinking of making an Android application that will be notified by the server and send the SMS. The idea was that the NET application would send a push notification to the mobile terminal, and it would take from the body of the notification the phone number and the content of the SMS.
Do you have a better idea?
Thank you!
 

JohnC

Expert
Licensed User
Longtime User
If you are able to modify the code on the server so that it will send a push modification, then you should be able to instead modify the server code to directly send an SMS from the server itself using the Twilio.com service (using a HTTP "post" message).

See Twilio.com for more info.

P.S. Google stopped allowing Android apps from directly sending SMS messages from a device unless the Android app is the default SMS app on the device. So, if you do implement your idea, you would no longer be able to use the current SMS app on your phone anymore - you would need to replace it with the new app you are creating. So, then to do normal SMS actions like receive SMS's and send SMS to your contacts, you would have to re-invent the wheel and add all that basic SMS app functionality to your app.
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
Thanks for the reply!
Yes, we know about the paid services for sending messages, but for Romania (the country where the application will run) the price for a message is also 20 times higher than in the USA! For this reason, my client would like us not to go on this option.

The application will not be uploaded to the Store, so it is not a problem with sending messages. I am more interested in an idea whereby the server can call the application to send a message at the right time. I do not like the variant with push notifications, but for now it is the only one I know.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
if this mobile phone is static just for outgoing sms a tpc socket connection would do it also.
search also for mqtt.
you can get also usb sticks with sim card for pc wherewith you can send sms via at commands.
a raspberry pi as example use very low power.
or have a look at arduino boards (+SIM 900 GPRS/GSM Shield).
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
I made the application that when receiving a push notification to send an SMS. The application works perfectly as long as it is in the foreground ... but not if it is in the background.

How can I correct this behavior?
B4X:
'Main
Sub SendSMS(Destination As String, Message As String)
    Try
    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
    Dim parts As Object
    parts = r.RunMethod2("divideMessage", Message, "java.lang.String")
    r.RunMethod4("sendMultipartTextMessage", _
      Array As Object(Destination, Null, parts, Null, Null), _
      Array As String("java.lang.String", "java.lang.String", _
         "java.util.ArrayList", "java.util.ArrayList", "java.util.ArrayList"))
         
    Log("SMS sent " & Destination)
    Catch
        Log(LastException)
    End Try
End Sub

------------------------------------------------------------------------
'FirebaseMessage service
Sub fm_MessageArrived (Message As RemoteMessage)   
    Private m As Map
    m.Initialize
    m.Put("Phone",Message.GetData.Get("Phone"))
    m.Put("Message",Message.GetData.Get("Message"))
    CallSubDelayed2(Main, "SendSMS",m)
End Sub
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Another possible solution for this that might work...

I don't know how cell companies outside the US work, but many US cell companies have a method to convert emails to SMS messages.

For example, if I send an email to [mycellnumber]@txt.att.net (different cell companies have different "to:" email addresses - see below), AT&T will convert the email to an SMS and send it to my cell phone. I currently use this method to allow my security IPCams to send me motion-detected SMS alerts.

So, if your cell company offers this method, then your server could simply send an email to the special address that will convert it to an SMS.

These are the email methods for other cell companies in the US that worked in the past, but I have no way to test them now:

phonenumber@vtext.com (Verizon)
phonenumber@messaging.sprintpcs.com (Sprint)
phonenumber@tmomail.com (T-Mobile)
 
Last edited:
Upvote 0
Top