Author: Bruno Machado, based on blank-ios-app by Corinne Krych, Daniel Passos
Level: Intermediate
Technologies: Swift 3, iOS, RHMAP, CocoaPods, Alamofire.
Summary: A demonstration of how to get started with RHMAP.
Community Project : Feed Henry
Target Product: RHMAP
Product Versions: RHMAP 3.7.0+
Source: https://github.com/bmachado/demo-rhmap-ios-native-swift
Prerequisites: fh-ios-swift-sdk : 5+, Xcode : 8+, iOS SDK : iOS8+, CocoaPods: 1.1.0+
Simple native iOS app to get you started with fh-ios-swift-sdk in RHMAP.
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 Blank 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
blank-ios-app/fhconfig.plist
with your values as explained here. - Run
Pod install
- Open blank-ios-app.xcworkspace
- Run the project
NOTE: If you clone it manually to make the app buildable in RHMAP Build farm, replace the templating
%id%
inblank-ios-app\blank-ios-app-Info.plist
in the following block:
<key>CFBundleIdentifier</key>
<string>%id%</string>
In blank-ios-app/ViewController.swift
the synchronization loop is started.
override func viewDidLoad() {
super.viewDidLoad()
// FH.init using Swift FH sdk
// trailing closure Swift syntax
FH.init { (resp:Response, error: NSError?) -> Void in
if let error = error {
self.statusLabel.text = "FH init in error"
print("Error: \(error)")
}
self.statusLabel.text = "FH init successful"
print("Response: \(resp.parsedResponse)")
}
}
If your RHMAP is depoyed without TLS1.2 support, open as source blank-ios-app/blank-ios-app-Info.plist.plist
make sure the following line are uncommented:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>