TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | Custom |
ReleasedLast Release | Aug 2016 |
SPMSupports SPM | ✗ |
Maintained by Kyle Browning.
Depends on: | |
Alamofire | >= 0 |
SwiftyJSON | >= 0 |
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 Alamofire. It combines the most used commands to communicate with Drupal and handles session managment for you.
DIOS Version | Drupal Version | Min iOS Target | Notes |
---|---|---|---|
4.x | Drupal 8 (Swift) | iOS 9.0 | |
3.x | Drupal 8 (Obj-C) | iOS 7.0 | |
2.x | Drupal 6-7 (Obj-C) | iOS 5.0 | Requires Services module |
At its core the Drupal iOS SDK is designed to handle everything Drupal Core supports out of the box. Since 8.x is in its infancy, more and more features will come available as Drupal aims to improve its API capabilities.
In the future this project will have more robust features that make working with Drupal from a Swift perspective easier such as:
Create a pod file with (this will keep you on the 4.0 releases which is Drupal 8 specific)
pod 'DIOS', '~> 4.0'
Then run
pod install
dios.plist
diosurlkey
to point to your domainThe code below will give you access to the baseline of features for communicating to a Drupal site.
//Create an instance to use.
let dios = DIOS.sharedInstance
This will log you into the site.
//set Username and password
dios.setUserNameAndPassword("kylebrowning", password: "password")
//we need an entity manager instance
let em = DIOSEntity()
let em = DIOSEntity()
//Get Node 36
em.get("node", entityId: "36") { (success, response, json, error) in
if (success) {
print(json)
} else {
print(error)
}
}
//build our node body
let body = [
"type": [
[
"target_id": "article"
]
],
"title": [
[
"value": "Hello World"
]
],
"body": [
[
"value": "How are you?"
]
]
]
//Create a new node.
em.post("node", params: body) { (success, response, json, error) in
if (success) {
print(response)
} else {
print(error)
}
}
//Update an existing node
em.patch("node", entityId: "36", params: body) { (success, response, json, error) in
if (success) {
//Extra error checking, but its not needed
if (response!.response?.statusCode == 201) {
print(json)
}
} else {
print(error)
}
}
//Delete an existing node
em.delete("node", entityId: "26") { (success, response, json, error) in
if (success) {
print(response)
} else {
print(error)
}
}