Developer Tools
BasicText SMSCampaignSendOTPVirtual NumberResellerSample CodePhonebookError Code
HOME LOGIN SIGN UP
  • Send SMS in PHP
  • Send SMS in Python
  • Send SMS in JAVA
  • Send SMS in JAVA For XML API
  • Send SMS in C#
  • Send SMS in Google Appscript
  • Send SMS in Windows 8
  • Send SMS in Android
  • Send SMS in iOS
  • Send SMS in VB6
  • Send SMS in Oracle
  • Send SMS in Go Language
  • Api Postman Collection

HTTP SEND SMS API Using iOS

Code:

//Create Objects
NSMutableData * responseData;
NSURLConnection * connection;

// In your viewDidLoad method add this lines -(void)viewDidLoad { [super viewDidLoad]; //Your authentication key NSString * authkey = @"YourAuthKey"; //Multiple mobiles numbers separated by comma NSString * mobiles = @"9999999"; //Sender ID,While using route4 sender id should be 6 characters long. NSString * senderId = @"102234"; //Your message to send, Add URL encoding here. NSString * message = @"Test message"; //define route NSString * route = @"default";
// Prepare your url to send sms with this parameters. NSString * url = [[NSString stringWithFormat:@"http://api.msg91.com/api/sendhttp.php?authkey=%@&mobiles=%@&message=%@&sender=%@&route=%@", authkey, mobiles, message, senderId, route] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; }
// implement URLConnection Delegate Methods as follow -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { //Get response data responseData = [NSMutableData data]; }
-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; }
-(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; [alert show]; }
-(void) connectionDidFinishLoading:(NSURLConnection *)connection { // Get response data in NSString. NSString * responceStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; }

© 2008-2025 | All Rights Reserved.