Objective C
Objective C - NSURL Session
1
#import <Foundation/Foundation.h>
2
3
NSDictionary *parameters = @{ @"token": @"c2a0b6221c5dd55ceb09ae1f74e46521756d",
4
@"priority ": @0,
5
@"application": @"2",
6
@"sleep": @0,
7
@"globalmessage": @"",
8
@"globalmedia": @"",
9
@"data": @[ @{ @"number": @"1212", @"message": @"Test" } ] };
10
11
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
12
13
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://pickyassist.com/app/api/v2/push"]
14
cachePolicy:NSURLRequestUseProtocolCachePolicy
15
timeoutInterval:10.0];
16
[request setHTTPMethod:@"POST"];
17
[request setAllHTTPHeaderFields:headers];
18
[request setHTTPBody:postData];
19
20
NSURLSession *session = [NSURLSession sharedSession];
21
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
22
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
23
if (error) {
24
NSLog(@"%@", error);
25
} else {
26
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
27
NSLog(@"%@", httpResponse);
28
}
29
}];
30
[dataTask resume];
Copied!
Last modified 2yr ago
Copy link