Skip to content

Instantly share code, notes, and snippets.

@sendpulse
Last active December 31, 2023 19:14
Show Gist options
  • Save sendpulse/95a758d2930397567d17 to your computer and use it in GitHub Desktop.
Save sendpulse/95a758d2930397567d17 to your computer and use it in GitHub Desktop.
SendPulse REST API Usage Example for Objective-C
#import "Sendpulse.h" // SendPulse's Obj-C Library https://github.com/sendpulse/sendpulse-rest-api-objective-c
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomethingWithTheData:) name:@"SendPulseNotification" object:nil];
Sendpulse* sendpulse = [[Sendpulse alloc] initWithUserIdandSecret:userId :secret];
NSDictionary *from = [NSDictionary dictionaryWithObjectsAndKeys:@"Your Sender Name", @"name", @"[email protected]", @"email", nil];
NSMutableArray* to = [[NSMutableArray alloc] initWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:@"Subscriber's name", @"name", @"[email protected]", @"email", nil], nil];
NSMutableDictionary *emaildata = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"<b>Your email content goes here</b>", @"html", @"Your email text version goes here", @"text",@"Testing SendPulse API",@"subject",from,@"from",to,@"to", nil];
[sendpulse smtpSendMail:emaildata];
}
- (void)doSomethingWithTheData:(NSNotification *)notification {
NSMutableDictionary * result = [[notification userInfo] objectForKey:@"SendPulseData"];
NSLog(@"Result: %@",result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment