The SDK ZIP file includes an iOS sample project that demonstrates the basic usage of each of the Cloud APIs. To run the sample, register a new application in Dashboard to obtain the necessary service application. You will then copy the key into the imported sample project's application delegate, then run the application.
To import the completed APSCloudExample project:
- In Xcode, open the the
AppDelegate.m, add the code below to your application delegate's
application:didFinishLaunchingWithOptionsmethod, and replace << YOUR APP KEY >> with the application key you copied to your clipboard previously.
Code Block language js
[[APSServiceManager sharedInstance] enableWithAppKey:@"<< YOUR APP KEY >>"];
- Run the application on an iOS device or simulator.
- Create a new user by selecting Users > Create User. Enter a username, password, and password confirmation and then click Create. If the user is created successfully, the following dialog is shown:
- View the newly created user in Dashboard:
- Log into the AMPLIFY Platform.
- Select Dashboard on the Dashboard tile.
- Select your MBS application from the Apps tab.
- Select Manage Data, then click Users in the Manage Data Objects table. You should see the user you created listed in the Users table.
The iOS framework includes a collection of classes whose methods map to individual REST API method endpoints. For example, the APSUsers create method that corresponds to the
/users/create.json method endpoint.
The first parameter of each Cloud API method is a
NSDictionary object that contains the of parameters to send with the request. For example, the APSPhotos show method takes a
photo_id parameter whose value is, naturally, the ID of the photo to show.
The second parameter of each method call is a block that is passed to an APSResponse whose properties contain information about the response. For instance, the
success property contains a boolean indicating if the method call was successful or not; , the
response property returns a JSON-encoded object with the results of the method call.
Note that the block will be called on the thread that on which the request was started on.
Example: APSUsers login call with response handler
Working with push notifications
APSPushNotifications class class lets your application subscribe, send, and receive push notifications. To use the class: