Skip to content

Commit

Permalink
Updated to Tickets 3.1.1, converted EmbeddedVC to all code (no storyb…
Browse files Browse the repository at this point in the history
…oard)
  • Loading branch information
jbackertm committed Aug 19, 2023
1 parent 78ab2a8 commit 4fee8fe
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 60 deletions.
6 changes: 3 additions & 3 deletions TicketsSDKDemoIntegration.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0.3;
MARKETING_VERSION = 3.1.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -358,7 +358,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0.3;
MARKETING_VERSION = 3.1.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -455,7 +455,7 @@
repositoryURL = "https://github.com/ticketmaster/iOS-TicketmasterSDK.git";
requirement = {
kind = exactVersion;
version = 1.1.0;
version = 1.1.1;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
60 changes: 21 additions & 39 deletions TicketsSDKDemoIntegration/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -76,7 +74,24 @@
<rect key="frame" x="0.0" y="0.0" width="322.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Present Tickets (Embedded)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="biV-tl-AzR">
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Push Tickets (Embedded)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="biV-tl-AzR">
<rect key="frame" x="20" y="0.0" width="294.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="0.0"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="L2p-Ag-qxv" style="IBUITableViewCellStyleDefault" id="8XR-YV-k8y">
<rect key="frame" x="20" y="186.33333587646484" width="353" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="8XR-YV-k8y" id="IT3-ad-mOM">
<rect key="frame" x="0.0" y="0.0" width="322.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Present Tickets (Embedded)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="L2p-Ag-qxv">
<rect key="frame" x="20" y="0.0" width="294.66666666666669" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="0.0"/>
Expand All @@ -85,16 +100,13 @@
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="UeC-JM-Pt6" kind="show" id="OtI-Bv-3E7"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Authentication SDK" id="HB8-vG-iPl">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="f3p-6b-GO6" style="IBUITableViewCellStyleDefault" id="WFd-k6-LJi">
<rect key="frame" x="20" y="242.33333396911621" width="353" height="43.666667938232422"/>
<rect key="frame" x="20" y="286.00000190734863" width="353" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="WFd-k6-LJi" id="1y1-se-3Gx">
<rect key="frame" x="0.0" y="0.0" width="322.66666666666669" height="43.666667938232422"/>
Expand All @@ -111,7 +123,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="Djk-SZ-e4I" style="IBUITableViewCellStyleDefault" id="tiO-Ck-y8C">
<rect key="frame" x="20" y="286.00000190734863" width="353" height="43.666667938232422"/>
<rect key="frame" x="20" y="329.66666984558105" width="353" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="tiO-Ck-y8C" id="P4P-oP-nY7">
<rect key="frame" x="0.0" y="0.0" width="322.66666666666669" height="43.666667938232422"/>
Expand All @@ -128,7 +140,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="65Z-UC-x4A" style="IBUITableViewCellStyleDefault" id="XLu-lK-8yr">
<rect key="frame" x="20" y="329.66666984558105" width="353" height="43.666667938232422"/>
<rect key="frame" x="20" y="373.33333778381348" width="353" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="XLu-lK-8yr" id="2e8-zg-h61">
<rect key="frame" x="0.0" y="0.0" width="353" height="43.666667938232422"/>
Expand Down Expand Up @@ -158,35 +170,5 @@
</objects>
<point key="canvasLocation" x="-189" y="-30"/>
</scene>
<!--Embedded View Controller-->
<scene sceneID="VBn-Mg-OeD">
<objects>
<viewController id="UeC-JM-Pt6" customClass="EmbeddedViewController" customModule="TicketsSDKDemoIntegration" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="b85-3P-Oay">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Jv5-BB-F55"/>
<color key="backgroundColor" systemColor="systemGray6Color"/>
</view>
<navigationItem key="navigationItem" id="6hG-zh-Xnt">
<barButtonItem key="rightBarButtonItem" title="Logout" id="Oc5-MJ-iUq">
<connections>
<action selector="logoutButtonPressed:" destination="UeC-JM-Pt6" id="hDm-oY-CT0"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="logoutButton" destination="Oc5-MJ-iUq" id="17o-1I-kyw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iLh-Zs-3gs" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="751.90839694656484" y="-30.281690140845072"/>
</scene>
</scenes>
<resources>
<systemColor name="systemGray6Color">
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
82 changes: 66 additions & 16 deletions TicketsSDKDemoIntegration/EmbeddedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,29 @@ import TicketmasterTickets // for TMTickets.shared and TMTicketsView
/// this example is provided as an alternative way to embed Tickets SDK in your application's UI
class EmbeddedViewController: UIViewController {

@IBOutlet weak var logoutButton: UIBarButtonItem!

var ticketsView: TMTicketsView?
var addLogoutButton: Bool = false

var addCloseButton: Bool = false

var useSafeBottom: Bool = false

private var logoutButton: UIBarButtonItem?
private var closeButton: UIBarButtonItem?

private var ticketsView: TMTicketsView?

private var didAttachTicketsView: Bool = false

override func viewDidLoad() {
super.viewDidLoad()

title = "My Events"

// build TMTicketsView, attach to parent via constraints
buildAndAttachTicketsView()
// build TMTicketsView
buildTicketsView()

// build logout button (if navBar present)
buildButtons()

// update logout button based on current login state
updateLogoutButton()
Expand All @@ -33,36 +45,57 @@ class EmbeddedViewController: UIViewController {
registerForLoginStateNotifications()
}

func buildAndAttachTicketsView() {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

// attach to parent via constraints
attachTicketsView()
}

func buildTicketsView() {
// do not allow multiple instances of ticketsView
if ticketsView == nil {
// build a new TMTicketsView
ticketsView = TMTicketsView(frame: .zero)
if let tView = ticketsView {
// tell Tickets SDK to use the provided TMTicketsView
// - you do not need to call this method when using TMTicketsViewController
// - see MainMenuVC+TableViewDleegate.swift
TMTickets.shared.start(ticketsView: tView)
}
}
}

func attachTicketsView() {
if let tView = ticketsView {
if didAttachTicketsView == false {
didAttachTicketsView = true
// always set this when using constraints
tView.translatesAutoresizingMaskIntoConstraints = false

// add TMTicketsView to EmbeddedViewController.view
view.addSubview(tView)

// do NOT extend under nav bar (ie. use safeAreaLayoutGuide)
let topConstraint = NSLayoutConstraint(item: tView, attribute: .top, relatedBy: .equal,
toItem: view.safeAreaLayoutGuide, attribute: .top, multiplier: 1.0, constant: 0.0)
let leftConstraint = NSLayoutConstraint(item: tView, attribute: .left, relatedBy: .equal,
toItem: view.safeAreaLayoutGuide, attribute: .left, multiplier: 1.0, constant: 0.0)
let rightConstraint = NSLayoutConstraint(item: tView, attribute: .right, relatedBy: .equal,
toItem: view.safeAreaLayoutGuide, attribute: .right, multiplier: 1.0, constant: 0.0)
// extend under bottom tab swipe (ie. do NOT use safeAreaLayoutGuide)
let bottomConstraint = NSLayoutConstraint(item: tView, attribute: .bottom, relatedBy: .equal,
let bottomConstraint: NSLayoutConstraint
if useSafeBottom {
// do NOT extend under bottom tab swipe (ie. use safeAreaLayoutGuide)
bottomConstraint = NSLayoutConstraint(item: tView, attribute: .bottom, relatedBy: .equal,
toItem: view.safeAreaLayoutGuide, attribute: .bottom, multiplier: 1.0, constant: 0.0)
} else {
// extend under bottom tab swipe (ie. do NOT use safeAreaLayoutGuide)
bottomConstraint = NSLayoutConstraint(item: tView, attribute: .bottom, relatedBy: .equal,
toItem: view, attribute: .bottom, multiplier: 1.0, constant: 0.0)
}

// add TMTicketsView contraints to EmbeddedViewController.view
view.addConstraints([leftConstraint, topConstraint, rightConstraint, bottomConstraint])

// tell Tickets SDK to use the provided TMTicketsView
// - you do not need to call this method when using TMTicketsViewController
// - see MainMenuVC+TableViewDleegate.swift
TMTickets.shared.start(ticketsView: tView)
}
}
}
Expand All @@ -79,14 +112,31 @@ class EmbeddedViewController: UIViewController {
object: nil)
}

func buildButtons() {
if addLogoutButton, logoutButton == nil {
logoutButton = UIBarButtonItem(title: "Logout", style: .plain, target: self, action: #selector(logoutButtonPressed))
navigationItem.rightBarButtonItem = logoutButton
}
if addCloseButton, closeButton == nil {
closeButton = UIBarButtonItem(title: "Close", style: .done, target: self, action: #selector(closeButtonPressed))
navigationItem.leftBarButtonItem = closeButton
}
}

@objc func updateLogoutButton() {
// we can define "logged in" as having an OAuth token
logoutButton.isEnabled = TMAuthentication.shared.hasToken()
logoutButton?.isEnabled = TMAuthentication.shared.hasToken()
}

@IBAction func logoutButtonPressed(_ sender: Any) {
@objc func logoutButtonPressed(_ sender: Any) {
TMAuthentication.shared.logout { _ in
// list of all backends that were logged out
}
}

@objc func closeButtonPressed(_ sender: Any) {
dismissSelf(animated: true) {
// all done
}
}
}
11 changes: 9 additions & 2 deletions TicketsSDKDemoIntegration/MainMenuVC+TableViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ extension MainMenuViewController {
let ticketsVC = TMTicketsViewController()
present(ticketsVC, animated: true)

// Present Tickets (embedded)
// Push Tickets (embedded)
} else if indexPath == IndexPath(row: 2, section: 0) {
// handled by storyboard seque
let embeddedVC = EmbeddedViewController()
embeddedVC.addLogoutButton = true
navigationController?.pushViewController(embeddedVC, animated: true)

// Present Tickets (embedded)
} else if indexPath == IndexPath(row: 3, section: 0) {
let embeddedVC = EmbeddedViewController()
present(embeddedVC, animated: true)

// Login
} else if indexPath == IndexPath(row: 0, section: 1) {
Expand Down

0 comments on commit 4fee8fe

Please sign in to comment.