Skip to content

Commit

Permalink
Add life hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
zenangst committed Nov 11, 2015
1 parent fad6d5a commit 88119a0
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,59 @@ func application(app: UIApplication,
}
```

Setting it up this way would mean that
you could open any view from a push notification depending on the contents of the payload.
Preferably you would add your own global function that you use for internal navigation.

#### Compass life hacks

##### Tip 1. NavigationHandler.swift
You could have multiple handlers depending on if a user is logged in or not.
```swift
import UIKit
import Compass

struct NavigationHandler {
static func routePreLogin(route: String, arguments: [String: String], navigationController: UINavigationController) {
let currentController = navigationController.topViewController

This comment has been minimized.

Copy link
@vadymmarkov

vadymmarkov Nov 11, 2015

Contributor

Do we need it?

This comment has been minimized.

Copy link
@zenangst

zenangst Nov 11, 2015

Author Contributor

Removed :)

switch route {
case "forgotpassword:{username}":
let forgotPasswordController = ForgotPasswordController(title: arguments["{username}"])
navigationController?.pushViewController(loginController,
animated: true)
default: break
}
}

static func routePostLogin(route: String, arguments: [String: String], navigationController: UINavigationController) {
let currentController = navigationController.topViewController
switch route {
case "profile:{username}":
let profileController = profileController(title: arguments["{username}"])

This comment has been minimized.

Copy link
@vadymmarkov

vadymmarkov Nov 11, 2015

Contributor

ProfileController

This comment has been minimized.

Copy link
@zenangst

zenangst Nov 11, 2015

Author Contributor

Fixed

navigationController?.pushViewController(profileController,
animated: true)
case "logout":
AppDelegate.logout()
default: break
}
}
}
```

##### Tip 2. Compass.swift
Add your own global function to easily navigate internally
``` swift
import Compass

public func navigate(urn: String) {
let stringURL = "\(Compass.scheme)\(urn)"
guard let appDelegate = UIApplication.sharedApplication().delegate as? ApplicationDelegate,
url = NSURL(string: stringURL) else { return }

appDelegate.handleURL(url)
}
```

## Installation

**Compass** is available through [CocoaPods](http://cocoapods.org). To install
Expand Down

0 comments on commit 88119a0

Please sign in to comment.