Swift version is available here.
Author: Corinne Krych
Level: Intermediate
Technologies: Objective-C, iOS, RHMAP, CocoaPods.
Summary: A demonstration of how to get started with remote cloud call in RHMAP.
Community Project : Feed Henry
Target Product: RHMAP
Product Versions: RHMAP 3.7.0+
Source: https://github.com/feedhenry-templates/helloworld-ios
Prerequisites: fh-ios-sdk : 3.+, Xcode : 8+, iOS SDK : iOS8+, CocoaPods 1.0.1+
Simple native iOS app to test your remote cloud connection in RHMAP. Its server side companion app: HelloWorld Cloud App. This template app demos how to intialize a cloud call and make calls to cloud endpoints. The app uses fh-ios-sdk.
If you do not have access to a RHMAP instance, you can sign up for a free instance at https://openshift.feedhenry.com/.
This application and its cloud services are available as a project template in RHMAP as part of the "Native iOS Hello World Project" template.
If you wish to contribute to this template, the following information may be helpful; otherwise, RHMAP and its build facilities are the preferred solution.
- Clone this project
- Populate
helloworld-ios-app/fhconfig.plist
with your values as explained on section 2.1.4. Setup. - Run
pod install
- Open helloworld-ios-app.xcworkspace
- Run the project
In helloworld-ios-app/HomeViewController.m
the FH.init call is done:
- (void)viewDidLoad {
// Initialized cloud connection
[FH initWithSuccess:^(FHResponse *response) { // [1]
// Do you other calls to the cloud. // [2]
} AndFailure:^(FHResponse *response) {
// Log an error // [3]
}];
}
[1] Initialize the cloud connection.
[2] On successfull callback, you are ready to do other calls.
[3] Log an eror.
In helloworld-ios-app/HomeViewController.m
the FH.init call is done:
- (IBAction)cloudCall:(id)sender {
NSDictionary *args = [NSDictionary dictionaryWithObject:name.text forKey:@"hello"];
FHCloudRequest *req = (FHCloudRequest *) [FH buildCloudRequest:@"/hello" WithMethod:@"POST" AndHeaders:nil AndArgs:args]; // [1]
[req execAsyncWithSuccess:^(FHResponse * res) { // [2]
// Response
} AndFailure:^(FHResponse * res){
// Errors
}];
}
[1] Create a cloud request specifying endpoint and its arguments.
[2] Make asynchronous call with its success and error callbacks.
If your RHMAP is depoyed without TLS1.2 support, open as source helloworld-ios-app/helloworld-ios-app-Info.plist
uncomment the exception lines:
<!--
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
-->