1

Possible Duplicate:
How to programmatically send SMS on the iPhone?

I am not sure whether it is possible, but what I would like to achieve is, after asked for users' permission, my app would like to send a formatted sms through my app on their phone. I would like it to happen in the background without them seeing the sms input screen and I would like the sent sms to not present in the message list, only the formatted received message.

Is it even possible? initially I would like to implement it on iPhone, but later on I would like to extend it to Android and wp7. Thanks in advance.

Community
  • 1
  • 1
  • This is a great answer http://stackoverflow.com/questions/10848/how-to-programmatically-send-sms-on-the-iphone?answertab=votes#tab-top – okett Nov 07 '12 at 04:13

5 Answers5

2

On iOS, no, you can't.

You could use a third party service, though.

magma
  • 8,432
  • 1
  • 35
  • 33
2

I dont know for the other platforms but on iOS if your app wants to send an sms it will ask for the users permission and the user will be taken to the sms interface. Apple is very strict about these but in android this might be possible.

Sending SMS on iOS documentation

edit: I dont know what you are trying to do, but why not use the web? If you are trying to send a message that the user doesnt know the content or destination it doesnt need to be by SMS.

pedros
  • 1,197
  • 10
  • 18
  • Because I need to verify the phone number. I am just exploring all possibilities. So yes I have looked into my own phone providers (I am with 3 different ones, one for each phone) result was disappointing - I can send infinite sms for $49.95 but they have no/removed web API. I have also checked out bulk sms providers. Since I might be sending out thousands of them, I am exploring what can be achieved by the mobile that uses my app themselves. –  Nov 07 '12 at 04:30
0

The only alternative I can think if is to send an NSHTTPURLRequest to a web service that provides an SMS gateway. That you could certainly do in the background, though likely you (the developer, not the user) would incur the cost of sending the messages, and the sender would not appear to be the user.

Arvind Kanjariya
  • 2,089
  • 1
  • 18
  • 23
  • Do you know any low costing, reliable sms provider? ... the kind that can send 20,000 for under 800 USD. Needs to cover U.S. U.K & Australia. But would also like to cover Singapore, France, China & HK (not essential). –  Nov 07 '12 at 05:49
  • No I don't know you can find out according to your region from which you are. – Arvind Kanjariya Nov 07 '12 at 05:57
0

You can Send a SMS In Background like this way :

Here i have use on button click you can send sms in background no screen appear in front of user. (Note : Return If applicable otherwise return empty value.)

Get Phone Number of owner :

 TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
 String number = tMgr.getLine1Number();

write Pending Intent this code in on click event.

String message = "HI THIS IS TEST SMS IN ANDROID.";             

/** Creating a pending intent which will be broadcasted when an sms message is successfully sent */
PendingIntent piSent = PendingIntent.getBroadcast(getBaseContext(), 0, new Intent("sent_msg") , 0);

/** Creating a pending intent which will be broadcasted when an sms message is successfully delivered */
PendingIntent piDelivered = PendingIntent.getBroadcast(getBaseContext(), 0, new Intent("delivered_msg"), 0);

/** Getting an instance of SmsManager to sent sms message from the application*/
SmsManager smsManager = SmsManager.getDefault();                

/** Sending the Sms message to the intended party */
smsManager.sendTextMessage(number, null, message, piSent, piDelivered);

Create class name with SmsNotifications which extends BroadcastReceiver

/**
 * This class handles the SMS sent and sms delivery broadcast intents
 */
public class SmsNotifications extends BroadcastReceiver{

    /**
     * This method will be invoked when the sms sent or sms delivery broadcast intent is received 
     */ 
    @Override
    public void onReceive(Context context, Intent intent) {

        /**
         * Getting the intent action name to identify the broadcast intent ( whether sms sent or sms delivery ) 
         */
        String actionName = intent.getAction();


        if(actionName.equals("sent_msg")){
            switch(getResultCode()){
                case Activity.RESULT_OK:
                    Toast.makeText(context, "Message is sent successfully" , Toast.LENGTH_SHORT).show();
                    break;
                default:
                    Toast.makeText(context, "Error in sending Message", Toast.LENGTH_SHORT).show();
                    break;              
            }           
        }

        if(actionName.equals("delivered_msg")){
            switch(getResultCode()){
                case Activity.RESULT_OK:
                    Toast.makeText(context, "Message is delivered" , Toast.LENGTH_SHORT).show();
                    break;
                default:
                    Toast.makeText(context, "Error in the delivery of message", Toast.LENGTH_SHORT).show();
                    break;

            }

        }       
    }
}

Manage your Manifest File :

Permission :

 <uses-permission android:name="android.permission.SEND_SMS" />

And

 <receiver android:name=".SmsNotifications" >
            <intent-filter >
                <action android:name="sent_msg" />
                <action android:name="delivered_msg" />                                
            </intent-filter>
        </receiver>
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
0

You can't do this in Windows Phone 7. You'd have to start a SmsComposeTask which is similar to the MFMessageComposeViewController. This means all the text sending logic is handled in there and you can only adjust some parameters.

tombrtls
  • 136
  • 3