Example code for SMS integration in language Objective C

Send SMS - REST API - JSON

            
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"Content-Type": @"application/json",
   @"Cache-Control": @"no-cache" };
NSDictionary *parameters = @{ @"message": @"Text of the SMS message",
    @"tpoa": @"Sender",
    @"recipient": @[ @{ @"msisdn": @"12015550123" }, @{ @"msisdn": @"447400123456" }, @{ @"msisdn": @"5212221234567" } ] };

NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/json/send"]
       cachePolicy:NSURLRequestUseProtocolCachePolicy
   timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];

NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
    completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        if (error) {
            NSLog(@"%@", error);
        } else {
            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
            NSLog(@"%@", httpResponse);
        }
    }];
[dataTask resume];

Credit inquiry - REST API - JSON

            
#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"Cache-Control": @"no-cache" };

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.labsmobile.com/json/balance"]
       cachePolicy:NSURLRequestUseProtocolCachePolicy
   timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];

NSString *authStr = [NSString stringWithFormat:@"%@:%@", [self myusername], [self mypassword]];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[request setValue:authValue forHTTPHeaderField:@"Authorization"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
  completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
      if (error) {
          NSLog(@"%@", error);
      } else {
          NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
          NSLog(@"%@", httpResponse);
      }
  }];
[dataTask resume];

Send SMS - HTTP/GET

                
NSURL *url = [NSURL URLWithString:@"http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"ret=%@", ret);

Credit inquiry - HTTP/GET

                
NSURL *url = [NSURL URLWithString:@"http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"ret=%@", ret);
  • contact form support

    Sign up!

    Create a user account and send your SMS messages in seconds. You will have all the functionalities and benefits in the same platform.

    Send from API and manage your account with our online application WebSMS.

    Create new account
  • DentalCare, Software for dental surgeries recommends LabsMobile

    SMS communication for dental surgeries. Reminders, loyalty programs, commercial and bulk marketing campaigns.

    Watch more reviews
  • dashboard aplicación online

    Maximum reliability at the best price

    At LabsMobile we only offer direct routes of maximum reliability and quality. Enjoy our platform and all our services for the price of an SMS.

    Pay ONLY for sent messages.

    Check our rates
  • dashboard aplicación online

    Need more info? Contact us!

    Our technical department has professionals with years of experience and we have made multiple integrations.

    We guide and help you through the process.

    Request technical support
  • Create a custom landing

    This tutorial explains how to create a web landing with the WebSMS application. You can send an SMS campaign with a link to this landing and track the clicks of the users.

    Ir al tutorial
loader