built by Kyle Browning
The Drupal iOS SDK is a standard set of libraries for communicating to Drupal from any iOS device. Its extremely simple, and is basically a wrapper for AFNetworking. It combines the most used commands to communicate with Drupal and handles session managment for you(but it doesnt store passwords or persist CSRF/oAUTH tokens, you must do that(at least yet :))
Create a pod file with (this will keep you on the 3.0 releases which is Drupal 8 specific)
pod 'drupal-ios-sdk', '~> 3.0'
Then run
pod install
DIOS Version | Drupal Version | Min iOS Target | Notes |
---|---|---|---|
3.x | Drupal 8 | iOS 7.0 | |
2.x | Drupal 6-7 | iOS 5.0 | Requires Services module |
In Drupal 8 things are a bit different, but much easier.
####First steps
DIOSSession *sharedSession = [DIOSSession sharedSession];
[sharedSession setBaseURL:[NSURL URLWithString:@"http://d8"]];
[sharedSession setBasicAuthCredsWithUsername:@"admin" andPassword:@"pass"];
Currently 3.x only supports basic auth but will support oAuth soon
//create new user
NSDictionary *user = @{@"name":@[@{@"value":@"username"}],@"mail":@[@{@"value":@"[email protected]"}],@"pass":@[@{@"value":@"passw0rd"}]};
[DIOSUser createUserWithParams:user success:nil failure:nil];
//update existing node
NSDictionary *node = @{@"uid":@[@{@"target_id":@"1"} ],@"body":@[@{@"value":@"Updated BOdy ",@"format":@"full_html"}],@"title":@[@{@"value":@"Updated Title"}]};
[DIOSNode patchNodeWithID:@"12" params:node type:@"page" success:nil failure:nil];
//create new comment
NSDictionary *parameters = @{@"subject":@[@{@"value":@"comment title"}],@"comment_body":@[@{@"value":@"a new body",@"format":@"basic_html"}]};
[DIOSComment createCommentWithParams:parameters relationID:@"7" type:@"comment" success:nil failure:nil];
//get a user
[DIOSUser getUserWithID:@"1" success:nil failure:nil];
//delete a node
[DIOSNode deleteNodeWithID:@"13" success:nil failure:nil];
Coming soon
If you are getting Forbidden, you probably havnt setup your permissions.
Checkout the Issue queue, or email me Email [email protected]