Skip to content

Commit

Permalink
Structured demo workbook into same structure as file system
Browse files Browse the repository at this point in the history
Removed commented out code
Ensured all demos work with latest SDK
Removed framework from Example folder, and added README.md instructing users to download the latest release themselves.
  • Loading branch information
Andy Johns committed Dec 19, 2017
1 parent 5e6a6af commit fa2dac0
Show file tree
Hide file tree
Showing 45 changed files with 178 additions and 492 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ DerivedData
## AppCode files to ignore
.idea/

## Don't commit the framework in Examples
Examples/Frameworks/*.framework
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import UIKit
import PredixSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -8,19 +7,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

// set trace logging for demo
// Logger.shared.loggerLevel = .trace
//
// if (PredixMobilityConfiguration.serverEndpointURL?.host ?? "my_predix_endpoint") == "my_predix_endpoint" {
// let alert = UIAlertController(title: "Configuration Required", message: "This demo requires the server url, and client id/secret to be populated in the project's Info.plist file.", preferredStyle: .alert)
//
// DispatchQueue.main.async {
// self.window?.rootViewController?.present(alert, animated: true, completion: nil)
// }
// return false
// }

return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ class ViewController: UIViewController {
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var signInButton: UIButton!
@IBOutlet weak var statusLabel: UILabel!

fileprivate var credentialProvider: AuthenticationCredentialsProvider?
fileprivate var authenticationManager: AuthenticationManager?

override func viewDidLoad() {
super.viewDidLoad()

//Creates an authentication manager configuration configured for your UAA instance. The baseURL, clientId and clientSecret can also be defined in your info.plist if you wish but for simplicity I've added them to the config below.
var configuration = AuthenticationManagerConfiguration()
configuration.baseURL = URL(string: "https://predixsdkforiosexampleuaa.predix-uaa.run.aws-usw02-pr.ice.predix.io")
configuration.clientId = "NativeClient"
configuration.clientSecret = "test123"

//Create an online handler so that we can tell the authentication manager we want to authenticate online
let onlineHandler = UAAServiceAuthenticationHandler()
onlineHandler.authenticationServiceDelegate = self

//Create an authentication manager with our UAA configuration, set UAA as our authorization source, set the online handler so that the manager knows we want to autenticate online
authenticationManager = AuthenticationManager(configuration: configuration)
authenticationManager?.authorizationHandler = UAAAuthorizationHandler()
authenticationManager?.onlineAuthenticationHandler = onlineHandler

//Tell authentication manager we are ready to authenticate, once we call authenticate it will call our delegate with the credential provider
authenticationManager?.authenticate { status in
self.updateStatusText(message: "Authentication \(status)")
}

self.updateStatusText(message: "Authentication Started")
}

Expand All @@ -41,7 +41,7 @@ class ViewController: UIViewController {
//Give the username and password to the credential provider
credentialProvider?(self.usernameTextField.text ?? "", self.passwordTextField.text ?? "")
}

fileprivate func updateStatusText(message: String) {
DispatchQueue.main.async {
self.statusLabel.text = message
Expand All @@ -53,11 +53,11 @@ extension ViewController: ServiceBasedAuthenticationHandlerDelegate {
public func authenticationHandler(_ authenticationHandler: PredixSDK.AuthenticationHandler, didFailWithError error: Error) {
updateStatusText(message: "Authentication failed: \(error)")
}

public func authenticationHandlerProvidedCredentialsWereInvalid(_ authenticationHandler: AuthenticationHandler) {
updateStatusText(message: "Invalid username and/or password")
}

public func authenticationHandler(_ authenticationHandler: AuthenticationHandler, provideCredentialsWithCompletionHandler completionHandler: @escaping AuthenticationCredentialsProvider) {
//Set our credential provider so that when we sign in we can pass the username and password from the text fields to the authentication manager
credentialProvider = completionHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
//
// AppDelegate.swift
// PredixMobileSVCDemo
//
// Created by Johns, Andy (GE Corporate) on 7/28/17.
// Copyright © 2017 GE. All rights reserved.
//

import UIKit
import PredixSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
var checkAuthRedirect: ((URL) -> (Bool))?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class ViewController: UIViewController {

// Associate a RefreshAuthenticationHandler -- in this case our refresh handler is design to work with UAA.
handler.refreshAuthenticationHandler = UAARefreshAuthenticationHandler()

//associate our OnlineAuthenticationHandler with the AuthenticationManager
manager.onlineAuthenticationHandler = handler
handler.manager = manager

//associate an AuthorizationHandler with the AuthenticationManager
manager.authorizationHandler = UAAAuthorizationHandler()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import UIKit
import PredixSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -8,22 +7,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var checkAuthRedirect: ((URL) -> (Bool))?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// //set trace logging for demo
Logger.shared.loggerLevel = .trace
//
// if (PredixMobilityConfiguration.serverEndpointURL?.host ?? "my_predix_endpoint") == "my_predix_endpoint" {
// let alert = UIAlertController(title: "Configuration Required", message: "This demo requires the server url, and client id/secret to be populated in the project's Info.plist file.", preferredStyle: .alert)
//
// DispatchQueue.main.async {
// self.window?.rootViewController?.present(alert, animated: true, completion: nil)
// }
// return false
// }

// Override point for customization after application launch.
return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {

// iOS will call this method when a URL matching our login_redirect is detected.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<key>CFBundleURLSchemes</key>
<array>
<string>predixsdk</string>
</array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ViewController: UIViewController {
}

//BrowserBasedAuthenticationHandlerDelegate methods
extension ViewController : BrowserBasedAuthenticationHandlerDelegate {
extension ViewController: BrowserBasedAuthenticationHandlerDelegate {

func authenticationHandler(_ authenticationHandler: AuthenticationHandler, loadWebAuthenticationUrl url: URL, shouldFollowRedirect: @escaping (URL) -> (Bool)) {

Expand All @@ -110,8 +110,8 @@ extension ViewController : BrowserBasedAuthenticationHandlerDelegate {
(UIApplication.shared.delegate as? AppDelegate)?.checkAuthRedirect = shouldFollowRedirect
self.createAndShowSVC(url)
}
public func authenticationHandler(_ authenticationHandler: PredixSDK.AuthenticationHandler, willStoreQueryParameters queryStringInfo: [String : String]) -> [String : Any] {

public func authenticationHandler(_ authenticationHandler: PredixSDK.AuthenticationHandler, willStoreQueryParameters queryStringInfo: [String: String]) -> [String: Any] {
print("did we get here?")
return queryStringInfo
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import UIKit
import PredixSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//set trace logging for demo
// Logger.shared.loggerLevel = .trace
// if (PredixMobilityConfiguration.serverEndpointURL?.host ?? "my_predix_endpoint") == "my_predix_endpoint" {
// let alert = UIAlertController(title: "Configuration Required", message: "This demo requires the server url, and client id/secret to be populated in the project's Info.plist file.", preferredStyle: .alert)
//
// DispatchQueue.main.async {
// self.window?.rootViewController?.present(alert, animated: true, completion: nil)
// }
// return false
// }

// Override point for customization after application launch.
return true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina5_9" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -19,11 +19,11 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7fb-za-j9D">
<rect key="frame" x="16" y="282" width="343" height="60"/>
<rect key="frame" x="16" y="306" width="343" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="C2d-uq-DMV"/>
</constraints>
Expand All @@ -32,7 +32,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oCa-kL-Afh">
<rect key="frame" x="16" y="207" width="343" height="60"/>
<rect key="frame" x="16" y="231" width="343" height="60"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="60" id="pmU-6T-rCA"/>
</constraints>
Expand All @@ -41,7 +41,7 @@
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="ysQ-QG-RjC">
<rect key="frame" x="131" y="160" width="112" height="32"/>
<rect key="frame" x="131" y="184" width="112" height="32"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vZr-wW-AGF">
<rect key="frame" x="0.0" y="0.0" width="51" height="32"/>
Expand All @@ -62,7 +62,7 @@
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="UAA Web Login Example" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PaI-Gy-DRW">
<rect key="frame" x="16" y="20" width="343" height="34"/>
<rect key="frame" x="16" y="44" width="343" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="33.5" id="Egv-BL-kER"/>
</constraints>
Expand All @@ -71,7 +71,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z9t-XS-lhO">
<rect key="frame" x="16" y="62" width="343" height="86.5"/>
<rect key="frame" x="16" y="86" width="343" height="86.333333333333314"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="20.5" id="93b-AO-LrV"/>
</constraints>
Expand All @@ -83,7 +83,6 @@
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="z9t-XS-lhO" firstAttribute="top" secondItem="PaI-Gy-DRW" secondAttribute="bottom" constant="7.5" id="Afa-Yw-QCv"/>
<constraint firstItem="z9t-XS-lhO" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="B1d-lT-JlA"/>
<constraint firstItem="oCa-kL-Afh" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="B66-MX-XVC"/>
<constraint firstItem="7fb-za-j9D" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="Eq7-rt-imJ"/>
Expand Down Expand Up @@ -119,20 +118,20 @@
<viewControllerLayoutGuide type="bottom" id="NDV-VM-5Pu"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kJk-wp-QpV">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z3J-rB-T6Q">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="16" y="44" width="343" height="734"/>
<color key="backgroundColor" red="0.80392156859999997" green="0.82745098039999998" blue="0.84313725490000002" alpha="1" colorSpace="calibratedRGB"/>
</webView>
</subviews>
<color key="backgroundColor" red="0.80392156859999997" green="0.82745098039999998" blue="0.84313725490000002" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="z3J-rB-T6Q" firstAttribute="leading" secondItem="kJk-wp-QpV" secondAttribute="leading" id="5Jh-Xx-OHv"/>
<constraint firstItem="NDV-VM-5Pu" firstAttribute="top" secondItem="z3J-rB-T6Q" secondAttribute="bottom" id="87D-9u-pkh"/>
<constraint firstItem="z3J-rB-T6Q" firstAttribute="top" secondItem="UTc-zo-4Ig" secondAttribute="bottom" constant="-20" id="fbM-uC-gO0"/>
<constraint firstAttribute="trailing" secondItem="z3J-rB-T6Q" secondAttribute="trailing" id="g6O-bH-HPT"/>
<constraint firstItem="z3J-rB-T6Q" firstAttribute="top" secondItem="UTc-zo-4Ig" secondAttribute="bottom" id="70y-wV-6oQ"/>
<constraint firstAttribute="trailingMargin" secondItem="z3J-rB-T6Q" secondAttribute="trailing" id="Lh2-N0-LRp"/>
<constraint firstItem="z3J-rB-T6Q" firstAttribute="leading" secondItem="kJk-wp-QpV" secondAttribute="leadingMargin" id="SgB-LE-xdj"/>
<constraint firstItem="NDV-VM-5Pu" firstAttribute="top" secondItem="z3J-rB-T6Q" secondAttribute="bottom" id="oQW-l7-Ueh"/>
</constraints>
</view>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LoginViewController: UIViewController {
}
}

extension LoginViewController : BrowserBasedAuthenticationHandlerDelegate {
extension LoginViewController: BrowserBasedAuthenticationHandlerDelegate {
func authenticationHandler(_ authenticationHandler: AuthenticationHandler, loadWebAuthenticationUrl url: URL, shouldFollowRedirect: @escaping (URL) -> (Bool)) {

self.webView.loadRequest(URLRequest(url: url))
Expand Down
Loading

0 comments on commit fa2dac0

Please sign in to comment.