Send a WhatsApp API using Objective-C

Introduction

In this code snippet, you learn how to send a WhatsApp API using Objective-C, to send a text message, WhatsApp Templates, media, interactive buttons, lists, products … etc, Alvochat account is required to run the following codes. Create an Account if you don’t have one.

Send template using WhatsApp API

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/template"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&name=hello_world" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&language=en_us" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&header=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&body=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&buttons=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send a text message using WhatsApp API

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/chat"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&body=WhatsApp API on alvochat.com works good" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&preview_url=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send image

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/image"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&image=https://alvochat-example.s3-accelerate.amazonaws.com/image/1.jpeg" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&caption=image caption" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send audio

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/audio"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&audio=https://alvochat-example.s3-accelerate.amazonaws.com/audio/1.mp3" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send video

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/video"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&video=https://alvochat-example.s3-accelerate.amazonaws.com/video/1.mp4" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&caption=video caption" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send document

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/document"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&document=https://alvochat-example.s3-accelerate.amazonaws.com/document/1.pdf" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&filename=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send sticker

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/sticker"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&sticker=https://alvochat-example.s3-accelerate.amazonaws.com/sticker/1.webp" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send Contact

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/contact"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&contact=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send Location

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/location"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&lat=37.484296" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&lng=-122.148703" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&address=Menlo Park, California, United States" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&name=Meta Headquarters" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send list

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/list"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&header=header" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&body= please select one of the following options" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&footer=footer" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&button=options" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"§ions=option_1,option_2,option_3" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send button

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/button"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&header=header" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&body= please select one of the following options" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&footer=footer" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&buttons=option_1,option_2,option_3" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

Send products

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.alvochat.com/instance1199/messages/product"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/x-www-form-urlencoded"
};

[request setAllHTTPHeaderFields:headers];
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"send=true" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&token=YourToken" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&to=16315555555" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&header=header" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&body=Hi , check out our new products" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&footer=footer" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&catalog_id=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&product=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&priority=" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&message_id=" dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);

You can see the Full Whatsapp API Documentation here.