Notes on using the Drupal PhoneGap Plugin for iOS
- Tested with PhoneGap 1.1.0 and XCode 4.2
- Create a new PhoneGap Application from XCode 4.2 to get started
- Add my fork of the ASIHTTPRequest to your XCode Project (but only the Classes folder). You can add it as a submodule -
git submodule add git://github.com/jefflinwood/asi-http-request.git DrupalPhoneGapApp/Classes/asi-http-request - Add my fork of the Drupal IOS SDK to your XCode Project. You can add it as a submodule -
git submodule add git://github.com/jefflinwood/drupal-ios-sdk.git DrupalPhoneGapApp/Classes/drupal-ios-sdk - Add
libz.1.2.5as a dynamic library for your app - Add
CFNetworkas a Framework for your app - Add
DrupalPlugin.mandDrupalPlugin.hfrom this project to your XCode PhoneGap project's plugins directory - Add the javascript file to your XCode project's www directory
- Reference the javascript file in your index.html
<script type="text/javascript" charset="utf-8" src="drupal-phonegap.js"></script>
- Add
DrupalPluginto yourPhoneGap.plistconfiguration file's list of plugins. Select the last plugin in the list (there are 14 out of the box) and then click the Plus sign. - Type "DrupalPlugin" into both boxes of the new plugin and save the file.
- You will need to edit
DIOSConfig.hto reference your Drupal server's services URL, main URL, and domain - For PhoneGap 1.1.0, you will need to also add that Drupal Server to the list of allowed external hosts by editing the ExternalHosts property in the PhoneGap.plist file under Supporting Files
- Start using the plugin
//authenticated user
function onDeviceReady()
{
window.plugins.drupal.login("drupaluser", "password", successCallback,failureCallback);
var node = {
title: "Sample Article",
body: {
und: [{
value: "Sample Body"
}]
},
type: 'article',
language: 'und'
};
window.plugins.drupal.nodeSave(node,articleSaveSuccess,failureCallback);
window.plugins.drupal.logout(successCallback,failureCallback);
}
//anonymous user
function onDeviceReady()
{
window.plugins.drupal.openAnonymousSession(successCallback,failureCallback);
window.plugins.drupal.viewGet("frontpage",frontPageSuccess,failureCallback);
}-
Currently the plugin only supports a connection to one Drupal site per app
-
Currently supported methods from Drupal Services:
user.loginuser.logoutsystem.connectnode.get(individual node and node index)node.savenode.deleteviews.getfile.save
-
Adding more methods should be pretty easy.