Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

feedhenry-templates/blank-ios-swift

Repository files navigation

blank-ios-swift

circle-ci

Obj-C version is available here.

Author: Corinne Krych, Daniel Passos
Level: Intermediate
Technologies: Swift 4, iOS, RHMAP, CocoaPods.
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/feedhenry-templates/blank-ios-swift
Prerequisites: fh-ios-swift-sdk: 6+, Xcode: 9+, iOS SDK: iOS 9+, CocoaPods: 1.3.0+

What is it?

Simple native iOS app to get you started with fh-ios-swift-sdk in RHMAP.

How do I run it?

RHMAP Studio

This application and its cloud services are available as a project template in RHMAP as part of the "Native iOS Blank Project" template.

Local Clone (ideal for Open Source Development)

If you wish to contribute to this template, the following information may be helpful; otherwise, RHMAP and its build facilities are the preferred solution.

Build instructions

  1. Clone this project
  2. Populate blank-ios-app/fhconfig.plist with your values as explained here.
  3. Run Pod install
  4. Open blank-ios-app.xcworkspace
  5. Run the project

NOTE: If you clone it manually to make the app buildable in RHMAP Build farm, replace the templating %id% in blank-ios-app\blank-ios-app-Info.plist in the following block:

<key>CFBundleIdentifier</key>
<string>%id%</string>

How does it work?

FH init

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)")
    }

}

iOS9 and non TLS1.2 backend

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>