Skip to content

Commit fa2dac0

Browse files
author
Andy Johns
committed
Structured demo workbook into same structure as file system
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.
1 parent 5e6a6af commit fa2dac0

File tree

45 files changed

+178
-492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+178
-492
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ DerivedData
2424
## AppCode files to ignore
2525
.idea/
2626

27+
## Don't commit the framework in Examples
28+
Examples/Frameworks/*.framework

Examples/Authentication/NativeAuthenticationDemo/NativeAuthenticationDemo/AppDelegate.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import UIKit
2-
import PredixSDK
32

43
@UIApplicationMain
54
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -8,19 +7,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
87

98
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
109
// Override point for customization after application launch.
11-
12-
// set trace logging for demo
13-
// Logger.shared.loggerLevel = .trace
14-
//
15-
// if (PredixMobilityConfiguration.serverEndpointURL?.host ?? "my_predix_endpoint") == "my_predix_endpoint" {
16-
// 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)
17-
//
18-
// DispatchQueue.main.async {
19-
// self.window?.rootViewController?.present(alert, animated: true, completion: nil)
20-
// }
21-
// return false
22-
// }
23-
2410
return true
2511
}
2612

Examples/Authentication/NativeAuthenticationDemo/NativeAuthenticationDemo/ViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ class ViewController: UIViewController {
66
@IBOutlet weak var passwordTextField: UITextField!
77
@IBOutlet weak var signInButton: UIButton!
88
@IBOutlet weak var statusLabel: UILabel!
9-
9+
1010
fileprivate var credentialProvider: AuthenticationCredentialsProvider?
1111
fileprivate var authenticationManager: AuthenticationManager?
1212

1313
override func viewDidLoad() {
1414
super.viewDidLoad()
15-
15+
1616
//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.
1717
var configuration = AuthenticationManagerConfiguration()
1818
configuration.baseURL = URL(string: "https://predixsdkforiosexampleuaa.predix-uaa.run.aws-usw02-pr.ice.predix.io")
1919
configuration.clientId = "NativeClient"
2020
configuration.clientSecret = "test123"
21-
21+
2222
//Create an online handler so that we can tell the authentication manager we want to authenticate online
2323
let onlineHandler = UAAServiceAuthenticationHandler()
2424
onlineHandler.authenticationServiceDelegate = self
25-
25+
2626
//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
2727
authenticationManager = AuthenticationManager(configuration: configuration)
2828
authenticationManager?.authorizationHandler = UAAAuthorizationHandler()
2929
authenticationManager?.onlineAuthenticationHandler = onlineHandler
30-
30+
3131
//Tell authentication manager we are ready to authenticate, once we call authenticate it will call our delegate with the credential provider
3232
authenticationManager?.authenticate { status in
3333
self.updateStatusText(message: "Authentication \(status)")
3434
}
35-
35+
3636
self.updateStatusText(message: "Authentication Started")
3737
}
3838

@@ -41,7 +41,7 @@ class ViewController: UIViewController {
4141
//Give the username and password to the credential provider
4242
credentialProvider?(self.usernameTextField.text ?? "", self.passwordTextField.text ?? "")
4343
}
44-
44+
4545
fileprivate func updateStatusText(message: String) {
4646
DispatchQueue.main.async {
4747
self.statusLabel.text = message
@@ -53,11 +53,11 @@ extension ViewController: ServiceBasedAuthenticationHandlerDelegate {
5353
public func authenticationHandler(_ authenticationHandler: PredixSDK.AuthenticationHandler, didFailWithError error: Error) {
5454
updateStatusText(message: "Authentication failed: \(error)")
5555
}
56-
56+
5757
public func authenticationHandlerProvidedCredentialsWereInvalid(_ authenticationHandler: AuthenticationHandler) {
5858
updateStatusText(message: "Invalid username and/or password")
5959
}
60-
60+
6161
public func authenticationHandler(_ authenticationHandler: AuthenticationHandler, provideCredentialsWithCompletionHandler completionHandler: @escaping AuthenticationCredentialsProvider) {
6262
//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
6363
credentialProvider = completionHandler

Examples/Authentication/SFAuthenticationSessionDemo/SFAuthenticationSessionDemo/AppDelegate.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
//
2-
// AppDelegate.swift
3-
// PredixMobileSVCDemo
4-
//
5-
// Created by Johns, Andy (GE Corporate) on 7/28/17.
6-
// Copyright © 2017 GE. All rights reserved.
7-
//
8-
91
import UIKit
10-
import PredixSDK
112

123
@UIApplicationMain
134
class AppDelegate: UIResponder, UIApplicationDelegate {
145

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

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

Examples/Authentication/SFAuthenticationSessionDemo/SFAuthenticationSessionDemo/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class ViewController: UIViewController {
6161

6262
// Associate a RefreshAuthenticationHandler -- in this case our refresh handler is design to work with UAA.
6363
handler.refreshAuthenticationHandler = UAARefreshAuthenticationHandler()
64-
64+
6565
//associate our OnlineAuthenticationHandler with the AuthenticationManager
6666
manager.onlineAuthenticationHandler = handler
6767
handler.manager = manager
68-
68+
6969
//associate an AuthorizationHandler with the AuthenticationManager
7070
manager.authorizationHandler = UAAAuthorizationHandler()
7171

Examples/Authentication/SafariViewControllerDemo/SafariViewControllerDemo/AppDelegate.swift

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import UIKit
2-
import PredixSDK
32

43
@UIApplicationMain
54
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -8,22 +7,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
87
var checkAuthRedirect: ((URL) -> (Bool))?
98

109
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
11-
// //set trace logging for demo
12-
Logger.shared.loggerLevel = .trace
13-
//
14-
// if (PredixMobilityConfiguration.serverEndpointURL?.host ?? "my_predix_endpoint") == "my_predix_endpoint" {
15-
// 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)
16-
//
17-
// DispatchQueue.main.async {
18-
// self.window?.rootViewController?.present(alert, animated: true, completion: nil)
19-
// }
20-
// return false
21-
// }
22-
10+
// Override point for customization after application launch.
2311
return true
2412
}
2513

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

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

Examples/Authentication/SafariViewControllerDemo/SafariViewControllerDemo/Info.plist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
<key>CFBundleURLName</key>
2525
<string></string>
2626
<key>CFBundleURLSchemes</key>
27-
<array>
28-
<key>CFBundleURLSchemes</key>
2927
<array>
3028
<string>predixsdk</string>
3129
</array>

Examples/Authentication/SafariViewControllerDemo/SafariViewControllerDemo/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ViewController: UIViewController {
101101
}
102102

103103
//BrowserBasedAuthenticationHandlerDelegate methods
104-
extension ViewController : BrowserBasedAuthenticationHandlerDelegate {
104+
extension ViewController: BrowserBasedAuthenticationHandlerDelegate {
105105

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

@@ -110,8 +110,8 @@ extension ViewController : BrowserBasedAuthenticationHandlerDelegate {
110110
(UIApplication.shared.delegate as? AppDelegate)?.checkAuthRedirect = shouldFollowRedirect
111111
self.createAndShowSVC(url)
112112
}
113-
114-
public func authenticationHandler(_ authenticationHandler: PredixSDK.AuthenticationHandler, willStoreQueryParameters queryStringInfo: [String : String]) -> [String : Any] {
113+
114+
public func authenticationHandler(_ authenticationHandler: PredixSDK.AuthenticationHandler, willStoreQueryParameters queryStringInfo: [String: String]) -> [String: Any] {
115115
print("did we get here?")
116116
return queryStringInfo
117117
}

Examples/Authentication/UAAWebLoginDemo/UAAWebLoginDemo/AppDelegate.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
import UIKit
2-
import PredixSDK
32

43
@UIApplicationMain
54
class AppDelegate: UIResponder, UIApplicationDelegate {
65

76
var window: UIWindow?
87

98
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
10-
//set trace logging for demo
11-
// Logger.shared.loggerLevel = .trace
12-
// if (PredixMobilityConfiguration.serverEndpointURL?.host ?? "my_predix_endpoint") == "my_predix_endpoint" {
13-
// 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)
14-
//
15-
// DispatchQueue.main.async {
16-
// self.window?.rootViewController?.present(alert, animated: true, completion: nil)
17-
// }
18-
// return false
19-
// }
20-
9+
// Override point for customization after application launch.
2110
return true
2211
}
2312

Examples/Authentication/UAAWebLoginDemo/UAAWebLoginDemo/Base.lproj/Main.storyboard

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
3-
<device id="retina4_7" orientation="portrait">
2+
<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">
3+
<device id="retina5_9" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
99
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -19,11 +19,11 @@
1919
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
2020
</layoutGuides>
2121
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
22-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
22+
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
2323
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2424
<subviews>
2525
<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">
26-
<rect key="frame" x="16" y="282" width="343" height="60"/>
26+
<rect key="frame" x="16" y="306" width="343" height="60"/>
2727
<constraints>
2828
<constraint firstAttribute="height" constant="60" id="C2d-uq-DMV"/>
2929
</constraints>
@@ -32,7 +32,7 @@
3232
<nil key="highlightedColor"/>
3333
</label>
3434
<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">
35-
<rect key="frame" x="16" y="207" width="343" height="60"/>
35+
<rect key="frame" x="16" y="231" width="343" height="60"/>
3636
<constraints>
3737
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="60" id="pmU-6T-rCA"/>
3838
</constraints>
@@ -41,7 +41,7 @@
4141
<nil key="highlightedColor"/>
4242
</label>
4343
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="ysQ-QG-RjC">
44-
<rect key="frame" x="131" y="160" width="112" height="32"/>
44+
<rect key="frame" x="131" y="184" width="112" height="32"/>
4545
<subviews>
4646
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vZr-wW-AGF">
4747
<rect key="frame" x="0.0" y="0.0" width="51" height="32"/>
@@ -62,7 +62,7 @@
6262
</subviews>
6363
</stackView>
6464
<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">
65-
<rect key="frame" x="16" y="20" width="343" height="34"/>
65+
<rect key="frame" x="16" y="44" width="343" height="34"/>
6666
<constraints>
6767
<constraint firstAttribute="height" constant="33.5" id="Egv-BL-kER"/>
6868
</constraints>
@@ -71,7 +71,7 @@
7171
<nil key="highlightedColor"/>
7272
</label>
7373
<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">
74-
<rect key="frame" x="16" y="62" width="343" height="86.5"/>
74+
<rect key="frame" x="16" y="86" width="343" height="86.333333333333314"/>
7575
<constraints>
7676
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="20.5" id="93b-AO-LrV"/>
7777
</constraints>
@@ -83,7 +83,6 @@
8383
</subviews>
8484
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
8585
<constraints>
86-
<constraint firstItem="z9t-XS-lhO" firstAttribute="top" secondItem="PaI-Gy-DRW" secondAttribute="bottom" constant="7.5" id="Afa-Yw-QCv"/>
8786
<constraint firstItem="z9t-XS-lhO" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="B1d-lT-JlA"/>
8887
<constraint firstItem="oCa-kL-Afh" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="B66-MX-XVC"/>
8988
<constraint firstItem="7fb-za-j9D" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="Eq7-rt-imJ"/>
@@ -119,20 +118,20 @@
119118
<viewControllerLayoutGuide type="bottom" id="NDV-VM-5Pu"/>
120119
</layoutGuides>
121120
<view key="view" contentMode="scaleToFill" id="kJk-wp-QpV">
122-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
121+
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
123122
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
124123
<subviews>
125124
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z3J-rB-T6Q">
126-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
125+
<rect key="frame" x="16" y="44" width="343" height="734"/>
127126
<color key="backgroundColor" red="0.80392156859999997" green="0.82745098039999998" blue="0.84313725490000002" alpha="1" colorSpace="calibratedRGB"/>
128127
</webView>
129128
</subviews>
130129
<color key="backgroundColor" red="0.80392156859999997" green="0.82745098039999998" blue="0.84313725490000002" alpha="1" colorSpace="calibratedRGB"/>
131130
<constraints>
132-
<constraint firstItem="z3J-rB-T6Q" firstAttribute="leading" secondItem="kJk-wp-QpV" secondAttribute="leading" id="5Jh-Xx-OHv"/>
133-
<constraint firstItem="NDV-VM-5Pu" firstAttribute="top" secondItem="z3J-rB-T6Q" secondAttribute="bottom" id="87D-9u-pkh"/>
134-
<constraint firstItem="z3J-rB-T6Q" firstAttribute="top" secondItem="UTc-zo-4Ig" secondAttribute="bottom" constant="-20" id="fbM-uC-gO0"/>
135-
<constraint firstAttribute="trailing" secondItem="z3J-rB-T6Q" secondAttribute="trailing" id="g6O-bH-HPT"/>
131+
<constraint firstItem="z3J-rB-T6Q" firstAttribute="top" secondItem="UTc-zo-4Ig" secondAttribute="bottom" id="70y-wV-6oQ"/>
132+
<constraint firstAttribute="trailingMargin" secondItem="z3J-rB-T6Q" secondAttribute="trailing" id="Lh2-N0-LRp"/>
133+
<constraint firstItem="z3J-rB-T6Q" firstAttribute="leading" secondItem="kJk-wp-QpV" secondAttribute="leadingMargin" id="SgB-LE-xdj"/>
134+
<constraint firstItem="NDV-VM-5Pu" firstAttribute="top" secondItem="z3J-rB-T6Q" secondAttribute="bottom" id="oQW-l7-Ueh"/>
136135
</constraints>
137136
</view>
138137
<connections>

Examples/Authentication/UAAWebLoginDemo/UAAWebLoginDemo/LoginViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LoginViewController: UIViewController {
3030
}
3131
}
3232

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

3636
self.webView.loadRequest(URLRequest(url: url))

0 commit comments

Comments
 (0)