04 Feb 2016

Simple iOS Registration App Using the StarterAPI

iOS 0 Comment

iOS

iOS is a mobile operating system developed and distributed by Apple Inc. The operating system is based on the Macintosh OS X. iOS is designed for use with Apple’s multi-touch devices, iPhone, iPad, and iPod. This system responds to various gestures like  pinching, tapping and swiping.

Xcode

Xcode is the IDE for developing iOS and Mac apps, and the only one officially supported by Apple.

To install, simply download Xcode on the Mac App Store. It comes with the newest SDK and simulators, and you can install more stuff under Preferences > Downloads.

Xcode-download-1

Environment Setup

  • Download Xcode from App Store app on your Mac.
  • Xcode is downloaded into your /Applications directory.

Design and Implementation

1) AppDelegate- The Application Delegate is the class that receives application-level messages, including the applicationDidFinishLaunching message that’s most commonly used to initiate the creation of other views.

2) Storyboard- A storyboard is a visual representation of the app’s user interface, showing screens of content and the transitions between them.

3) ViewController-  View controllers are the vital link between an app’s data and its visual appearance. Whenever an iOS app displays a user interface, the displayed content is managed by a view controller or a group of view controllers coordinating with each other. Therefore, view controllers provide the skeletal framework on which you build your apps.

 Add a ViewController in Storyboard and Connect to Swift Class

– Open Main.storyboard, and select ViewController and drag it to the Storyboard

AddVc

–  Create a new swift file, File -> New -> file -> Select iOS -> Swift file. Then give it a name and it’s created.

AddFile

–  Give the swift class name for Created ViewController

ConnectVCToSwiftClass

Import iOS Starter App to Xcode

  • Open Xcode
  • Select -> Check out an existing project

OpenXcode

  • Enter repository location as git@scm.nbostech.com:starter-apps/starter-app-ios.git

Checkout1

  • Check out repository

Edit Bundle ID

Your bundle ID must be registered with Apple and be unique to your app. The bundle identifier is the unique string that identifies your application to the system.

  • In the project navigator, select the project(1) and your target(2) to display the project editor.
  • Click Info(3)
  • Enter the bundle ID in the Value column of the “Bundle identifier” row.(4)

 

BundleId

– Change base Url and client id  in Targets/info -> UrlSettings -> baseUrl

ChangeAppSettings

API  Modules

  1. Auth API
    1. Login
    2. Logout
    3. Change password
    4. Forgot password
    5. Refresh Token
  2. Users API
    1. SignUp
    2. Get Profile
    3. Update Profile
  3. Media API
    1. Get Media
    2. Upload Media
  4. SocialAPI
    1. ${social} login
    2. ${social} Connect

Models

  1. NewMemberApiModel
  2. MemberApiModel
  3. TokenApiModel
  4. SocialApiModel
  5. MediaApiModel
  6. MediaFileDetailsApiModel
  7. MessagesApiModel
  8. ValidationMessagesApiModel

Run iOS app 

  • Select iPhone 6 (select any one) in the Scheme pop-up menu in the Xcode toolbar.
  • Click the Run button (or press Command-R), located in the top-left corner of the Xcode toolbar.
  • You can watch the build process in the activity viewer of the Xcode toolbar.

RunIOSApp

 

Login

iOS_starter_Login

 

 

Input Output
[POST] http://localhost:8080/starter-app-rest-grails/api/v0/auth/login  [POST] http://localhost:8080/starter-app-rest-grails/api/v0/auth/login
{
“clientId”:”String”,
“accessToken”:”String”,
“expiresIn”:0
}
{

“member”: {
“id”: 0,
“email”: “string”,
“firstName”: “string”,
“lastName”: “string”,
“phone”: 0,
“description”: “string”,
“socialAccounts”: [
{
“id”: 0,
“email”: “string”,
“socialType”: “string”,
“imageUrl”: “string”
}
]
},

“token”: {
“scope”: “string”,
“expires_in”: 0,
“token_type”: “string”,
“refresh_token”: “string”,
“access_token”: “string”
}

}

Sign up

iOS_starter_SignUp

 

Input Output
[POST] http://localhost:8080/starter-app-rest-grails/api/v0/users/signup
 {

“clientId”: “string”,
“username”: “string”,
“email”: “string”,
“password”: “string”,
“firstName”: “string”,
“lastName”: “string”
}

{

“member”: {
“id”: 0,
“email”: “string”,
“firstName”: “string”,
“lastName”: “string”,
“phone”: 0,
“description”: “string”,
“socialAccounts”: [
{
“id”: 0,
“email”: “string”,
“socialType”: “string”,
“imageUrl”: “string”
}
]
},

“token”: {
“scope”: “string”,
“expires_in”: 0,
“token_type”: “string”,
“refresh_token”: “string”,
“access_token”: “string”
}

}

 

Profile

iOS Simulator Screen Shot Sep 3, 2015, 1.18.13 PM

Input Output
[GET] http://localhost:8080/starter-app-rest-grails/api/v0/users/{userId}
 

{

“id”: 0,
“email”: “string”,
“firstName”: “string”,
“lastName”: “string”,
“phone”: 0,
“description”: “string”,
“socialAccounts”: [
{
“id”: 0,
“email”: “string”,
“socialType”: “string”,
“imageUrl”: “string”
}
]
}

Change Password

iOS Simulator Screen Shot Sep 3, 2015, 1.18.20 PM

Input Output
[POST] http://localhost:8080/starter-app-rest-grails/api/v0/auth/changepassword
   {
“password”:”string”,
“newpassword”:”string”}
{
message = “string”;
messageCode = “string”;
}

Social Connects

iOS Simulator Screen Shot Sep 3, 2015, 1.18.16 PM

Input Output
[POST] http://localhost:8080/starter-app-rest-grails/api/v0/auth/social/${socialId}/connect
   {
“clientId”:”string”,
“accessToken”:”string”,
“expiresIn”:0
}
 

{
message = “string”;
messageCode = “string”;
}