Challenge Overview
INTRODUCTION
This is one of several challenges to build a mobile app for communicating with the REST services built out in the previous Baton Rouge challenges. In this challenge we'll be focusing on Setting up moble app project and implementing the app Login screen using Authorization REST service and parsing JSON responses to get API Key from successful authorization call.
All submitters passing review on this developer challenge will also earn the Swift/iOS Ready Show Your Skills badge at the completion of the challenge. Ordinarily, this badge can only be earned by passing one of the peer-reviewed Show Your Skills challenges. During Swiftoberfest, certain challenges have been identified as [Swift/iOS Ready] which let you earn your badge while competing in real-world challenges, too!
The framework built in this challenge will be used as the basis for building out communications with the remaining services. The framework should be built using Swift 2 and Xcode 7. It should include the following classes/functionality:
DETAILED REQUIREMENTS
REST Singleton
Create a REST singleton class for communicating with the services. The singleton should use NSURLSession and its delegate methods to do service requests. Network connectivity should be checked before attempting any network communications. Any errors should be handled with Swift 2 Error handling do/try/catch.
- Use shared REST API available Base URL: https://alma-grower.herokuapp.com/aps/1.0
- The singleton should have the following methods:
- func requestAuthorizationWithEmail(email: NSString, andPin pin: NSString, withDelegate delegate: RESTDelegate)
- This method will do a PUT to /alma-grower.herokuapp.com/aps/1.0/authorize to request an API KEY. It will perform delegate callbacks on success or failure of the call.
RESTDelegate Protocol
- The RESTDelegate protocol should implement the following authorization methods:
- func authorizationPassedWithKey(key: NSString)
- Successful requests will call this delegate method and return the APSKEY value.
- func authorizationFailedWithError(error: NSError)
- Failed requests will call this delegate method and return an error object with details.
Sample curl command to call authorization API to get API KEY: curl --request PUT --header "Content-Type: application/x-www-form-urlencoded" --data-binary "username=user%40email.com&password=pass1234" 'https://alma-grower.herokuapp.com/aps/1.0/authorize'
Here is backup REST URL: https://alma-grower-dev1.herokuapp.com
In the case when this REST API URL not available in some regions (IP blocking etc) we included the Node.js api server code with this challenge resources. It is simple to deploy on Heroku or other platform to ahve your own REST service to develop.
Mobile App Requirements
- Create Swift project as initial setup for this challenge, other challenges will be using this as starting point to extend functionality
- Create Initial Login screen based on given design with changes outlined below
- User login call Authorization API to authenticate user and get API KEY
- Store API Key for this app on device to use with all REST calls (keychain or other methods are acceptable)
- Impement methods to get API KEY for setting up REST calls to other methods (Query APIs will become available in chahllenges)
Login Screen Updates
0) Login (0.1 Login.png)
- Remove Plant Quality Control and replace with Alma Growers App
- Set background image on this page using photo login_background.png
- Remove “Remember me”
- Remove “Forget Password?” and instead show Contact XYZ@alma.com for Support (No Self registration or password changes available for this app)
Final Submission Guidelines
SUBMISSION GUIDELINES
- Swift 2 Xcode 7 project with well commented code
- Target devices: iPhone 6, 6S, 6 Plus and iPhone 5/S
- Code must compile against iOS SDK 9.0 with a minimal deployment target of iOS 8.0
- Upload all source projects as a zip
- Provide a video overview of your submission
SETUP
- Send an email to takumi3t9 and request to be added to the GitLabs Project Almasato team if you’re not already a member. Once added to the team fork the repository and make a merge request targeting this branch once the submission phase has completed.
- Base URL for API calls is https://alma-grower.herokuapp.com/aps/1.0/