Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Add the appcelerator-sdk-ios-<VERSION>/Appcelerator.framework folder to your project:
    • For Xcode 5 projects, drag the Appcelerator.framework folder to your project's Frameworks folder, making sure Copy items into destination group's folder is checked, and click Finish.
    • For Xcode 6 projects, drag the Appcelerator.framework folder to the project's root folder, making sure Copy Items if Needed is checked, and click Finish.
  2. On your project's Build Phases tab, expand the Link Binary With Libraries section and add the libsqlite3.dylib and libz.dylib frameworks.
  3. On your project's Build Settings tab, click All in the top-left corner, then expand the Linking section.
  4. In the Other Linker Flags field, enter -ObjC.
     
  5. Import Appcelerator.h into your application delegate:

    Code Block
    #import <Appcelerator/Appcelerator.h>
  6. Lastly, initialize Platform services by calling the [APSServiceManager enableWithAppKey] method, replacing << YOUR APP KEY >> with the service key generated by Dashboard when you created your application. (See View Application Information for how to locate your application key.)

    Code Block
    [[APSServiceManager sharedInstance] enableWithAppKey:@"<<YOUR APP KEY>>"];

...

The iOS framework includes a collection of classes whose methods map to individual REST API method endpoints. For example, the [APSUsers create] method corresponds to the /users/create.json method endpoint.

Alternatively, you can use the generic [APSCloud sendRequest] method to make REST calls directly against the Cloud APIs. For more information, see Making Generic REST API Calls.

Building Request Parameters

...

Code Block
// Create dictionary of parameters to be passed with the request
NSDictionary *data = @{
   @"login": self.usernameField.text,
   @"password": self.passwordField.text
};

[APSUsers login:data withBlock:^(APSResponse *e) {
    // The block will be called on the thread the request was started on
    if (e.success) {
        NSString *userId = [[[e.response objectForKey:@"users"] objectAtIndex:0] objectForKey:@"id"];
        NSString *msg = [NSString stringWithFormat:@"Logged in! You are now logged in as %@", userId];
        [[[UIAlertView alloc] initWithTitle:@"Success" message:msg delegate:nil cancelButtonTitle:@"OK" 
        otherButtonTitles:nil] show];
    } else {
        [Utils handleErrorInResponse:e];
    }
}];

...

Code Block
NSDictionary *data = @{
    @"photo": self.photoData,
    @"photo_sync_sizes[]": @"small_240"
};
[APSPhotos create:data withBlock:^(APSResponse *e) {
    // The block will be called on the thread the request was started on
    if (e.success) {
        [[[UIAlertView alloc] initWithTitle:@"Success" message:@"Uploaded!" delegate:nil cancelButtonTitle:@"OK" 
        otherButtonTitles:nil] show];
        self.photoData = nil;
    } else {
        [Utils handleErrorInResponse:e];
    }
    self.createButton.hidden = NO;
} progressBlock:^(float progress, BOOL upload) {
    // The block will be called on the thread the request was started on
    self.progressBar.progress = progress;
}];

...

  • REST API method endpoint relative to "api.cloud.appcelerator.com/v1". Method endpoints are listed in the corresponding entries in the REST API documentation.
  • The HTTP method to use.
  • Data to send with the request.

For example, to create a post, pass the sendRequest() method the following information:

...

The following example calls users/login.json REST method directly and logs the result to the console.

...