Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development...

148
Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 Swift Shopper Native SDK for iOS Development Guide Version 1.0 Page 1 of 148

Transcript of Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development...

Page 1: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Swift Shopper Native SDK for iOS Development Guide

Version 1.0

Page 1 of 148

Page 2: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Introduction 7

Audience 7 Prerequisites 7

Initial Setup 8 Add Swift Swift Shopper Framework File to Your App 8

Open Your App in XCode 8 Drag and Drop the Swift Shopper Framework File into Your App 9 Configure Swift Shopper Framework as Embedded Binary for your App 11 Configure Cocoa Pods for Your App 13 Close Your App & Re-open Using the New Workspace 18 Explain Why Your App Now Needs Extra Runtime Permissions 19 Define a Theme Color 21 Define an Icon 22 Activate R.swift 23 Initialize the Swift Shopper SDK When Your App Starts 25 In-App Payment Setup 26

Swift Shopper User Interface Integration 30 Design / Usage Pattern 30 User Login 31

Anonymous Login 31 Social Media Login 32

Using Swift Shopper SDK’ SSLoginView 32 Email Login 33 Suggested Strategies 34

Anonymous Login 34 Social Media Login Using SSLoginView 34 Significantly Customized Social Media Login 35 Completely Custom Login 35

Basic Self-Scan Shopping 36 Single Location Support 36 Multiple Location Support 36

Selecting a Market 37 Design Storyboard Scene 37 View Controller Swift Class 41

Page 2 of 148

Page 3: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Self-Scan Shopping Scene 46

Navigation Scenario: Single Retail Store Location 50 Navigation Scenario: Multiple Retail Stores 55

Navigate First to the Select Market Scene 55 Navigate to the In Store Shopping Scene when User Enters a Store 56 Test / Verify the Result 57

Navigation Scenario: Return Home After Checkout 59 Navigation Scenario: User Leaves App While Shopping 63 Navigation Scenario: Keeping the User Inside Self-Scan Shopping 65

Cart Widget 67 Example 67 Example 68

Cart Scene 69 Exit Store 71

Example 71 Order History 74

Shopping Lists 76 Scenario: View/Edit Shopping Lists (Support Only When Not Shopping) 77 Scenario: View/Edit Shopping Lists (Support Only While Shopping) 77 Scenario: View/Edit Shopping Lists (Support When Either Shopping or Not Shopping) 77 Shared Shopping Lists 79

Minimal Behavior Needed From Your App 79 Optimized Behavior Suggested From Your App 80

Sign-up For an Account With “Branch.io” 80 Customize the Text / Email Message from First User to Second User 80 Detect When the Second User Clicks the Shared List Link 83

Viewing Deals 87

User Profile 88

Appendix 1: Class Reference 89 SwiftShopperFramework 89

Purpose 89 Static Functions 89

initialize 89 application <<User Activity>> 91 application <<URL>> 92 login <<social media token>> 93

Page 3 of 148

Page 4: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

login <<custom login>> 96 login <<loyalty token>> 98 loginAnonymous 99 logout 100 toggleScannerGuide 101 enterStore 102 exitStore 104 getUser 105 getStore 106 importSharedList 107 scanItemToCart 110

SSUser 111 Purpose 111 Values 111

userId 111 firstName 111 lastName 111 email 111 imageUrl 111 gender 111 isAnonymous 111

SSStoreDetail 112 Purpose 112 Values 112

name 112 storeId 112 latitude 112 longitude 112 isFlyPassEnabled 112 isFlyThruEnabled 112 retailerWelcomeHtml 112 termsURL 112 retailerName 112

SSScanResult 113 Purpose 113 Values 113

statusCode 113 message 113

Page 4 of 148

Page 5: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

barcode 113

SSError 114 Purpose 114 Values 114

message 114

Appendix 2: Posted Events 115 Events 115

sharedListImported 115 finishedShopping 116

Appendix 3: Swift Shopper Views 117 Views 117

SSCartView 117 SSCartButton 118 SSOrderHistory 120 SSShopOnTheFlyView 121 SSProfileView 122 SSLoginView 123 SSSelectMarketView 125 SSListView 126 SSDealView 128

Appendix 4: Delegate Protocols 129 SSSelectMarketViewDelegate 130

checkedIn 130 SSListViewDelegate 131

shared 131

Appendix 5: String Customizations 133 Available Strings for Customization 134

Appendix 6: Troubleshooting 139 Build Problems 139

Build Failed: Linker Command (app does not contain bitcode) 139

Appendix 7: App Store Release 140

Appendix 8: License Agreement 144

Page 5 of 148

Page 6: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Page 6 of 148

Page 7: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Introduction The Swift Shopper Native SDK for iOS allows portions of the original Swift Shopper Universal App to be incorporated into any iPhone app that can be developed in XCode.

Audience This document is intended for an iOS developer who is currently developing or maintaining an app. This development guide provides comprehensive, step-by-step instructions and illustrations for adding Swift Shopper into any such existing app. This guide tries to err on the side of being perhaps too detailed in order to ensure that any iOS developer at any experience level can successfully integrate Swift Shopper with their app.

Prerequisites The following prerequisites are required to integrate the Swift Shopper Native SDK with an iPhone app:

● Full source code to a working iPhone app in which to integrate Swift Shopper ● A Macintosh computer with XCode with sufficient hardware and software specifications

to allow you to build the app in which to integrate Swift Shopper. (If you are a developer who has already been developing and building your app, then these first two prerequisites would certainly be satisfied.)

● "SwiftShopperSDK.framework" file. Please obtain this file from your Swift Shopper technical point-of-contact.

● Cocoa Pods installed on the Macintosh Development computer To install Cocoa Pods, open the Terminal application and issue the following command:

sudo gem install cocoapods

Page 7 of 148

Page 8: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Initial Setup

Add Swift Swift Shopper Framework File to Your App

Open Your App in XCode Open your app in the Xcode application:

Page 8 of 148

Page 9: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Drag and Drop the Swift Shopper Framework File into Your App Make sure that the Project Navigator appears on the side within Xcode:

Drag the SwiftShopperSDK.framework file from a Finder window and drop the file into the outermost directory within the Project Explorer Tree:

Page 9 of 148

Page 10: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

The Choose options for adding these files dialog appears:

Ensure that the Copy items if needed checkbox is checked on the Choose options for adding these files dialog, then click the Finish button:

Page 10 of 148

Page 11: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Configure Swift Shopper Framework as Embedded Binary for your App Add the SwiftShopperSDK.framework to the list of embedded binaries for your app:

Page 11 of 148

Page 12: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

After adding the Swift Shopper SDK as an embedded binary, XCode incidentally might list the SwiftShopperSDK.framework twice under the section titled Linked Frameworks and Libraries, which is located just below the Embedded Binaries section in the project editor screen. Delete the duplicate if it exists:

Page 12 of 148

Page 13: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Configure Cocoa Pods for Your App Open the terminal application, ‘cd’ to your app’s root source code directory, and issue the command:

pod init

The command should quickly succeed. You should then see a file named Podfile in the directory:

Page 13 of 148

Page 14: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Open the Finder application and navigate to the root directory of your app’s source code:

Right-click the Podfile and open with the TextEdit application:

Page 14 of 148

Page 15: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Copy the following text and replace the entire text within the Podfile with the following: platform :ios, '11.0'

target 'StarterApp' do

# Comment the next line if you're not using Swift and don't want to use dynamic frameworks

use_frameworks!

# Swift 4.2

pod 'Alamofire', '~> 4.7'

pod 'RSBarcodes_Swift', '~> 4.2.0'

pod 'ObjectMapper', '~> 3.3'

pod 'DropDown'

pod 'R.swift', '~> 4.0'

pod 'SkyFloatingLabelTextField', '~> 3.0'

pod 'CHIPageControl/Aji', '~> 0.1.3'

pod 'SideMenu', '~> 5.0'

# Swift 4.0

pod 'SwiftySound'

# Swift 3.x

pod 'Permission/Camera', :git => 'https://github.com/leoneparise/Permission', :branch => 'master'

pod 'Permission/Location', :git => 'https://github.com/leoneparise/Permission', :branch => 'master'

# Objective C

pod 'CRToast', '~> 0.0.7'

pod 'ZXingObjC', '~> 3.0'

pod 'AWSS3'

pod 'AWSCore'

pod 'AWSCognito'

pod 'SWTableViewCell', '~> 0.3.7'

pod 'TTTAttributedLabel', :git => 'https://github.com/TTTAttributedLabel/TTTAttributedLabel.git'

pod 'SDWebImage', '~> 4.4'

pod 'Stripe'

pod 'KVNProgress', '~> 2.0'

# Frameworks

pod 'AppsFlyerFramework'

post_install do |installer|

installer.pods_project.targets.each do |target|

target.build_configurations.each do |config|

config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'

end

if ['Permission'].include? target.name

target.build_configurations.each do |config|

config.build_settings['SWIFT_VERSION'] = '3.0'

end

end

if ['SwiftySound', 'R.swift.Library'].include? target.name

target.build_configurations.each do |config|

config.build_settings['SWIFT_VERSION'] = '4.0'

end

end

end

end

end

Page 15 of 148

Page 16: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Change the target on the third line of the new text inside the Podfile to match your app’s target name. Your app’s target name will usually appear as the first target displayed in the project editor:

Page 16 of 148

Page 17: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Save the Podfile from within the TextEdit application.

From the same terminal window as before, and in the same directory as before, issue the command pod install

Page 17 of 148

Page 18: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

As the command executes, the pod utility will download and install the Swift Shopper SDK’s dependencies into your app. Depending on your Internet connection speed, this will take several minutes:

Close Your App & Re-open Using the New Workspace In addition to installing the Swift Shopper SDK’s dependencies, the pod install command creates an XCode workspace for your app.

Close your project from within XCode:

Open a finder window, navigate to your project’s source directory, and double-click the file with extension .xcworkspace:

Your app’s workspace contains two projects: (1) your app’s original project and (2) a new project named Pods.

Page 18 of 148

Page 19: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Explain Why Your App Now Needs Extra Runtime Permissions Back in Xcode, open the file named info.plist file for your app. The info.plist file is an XML file. Edit the info.plist file as a source code file:

This will allow you to directly edit the text for the info.plist file. Copy and paste the following text into the bottom of the <dict>...</dict> section and then save the file: <key>NSAppTransportSecurity</key>

<dict>

<key>NSAllowsArbitraryLoads</key> <true/>

</dict>

<key>NSCameraUsageDescription</key> <string>App uses your camera to scan barcodes as you shop.</string> <key>NSLocationAlwaysUsageDescription</key> <string>App uses your location to find nearby stores to shop at, and the find nearby deals.</string>

<key>NSLocationWhenInUseUsageDescription</key> <string>App uses your location to find nearby stores to shop at, and the find nearby deals.</string>

<key>NSPhotoLibraryUsageDescription </key>

<string>App accesses your photos when you choose pictures for shopping list items.</string>

Page 19 of 148

Page 20: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Page 20 of 148

Page 21: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Define a Theme Color The Swift Shopper SDK draws its user interface using a theme color that you provide. This allows any user interface components that the Swift Shopper SDK draws to match your app’s appearance. Open your app’s “colors” assets file in XCode if your app has an assets file that defines colors. Otherwise, add a “colors” assets file. Here’s how to add a “colors” assets file:

Name the new assets file as Colors

Add a color named “themeColor” to your “colors” assets file:

Page 21 of 148

Page 22: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Specify a Color for the themeColor:

With the themColor selected from within the Colors.assets file, make Sure the Right Pane is Activated:

View the Color’s Attributes:

Choose the Color:

Define an Icon The Swift Shopper SDK presents an icon from your app in certain strategic locations on the various user interface components that the Swift Shopper SDK provides. We suggest that this icon should represent the retail store chain at which your app allows users to shop:

Open the Assets.xcassets file:

Add a New Image Set:

Name it ShoperIcon:

Change to Single Scale:

Drag File in From Finder:

Page 22 of 148

Page 23: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Activate R.swift The R.swift plugin makes it easy to access your application’s assets from your code. Follow these steps to activate R.swift If your app does not have R.swift activated.

Edit Your App’s Build Phases:

Add a New Run Script Phase:

Locate the New Run Script Phase:

Drag and Drop the New Run Script Phase Just Above the Compile Sources phase:

Expand the New Run Script Phase:

Type "$PODS_ROOT/R.swift/rswift" generate "your-app-target" (but replace your-app-target with the real name of your app target)

Page 23 of 148

Page 24: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Build Your Project (Even Though the Build Might Fail):

Add R.generated.swift to the Compile Sources Build Phase:

Add R.generated.swift via the “Add Other…” button:

Choose the R.generated.swift file from your project’s root source code directory:

NOTE: You were instructed a few steps ago to build your project. Building your project causes the R.generated.swift file to be created.

Then press the Finish button:

Page 24 of 148

Page 25: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Initialize the Swift Shopper SDK When Your App Starts

Open your app’s AppDelegate.swift file in XCode:

Add import statement for SwiftShopperSDK:

Locate the ‘application’ callback that is called when your app launches:

Call the SwiftShopperFramework.initialize method as follows:

if let themeColor = R.color.themeColor(), let shopperIcon = .image.shopperIcon(){ SwiftShopperFramework.initialize( key: "w9mn{dn7lPIF37Yb#>fh)By^Q|AoA3w8<SGXbd2gmPF2|", color: themeColor, icon: shopperIcon) }

The ‘key’ associates your app to a retailer within the Swift Shopper infrastructure. Replace the ‘key’ with the ‘key’ that Swift Shopper has assigned to your retailer. If you do not have this key, you may use the key in this example to get you started. Eventually you will need to contact [email protected] and ask for your retailer’s key. The Swift Shopper SDK is now installed into your app. Although your app does not yet do anything useful with the SDK, you may now build your app. Assuming that your app successfully built prior to following these instructions, your app should now be at a point at which your app will successfully build and run.

Page 25 of 148

Page 26: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

In-App Payment Setup Follow these steps if your app will allow the user to pay directly in the app. (1) Add “SSApplePayProtocol” as a URL Scheme in the app’s info.plist file.

Open the App’s info.plist file:

Add “URL Types” array if missing: (1) Right Click the outermost Information Property List (2) Choose “Add Row” in the pop-up menu that appears (3) Scroll Down and Choose URL Types

Page 26 of 148

Page 27: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Or if the app already has a “URL Types” array, then add a row to the “URL Types” array: (1) Right-click the “URL Types” array (2) Choose “Add Row” in the pop-up menu that appears (3) notice that a new “Item 0” appears in the list (any pre-existing “item 0” is now “item 1”, etc.)

In either case, change the “URL identifier” that XCode automatically created under “Item 0” beneath “URL Types”. Change from “URL identifier” to “URL Schemes”, and add a string property under “URL Schemes” whose value is “SSApplePayProtocol”:

(1) Expand “Item 0”:

(2) Drop-down the list for the “URL identifier” located under “Item 0”:

(3) Choose “URL Schemes” from the drop-down. Notice that the “URL Identifier”

has now become “URL Schemes”:

(4) Expand “URL Schemes” under “URL Types” / “Item 0”. Notice there is another “Item 0” under “URL Schemes” but whose

type is “String”. Set the value for the “Item 0” string property under “URL Schemes” to

“SSApplePayProtocol”:

Page 27 of 148

Page 28: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

The previous set of steps to add the “SSApplePayProtocol” URL scheme in info.plist causes the app to be registered when installed on the device in such a manner that causes the app itself to officially handle custom URL’s that start with SSApplePayProtocol://. Whenever the device needs to “open” a URL that starts with SSApplePayProtocol://, the device will now invoke a callback in the app and pass the URL.

BACKGROUND: Registering the app to handle URLs that start with “SSApplePayProtocol://” is necessary due to a nuance in how Apple insists that iOS apps handle Apple Pay. Any iOS app the takes Apple Pay transactions needs to either go through an intense process of registering the app itself in iTunes Connect and with a third payment provider company; or Apple Pay can be processed in either Safari or a Safari Web View. To alleviate the burden that you would otherwise have to go through to get the app registered with iTunes Connect and a third party payment processor company, the Swift Shopper Framework has opted to process Apple Pay via a Safari Web View. When a user chooses to pay by Apple Pay, the Apple Pay interface is displayed via a Safari Web View. The Safari Web View essentially executes in another process that is external to the app. When the user completes the Apple Pay payment approval, the code that executes in the Safari Web View sends the “result” back to the app by asking the Safari Web View to open a URL that starts with “SSApplePayProtocol://”. Since the app itself is registered as a handler for URLs that start with “SSApplePayProtocol://”, the app itself thereby receives the URL callback. The app simply needs to pass the URL that the app receives in the callback into the Swift Shopper Framework

Next you’ll need to add a small amount of code to your app such that when your app receives the callback that occurs whenever the app is passed an SSApplePayProtocol:// url, the app will then pass the URL to the Swift Shopper Framework so that the Swift Shopper Framework can process the URL request. Add the following method to your app’s AppDelegate class in the AppDelegate.swift file: func application( _ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { SwiftShopperFramework.application(app, open: url, options: options)

return true;

}

Or if the app’s AppDelegate class already has that method defined, add the following code to the top of the logic that is already in that method:

Page 28 of 148

Page 29: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SwiftShopperFramework.application(app, open: url, options: options)

This is the standard way of defining the callback code that is executed when the user completes payment for Apple Pay. This code simply passes the URL to the Swift Shopper Framework so that the Swift Shopper Framework can then complete the user’s purchase transaction and show the user their receipt, etc.

Page 29 of 148

Page 30: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Swift Shopper User Interface Integration

Design / Usage Pattern The Swift Shopper SDK provides fully implemented graphical user interface components for all of the Swift Shopper features such as self-scan mobile checkout, viewing in-store deals, viewing / editing shopping lists, etc. The general usage pattern is that the Swift Shopper SDK provides a fully implemented custom iOS view for each of these Swift Shopper tasks. All you have to do is create a scene within your storyboard, add a UIView to the scene’s view hierarchy, set the custom class name accordingly upon the UIView, for example: SSShopOnTheFlyView, SSCart, SSLoginView, SSDeals, etc. Set the custom class module to SwiftShopperSDK. The scenes correspond to screens within your app. After adding the Swift Shopper custom views to the scene(s) within your app, provide a means within your app for the user to navigate to those scenes. As long as your app has called SwiftShopperFramework.initialize(...) from your app’s AppDelegate.swift file when your app starts up, each of these views will then be fully operational. These views will render the user interface colored based on the theme color that your app passes to the SwiftShopperFramework.initialize(...) method; likewise for the font and icon that your app passes to the SwiftShopperFramework.initialize(...) method. This is the general pattern for integrating any portion(s) of Swift Shopper within your app. The rest of this document explains each item that is available for integration into your app, along with step-by-step illustrations in some cases for incorporating these items into your app. The same general pattern applies, however, to each item. Step-by-step illustrations are arbitrarily provided for various Swift Shopper components so as to give you a general walk-through for integrating Swift Shopper components. For any components for which step-by-step illustrations might not be included, simply review the illustrations for any other component and do likewise.

Page 30 of 148

Page 31: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

User Login Your app needs to log the app’s user into Swift Shopper in order to use the Swift Shopper SDK. There are multiple options for logging the app user into Swift Shopper, each with different benefits.

Anonymous Login Anonymous login is the easiest login to implement. However, anonymous login provides the least amount of benefits to the user. Pros:

● Easiest for the developer to implement ● Does not require any information about the user ● The app developer does not need to maintain their own master database of users

Cons: ● The user will not receive an email receipt when they purchase in the app. ● The user will not be able to share their shopping lists with other users. ● The user will not be able to access any shared shopping lists from other users ● The user’s credit cards will not be saved, except for Apple Pay, since Apple saves the

user’s payment information in the user’s Apple Wallet which is connected to the user’s iTunes Connect account.

Implement Anonymous Login

Open your app’s AppDelegate.swift file in XCode and edit the ‘application’ callback that executes when the app is launched:

Call SwiftShopperFramework.loginAnonymous(...):

Page 31 of 148

Page 32: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Social Media Login You may log your users in via any of the following social media account types:

● Google ● Facebook ● Twitter

Pros

● The SwiftShopper SDK provides a fully implemented, easy-to-integrate user interface for social media login.

● The user will receive an email receipt when they purchase in the app. ● The user will be able to share their shopping lists with other users. ● The user will be able to access shared shopping lists from other users ● The user’s credit cards will be saved to their login. ● The user’s purchase history, shared lists, and credit cards will “follow” them if they run

the app on another device provided that they log in via the same social media account on that device.

● The app developer does not need to maintain their own master database of users ● If the app already features a social media login, the app’s own social media login can be

used as the Swift Shopper login too. Cons

● Some users are averse to logging into apps using their social media accounts.

Using Swift Shopper SDK’ SSLoginView

1. Identify or add a scene to your storyboard for sign-in 2. Open the “library” from the Interface Builder, search for “UIView”, then drag a “View”

onto the scene’s view hierarchy. 3. Resize the view to occupy a substantial amount of the screen’s real estate. 4. Set the view’s custom class name to “SSLoginView” 5. Set the view’s custom class module to “SwiftShopperSDK” 6. Create / associate a .swift view controller class to the scene. 7. Connect a “referencing outlet” from the SSLoginView in your scene’s view hierarchy to

the .swift view controller class. 8. Override the ‘viewDidLoad()’ method and call the setLoginSuccessListener(...) and

setLoginSuccessFailure(...) methods on the SSLoginView. 9. Pass a function into the setLoginSuccessListener(...) method that takes an SSUser as a

parameter. The Swift Shopper SDK will call this code upon successful login. The SSUser object encapsulates the user’s email, first name, last name, profile photo url, etc.

10. Pass a function into the setLoginFailureListener(...) method that takes no parameters. The Swift Shopper SDK will call this code upon unexpectedly failed login.

Page 32 of 148

Page 33: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Email Login You may log your users into Swift Shopper via the user’s email address. Pros:

● Same benefits as social media login. Cons:

● The app developer needs to implement the entire user interface flow for collecting the user’s email address, validating the user’s password, etc..

● The app developer needs to maintain a master database of their users, user passwords, etc. Each user’s email address needs to be mapped to a globally unique user id integer that the app develop needs to construct.

Page 33 of 148

Page 34: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Suggested Strategies

Anonymous Login

The pros and cons of anonymous login were previously discussed. If despite the cons (such as no email receipts upon in-store purchase, no shared shopping lists, etc) you wish to provide the most basic integration, simply call SwiftShopperFramework.loginAnonymous(...) perhaps from your app’s “AppDelegate” when the app starts. Then your app may allow the user to navigate to any screens that incorporate Swift Shopper tasks, such as self-scan checkout.

Social Media Login Using SSLoginView

This document explains how to integrate the various Swift Shopper components into your app, such as self-scan mobile checkout, displaying in-store deals, and shopping list support. Your app will inevitably present navigation mechanism (buttons, menus, etc) for the user to invoke in order for your app to navigate the user to perform these tasks. As a user attempts to navigate to any of these tasks, check if the user is logged in yet to Swift Shopper by evaluating the return value after calling SwiftShopperFramework.getUser(). SwiftShopperFramework. getUser() returns a non-nil value if the user is logged in. However, the user could be logged in anonymously, so also verify that the “isAnonymous” property’s value is “false”: if let user = SwiftShopperFramework.getUser(), !user.isAnonymous {

// User is logged in and is not anonymous

}

If the user is not yet logged into Swift Shopper or if the user is logged in anonymously, navigate the user to the Login Scene that your app features. This login scene will integrate the SSLoginView in the scene’s view hierarchy, as previously described. From the view controller’s callback that occurs upon successful login, as previously described, navigate the user to the corresponding scene for the task that the user had tried to perform prior to being directed to login. Using the SSLoginView, the user may login via their Facebook, Twitter, or Google account. The user may also elect to “skip login” from the SSLoginView in which case, the user is actually logged in anonymously. Of course, if the user attempts to navigate to perform a Swift Shopper task (self-scan mobile checkout, etc.) and if the user is already logged into Swift Shopper, the app should simply allow the user to navigate directly to the chosen task. The SSLoginView allows for some mild customization. From the interface builder you may specify whether to hide any particular social media login mechanism and/or whether to hide the option to “skip login”. From the interface builder, you may also specify a “themeColor”. The

Page 34 of 148

Page 35: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SSLoginView uses the “themeColor” as the color for the “Skip” button’s border and text. Or you may set the “themeColor” to “clear” and then SSLoginView will use default coloring (white).

Significantly Customized Social Media Login

Alternatively, if you wish to provide a more customized login experience beyond the experience that the SSLoginView provides, you may implement the social media login completely on your own. For example, you may establish a facebook developer account, twitter developer account, and/or google developer account and directly implement social media login in your app. Upon successful social media login from either of these providers, your app receives a corresponding social media login token from the corresponding API’s that these social media providers provide. The social media login token is a string of decoded data that represents the logged in user. Once your app receives this token, simply pass this token to the SwiftShopperFramework. login(...) method. The Swift Shopper SDK will then convert the social media login into a Swift Shopper login and then call an “onSuccess” callback that you would provide to the SwiftShopperFramework. login(...) method. From that “onSuccess” callback, you would then navigate your user to the next screen that your app wishes to display after the user logs in: perhaps a scene that corresponds to a Swift Shopper task that the user may have tried to perform such as self-scan mobile checkout or view in-store deals.

Completely Custom Login

Alternatively, if you wish to provide your own completely customized sign-up process, including having the user establish a user name and password for use in your app, you may implement this on your own too. (There will certainly back-end / service infrastructure that you will need to either implement or perhaps already have available from the retailer perhaps from legacy software.) After the user signs in using this mechanism, simply call SwiftShopperFramework. login(...) and pass a globally unique id for the user (to be calculated by your app or back-end infrastructure), along with an email, first name if available, last name if available, profile photo URL if available, etc. Also pass in an “onSuccess” callback. Swift Shopper will convert these values into a Swift Shopper login, the user will be logged into Swift Shopper, and finally the “onSuccess” callback will be invoked. From the “onSuccess” callback, navigate the user to the screen for the task that the user requested prior to being directed to your custom login screen.

Page 35 of 148

Page 36: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Basic Self-Scan Shopping To add basic in-store shopping, your app should provide one or two scenes in the storyboard, depending on whether the app is written for a retailer with one versus multiple locations: Select Market Scene (for supporting multiple locations) and In-Store Shopping Scene (for the actual shopping experience). Your app should provide a navigation means to allow the user to initiate in-store shopping. This may be a button on another scene in your app, a button on your app’s menu, etc.

Single Location Support When the user navigates to the “In-Store Shopping” Scene, the app needs to call the SwiftShopperFramework.enterStore(...) method, and then navigate to the “In-Store Shopping” scene from an “onSuccess” callback that the app passes to the SwiftShopperFramework.enterStore(...) method.

Multiple Location Support When the user chooses to shop, your app needs to navigate the user either to the Select Market Scene or to the In-Store Shopping Scene. When the user clicks the button that your app provides to initiate the in-store shopping experience, if the app is currently checked into a store, your app should navigate the user directly to your app’s shopping scene. Call the SwiftShopperFramework. getStore() function to determine if the app is checked into a store. The SwiftShoperFramework. getStore() function returns a non-nil SSStoreDetail object if the user is currently checked into a store:

if SwiftShopperFramework.getStore() == nil {

// The app needs to check into a store... perhaps navigate to your Select Market

scene.

} else {

// The app is already checked into a store... perhaps navigate to your shopping scene

}

If your app is not currently checked into a store, your app should navigate the user to your app’s Select Market Scene, which will utilize the Swift Shopper SDK to prompt the user to choose a nearby store. Your app will then receive a callback when the user chooses a nearby store. From the callback your app should automatically bring the user to your app’s shopping scene. You may also program your app to display the information about the current store if you wish. The information is available via the various data fields that are on the SSStoreDetail object that your app receives in the callback. Alternately, you may call SwiftShopperFramework. getStore() to access the SSStoreDetail object to attain the various data fields that describe the store.

Page 36 of 148

Page 37: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Selecting a Market To help support the scenario where the is for a retailer that has multiple locations, the Swift Shopper SDK provides a ‘Select Market’ UIView that you can place on a scene within your app’s storyboard. This section may be skipped if the app only needs to support a single physical location. Simply create a scene. Perhaps name the scene as Select Market Scene. Add a UIView to your scene’s view hierarchy. Size the UIView to provide a decent amount of real estate from the screen, perhaps even size the UIView to fill the entire screen minus any real-estate that your app uses for providing menus, navigation, etc. Set the custom class name as SSSelectMarketView and the custom class module to SwiftShopperSDK.

Design Storyboard Scene

Open Your App’s Storyboard in XCode:

Open the Library, Search for “View Controller”

Page 37 of 148

Page 38: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Drag a View Controller from the Library and drop it under the list of Scenes located to the left side of the storyboard editor:

Notice that a new View Controller Scene appears in your app’s storyboard:

Rename the View Controller within the View Controller Scene to “Select Market”:

Incorporate your app’s navigation mechanism into the Select Market Scene. For example:

Page 38 of 148

Page 39: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Add a UIView to the View under the Select Market Scene:

Rename the new View as “Select Market View”:

Set the “Select Market” view’s custom class name to “SSSelectMarketView” and press enter:

Then set the “Select Market” view’s custom class module name to “SwiftShopperSDK”:

Make the “Select Market” view’s width and height match its parent View:

(Control-click drag from SelectMarketView to its parent view, choose “Equal Widths”, control-click drag again and then choose “Equal Heights”.

Page 39 of 148

Page 40: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Center the SelectMarketView horizontally and vertically within its parent view:

Result:

Page 40 of 148

Page 41: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View Controller Swift Class Create a SelectMarketVC view controller class in .swift source code file for the “Select Market” scene.

Start with the following source code for the SelectMarketVC class: import Foundation import UIKit import SwiftShopperSDK

class SelectMarketVC: UIViewController { override func viewDidLoad() { }

}

extension SelectMarketVC: SSSelectMarketViewDelegate { func checkedIn(to store: SSStoreDetail) { }

}

Page 41 of 148

Page 42: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Result:

Associate the SelectMarketVC view controller with the “Select Market” scene’s view controller in the storyboard:

Page 42 of 148

Page 43: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Define the Select Market Scene’s Storyboard ID as “SelectMarketVC”:

Create a source code reference (outlet) between the “Select Market” view in the “Select Market” scene and the “SelectMarketVC” class in the “SelectMarketVC.swift” file:

View the Storyboard and SelectMarketVC in split pane mode:

In split pane mode, expand the “Select Market” scene, select the “Select Market View”, and view the “Connections Inspector”:

Drag the circle next to “New Referencing Outlet” onto the top of the “SelectMarketVC” class in the second pane’s source code editor for the SelectMarketVC.swift file:

Name the connection as “selectMarketView” and press the “Connect” button:

Page 43 of 148

Page 44: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Result:

Associate your app’s “select market” “view delegate” with your app’s “select market” view by adding the following line of code to the “SelectMarketVC” class’s “viewDidLoad()” method:

marketView.delegate = self

Result:

The next step will be to add a navigation mechanism to your app’s user interface that launches the Select Market Scene when the user chooses to go shopping. Your app will also need to implement the “In-Store Shopping” scene. Please note that there is a callback method in your

Page 44 of 148

Page 45: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SelectMarketVC class that is called when the user selects a store to go shopping at. This callback method is currently empty. The next section of this document will walk you through creating the “In-Store Shopping Scene”, and implementing the navigation mechanism that will first present the “Select Market Scene” and then present the “In-Store Shopping” scene after the user selects a market to shop at. The navigation between the Select Market Scene and the In-Store Shopping Scene is covered in detail in the subsection titled “Navigation Mechanism for Supporting Multiple Retail Store Locations”.

Page 45 of 148

Page 46: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Self-Scan Shopping Scene The Swift Shopper SDK provides a UIView for self-scan shopping that you can place on a scene within your app’s storyboard. This self-contained view provides the basic in-store self-scan shopping experience. This view displays the contents of the user’s shopping cart, a ‘scan’ button, and a ‘checkout’ button, plus the other relevant screens that appear after the ‘scan’ and ‘checkout’ buttons are tapped. In order to use this view, the app must first be checked into a particular retailer store location. There are two options to implement checking into a retail store location:

1. Call the SwiftShopperFramework.enterStore(...) method from code within the app. This mechanism is intended to support the scenario where an app supports shopping at exactly and only one physical store location.

2. Implement the Select Market functionality as described previously in this document. When the user chooses to shop, program the app to visit the app’s In-Store shopping scene if the app is already checked into a store. Otherwise, program the app to first visit the app’s Select Market scene if the app is not checked into a store. The Swift Shopper Select Market view walks the user through checking into a nearby store, and makes a callback to a specified callback function in the app after the user selects a store. From that callback in the app, program the app to then display the app’s In-Store Shopping scene. Your app’s code may call the SwiftShopperFramework. getStore() function to determine whether the app is checked into a store. This function returns a non-nil SSStoreDetail value if your app is checked into a store.

Simple create a scene. Perhaps name the scene as “In-Store Shopping”. Add a UIView to your scene’s view hierarchy. Size the UIView to provide a decent amount of real estate from the screen, perhaps even size the UIView to fill the entire screen minus any real-estate that your app uses for providing menus, navigation, etc. Set the custom class name to SSShopOnTheFlyView. Set the custom class module to SwiftShopperSDK. Step-by-step instructions for creating the “In-Store Shopping” scene are as follows:

Page 46 of 148

Page 47: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Click your app’s main storyboard file in the project navigator tree:

Open the Storyboard Library:

Drag a View Controller into the Storyboard:

A New Scene Appears

Edit the View Controller’s Name:

Set the View Controller’s Name to “In-Store Shopping”:

Add Another View to the In-Store Shopping Scene:

Result:

Change the New View’s Class Name to

Page 47 of 148

Page 48: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

“SSShopOnTheFlyView” via the Identity Inspector. Press enter after typing in the class name:

Result:

Add Constraints to Center the Shop On The Fly View both Horizontally and Vertically:

Result:

Page 48 of 148

Page 49: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Add Constraints to Set the Shop On The Fly View’s Width and Height Equal to the Parent View’s Width and Height:

1. Hold down the control key 2. Click the Shop On The Fly View, but

hold down the mouse button. 3. While holding down the mouse button,

drag the pointer to the “View” that is located just above the “Shop On The Fly View” in the In-Store Shopping Scene’s hierarchy, then release the mouse button.

A Pop-Up Menu Appears. Click “Equal Widths”

Repeat this procedure and also choose “Equal Heights”.

Result: XCode No Longer Shows Red Cross-Bars or Warnings on the Scene:

Despite the many detailed illustrated steps, the general idea is simply to add a view to a scene in the storyboard, set the view’s class to “SSShopOnTheFlyView” within the “SwiftShopperSDK” module, and give the SSShopOnTheFlyView a decent amount of real estate on the screen. Next add the mechanism to navigate from your app’s main or home screen to the In Store Shopping scene.

Page 49 of 148

Page 50: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Navigation Scenario: Single Retail Store Location This section describes how to setup and program your app’s user interface to allow the user to navigate to the In-Store Shopping scene assuming that your app only needs to support shopping at a single retail store location. You may skip to the section Navigation Mechanism for Supporting Multiple Retail Store Locations if your app needs to support allowing the user to shop at closest available retail store location.

Open your storyboard and view your main scene. It is assumed that you have a “Shop” button on your main scene.

Divide the screen to show the code for the main scene’s view controller below the storyboard editor:

Click the “Shop” button that you have presumably already added to the app’s main scene, and view the “Connections Inspector” for the “Shop” button:

Page 50 of 148

Page 51: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Drag the circle located to the right of the “Touch Up Inside” event to an empty area of the code editor for the

main scene’s view controller source code file:

XCode then prompts you for a name for the connection. Enter “onShopClicked” as the name and then press the “Connect” button:

Page 51 of 148

Page 52: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

XCode generates a method named “onShopClicked” in the main view controller’s source file and arranges for this method to be called at runtime whenever the ‘Shop’ button is pressed. Replace the “onShopClicked” method stub with the following code: @IBAction func onShopClicked( _ sender: Any) { self.showSpinner( self.view)

SwiftShopperFramework.enterStore(

retailerStoreId: 50,

onSuccess: { (ssStoreDetail) in if let inStoreShoppingVc = self.storyboard?.instantiateViewController( withIdentifier: "InStoreShoppingVC") {

self.navigationController?.pushViewController(inStoreShoppingVc, animated: true) }

self.removeSpinner() }, onFailure: {

self.removeSpinner() })

}

NOTE: You will need to improvise a little. The essential part is to call SwiftShopperFramework.enterStore(..), pass the value 50 as the retailerStoreId, and pass an inline onSuccess function that navigates to the “In Store Shopping” scene. The value “50” maps within the Swift Shopper infrastructure to a special, individual “test” retailer store location that can be used for development and verification of your app. NOTE: For this sdkdemo app, we have declared an “extension” upon the UIViewController class that adds a “showSpinner” and “removeSpinner” method to all view controllers to show or hide a very simple “loading” animation. Your app likely has its own mechanism for showing and hiding such an animation. For reference, here is a link to an article that Swift Shopper followed to create the “showSpinner” and “removeSpiner” methods:

http://brainwashinc.com/2017/07/21/loading-activity-indicator-ios-swift/

You may now run your app, press the ‘Shop’ button and see the ‘In Store Shopping’ scene:’ Notice that the “In Store Shopping” scene is fully populated in the running app, and includes a “Tap to Scan” button. You may press the “Tap to Scan” button to scan a barcode. A screen will appear, compliments of the Swift Shopper SDK that uses the camera to scan a barcode. If you are running your app in an XCode iOS emulator, the emulators do not support cameras, but the Swift Shopper SDK is programmed to automatically pretend that a test barcode was scanned. So, if you test your app in the emulator, simply tap the scan button, ignore any warnings about the camera, and notice that the Swift Shopper SDK behaves as if a barcode was scanned.

Page 52 of 148

Page 53: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

If you are testing your app on a real iOS device, press the “Tap to Scan” button and point your camera at the following barcode:

Otherwise, if you are testing your app in an emulated iOS device, press the “Tap to Scan” button, ignore the error message about the camera, and wait a few seconds for the Swift Shopper SDK to pretend that this same test barcode is scanned.

Page 53 of 148

Page 54: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

At this point you should be able to checkout via “FlyPass” (in-app payment) or “FlyThru” (pay at the cash register in the store). You may test “Apple Pay” or “Pay with Card”. To test “Apple Pay”, when prompted, simply choose any payment card in your “Apple Wallet”. Don’t worry, at this point your app is running in the Swift Shopper “Prerelease” environment, so your credit card will not actually be charged. To test “Pay with Card”, simply enter the following fake credit card: 4242 4242 4242 4242 (enter any date in the future as the expiration date, enter any CCV as the 3-digit card verification code).

Page 54 of 148

Page 55: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Navigation Scenario: Multiple Retail Stores To support shopping at multiple retail stores, the idea is that when the user chooses to ‘Shop’ from within your app, your app will first navigate the user to the “Select Market” scene. The Swift Shopper SDK will then present the user with a list of nearby stores prompting the user to select a store. After the user selects a store, the Swift Shopper SDK then calls a callback function in your app. The code in your app’s callback function will then subsequently navigate the user to the “In Store Shopping” scene.

Navigate First to the Select Market Scene

Open your storyboard and view your main scene. Add a “Shop” button (The example below already has a “Shop” button, but that button is from the “Single Retail Store Location” example. Hence, this example adds a “Shop Location” button to differentiate between the two.)

Divide the screen to show the code for the main scene’s view controller below the storyboard editor:

Click your “Shop” button that you have presumably already added to the app’s main scene, and view the “Connections Inspector” for the “Shop” button. (This Example illustrates a “Shop Nearby” button.) Drag the

“Touch Up Inside” event into the source code editor for the main view controller swift file :

Page 55 of 148

Page 56: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Next Step:

Result:

XCode generates a method named “onShopNearbyClicked” in the main view controller’s source file and arranges for this method to be called at runtime whenever the ‘Shop’ button is pressed. Replace the generated method stub’s inner code with the inner code from the following sample: @IBAction func onShopNearbyClicked( _ sender: Any) { if SwiftShopperFramework.getStore() == nil { if let selectMarketVC = self.storyboard?.instantiateViewController( withIdentifier: "SelectMarketVC") {

self.navigationController?.pushViewController(selectMarketVC, animated: true) }

} else { if let inStoreShoppingVc = self.storyboard?.instantiateViewController( withIdentifier: "InStoreShoppingVC") {

self.navigationController?.pushViewController(inStoreShoppingVc, animated: true) }

}

}

This code checks whether the current Swift Shopper store details is nil to determine whether the app is currently checked into a store. If checked into a store, this code navigates to the “In Store Shopping” scene. If not checked into a store, this code navigates to the “Select Market” scene.

Navigate to the In Store Shopping Scene when User Enters a Store The “Select Market Scene” section of this document illustrates and describes how to create the “Select Market Scene”. After following along in that section, your app will a file named “SelectMarketVC.swift” that defines a class named “SelectMarketVC” with an extension to the “SelectMarketVC” that includes an inline callback method named “checkedIn” in the source code. This method is called during the app’s runtime when the user selects a store to shop at from the “Select Market” scene.

Page 56 of 148

Page 57: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Add the following lines of code to the “SelectMarketVC” class’s “checkedIn” callback. These lines of code cause the app to subsequently navigate to the “In-Store Shopping” scene after the user selects a store. Since the user would have selected a store to shop at, the “In-Store Shopping” scene will then present the in-store shopping experience for shopping at the selected store. Here are the lines of code that need to be added to the “SelectMarketVC” class’s “checkedIn” callback: if let inStoreShoppingVc = self.storyboard?.instantiateViewController( withIdentifier: "InStoreShoppingVC") {

self.navigationController?.pushViewController(inStoreShoppingVc, animated: true) }

Test / Verify the Result

Run the app:

Press the “Shop Nearby” button:

The “Select Market” screen appears in which the Swift Shopper SDK asks the user to select a nearby market:

Page 57 of 148

Page 58: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Note that the example screenshot for the “Select Market” scene does not include a user interface “label” that labels the screen as the “Select Market” screen. Although these instructions have neither explicitly illustrated nor instructed you to do this, this document assumes that your pre-existing app already provides a means to provide some kind of user interface heading label on the app’s scene. You should probably update your Select Market scene to add some kind of heading label, or tie into your app’s potentially pre-existing mechanism for labelling the current screen, for example:

Tap a Market from the list:

A “welcome” screen appears. Tap the checkbox to agree to the market’s terms & conditions and then tap “Enter”:

NOTE: The ‘checkedIn’ callback occurs just after the user taps “Enter” on this screen.

The “In-Store Shopping” scene appears.

The user may now scan products (barcodes) to their cart and checkout / purchase groceries.

Page 58 of 148

Page 59: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Navigation Scenario: Return Home After Checkout It is suggested that your app automatically navigate the user back to the app’s home screen after the user completes their in-store checkout in the app. The easiest way to do this is to have your AppDelegate listen for the “finishedShopping” shopping and navigate the window’s root view controller to the main scene for your app. For example: // Sample code that automatically navigates to user back to the main scene upon completing

// or exiting from in-store self-scan shopping.

import UIKit import SwiftShopperSDK

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

// iOS automatically assigns the app’s window reference prior to calling

// the 'application' callback

var window: UIWindow?

func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { ...

// Automatically call the 'finishedShopping' method when the .finishedShopping

// event occurs

NotificationCenter.default.addObserver( self, selector: #selector(finishedShopping), name: .finishedShopping, object: nil) ...

}

...

@objc func finishedShopping() { if let mainNavigation = self.window?.rootViewController as? UINavigationController, let

mainMenuVc = R.storyboard.main.mainMenuScene(){

// Resets the navigation stack to just the main menu scene thereby navigating

// the user to the main scene

mainNavigation.setViewControllers( [mainMenuVc], animated: true) } else { print( "Design error / oops: unable to get the root navigation controller and/or the main menu scene.") }

}

... deinit { NotificationCenter.default.removeObserver( self, name: .finishedShopping, object: nil) }

...

}

Page 59 of 148

Page 60: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

If your app does not already have a source code file for the “In Store Shopping” scene’s view controller, create a Swift class named “InAppShoppingVC” and associate the “InAppShoppingVC” class as the View Controller class for the “In App Shopping” scene:

Right-click your app’s target in the project navigator pane located on the left in XCode and choose “New File…” from the pop-up menu:

Select “Swift File” and then press “Next”:

Type “InAppShoppingVC” as the file name and then press “Create”:

The new “InAppShoppingVC.swift” file appears. Replace all of the code with the following:

Page 60 of 148

Page 61: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

import Foundation import UIKit import SwiftShopperSDK

class InAppShoppingVC: UIViewController { override func viewDidLoad() { NotificationCenter.default.addObserver(

self, selector: #selector( checkoutCompleted),

name: NSNotification.Name(

rawValue: SwiftShopperFramework.checkoutCompleteListener),

object: nil) }

deinit { NotificationCenter.default.removeObserver(

self, name: NSNotification.Name(

rawValue: SwiftShopperFramework.checkoutCompleteListener),

object: nil) }

@objc func checkoutCompleted() { // navigate to home screen self.dismiss(animated: true, completion: {}); self.navigationController?.popViewController(animated: true); }

}

Save the file:

Open the app’s storyboard, expand the “In-Store Shopping Scene”, view the “Identity Inspector”, click the drop-down next to “Class” in the “Custom Class” section, and choose

Page 61 of 148

Page 62: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

“InAppShoppingVC”:

Now you may run your app again, go shopping, scan a barcode, checkout, and when complete your app will navigate you to the app’s main / home screen.

Page 62 of 148

Page 63: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Navigation Scenario: User Leaves App While Shopping In case the user leaves the app while in the middle of shopping and then subsequently returns to the app it is suggested that your AppDelegate logic check whether the user is currently checked into a store for shopping when the app launches. Automatically navigate the user to the self-scan shopping scene if the user is currently checked into a store when the app launches. For example:

(Continued on Next Page)

Page 63 of 148

Page 64: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

// Sample code that automatically navigates to the in-store shopping scene upon app launch

// if the user had been in the middle of shopping when the app was most recently closed

import UIKit import SwiftShopperSDK

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

// iOS automatically assigns the app’s window reference prior to calling

// the 'application' callback

var window: UIWindow?

func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { ...

// If the user closes the app when shopping, resume the shopping experience // immediately upon relaunching of the app

if SwiftShopperFramework.getStore() != nil, let inAppShoppingVc = R.storyboard.main.inStoreShoppingVC() {

let mainNavigation = window?.rootViewController as! UINavigationController mainNavigation.setViewControllers( [inAppShoppingVc], animated: true) }

// else: the app is automatically compiled to navigate to the main storyboard's // entry point, which for this app is the "Main Menu Scene"

...

}

...

}

Page 64 of 148

Page 65: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Navigation Scenario: Keeping the User Inside Self-Scan Shopping It is suggested that you consider keeping the user inside of the self-scan shopping scene, or any subsequent scenes that the user visits (the view in-store deals, view their shopping list, etc) from the self-scan shopping scene. Assuming that your app uses the standard iOS navigation bar, it is suggested that your self-scan shopping scene’s view controller explicitly set the navigation stack to just itself when the scene loads. It is further suggested that you explicitly define the “back” button to be an “Exit Store” button, implement the suggestion described in the “Exit Store”, and implement the suggestion described in the “Navigation Scenario: Return Home After Checkout” sub-section. To reset the navigation stack to be just the self-scan shopping scene and to explicitly render an “Exit Store” button in the self-scan shopping scene’s navigation bar, create a view controller class and associate it to the self-scan shopping scene via the XCode “Interface Builder” if you have not already done so:

Add the following code to the view controller’s “viewDidLoad” method: self.navigationController?.setViewControllers([ self], animated: false)

self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Exit Store", style: .plain, target: self, action: #selector(exitButtonPressed))

Page 65 of 148

Page 66: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Add the following code to define the “exitButtonPressed” method. @objc func exitButtonPressed() { let confirmationAlert = UIAlertController(title: "Exit Store Confirmation", message: "Are

you sure you want to exit the store? Any items in your cart will be removed.",

preferredStyle: .alert)

confirmationAlert.addAction(UIAlertAction(title: "I'm Sure", style: .default, handler:

{(action: UIAlertAction!) in SwiftShopperFramework.exitStore {

// NOTE: The AppDelegate listens to the "finishedShopping" event, which Swift // Shopper posts when the exitStore function successfully completes. The

// AppDelegate navigates back to the main menu.

}

}))

confirmationAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler:

{(action: UIAlertAction!) in }))

present(confirmationAlert, animated: true, completion: nil) }

By setting the navigation controller’s views to just the view controller’s “self”, the navigation bar would no longer feature a “back” button. However the logic in “viewDidLoad” then explicitly places an “Exit Store” button where the “back” button would be and arranges for the view controller’s “exitButtonPressed” method to be called when the “Exit Store” button is pressed. The “exitButtonPressed” method’s logic prompts the user for confirmation and calls SwiftShopperFramework. exitStore(...) upon confirmation. The Swift Shopper SDK then posts the “finishedShopping event” which the AppDelegate presumably listens for and subsequently navigates to user to the app’s main / home screen. The Swift Shopper SDK also posts the “finishedShopping” event if the user completes their purchase. Hence the app’s AppDelegate processes the “finishedShopping” event when the user either exists the store via the “Exit Store” button or completes their purchase. This strategy keeps the user inside the shopping experience until they are finished shopping. It is suggested that this strategy be combined with the strategy that is described in the “Navigation Scenario: User Leaves App While Shopping” to keep the user’s focused on self-scan shopping while the user is shopping at the store.

Page 66 of 148

Page 67: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Cart Widget Your app may optionally display the Swift Shopper Cart Widget. The Swift Shopper Cart widget is a small view that is about the size of a button that displays a small rendition of a shopping cart along with the count for the number of items that are currently in the shopping cart. It is encouraged that your app place the Cart Widget in the upper right hand corner of the “In Store Shopping” scene, and/or at the upper right hand corner of the navigation bar or other universal navigation mechanism that your app may use. You may do this programmatically from your view controller’s source code or from within the interface builder when editing a storyboard. From the interface builder simply add a UIView / view to a scene, define the necessary layout to place the view in the upper-left-hand corner (or any location of your choosing), and set the custom class name to SSCartButton and custom class module to SwiftShopperSDK (or programatically add a cart widget to the navigation controller that your app might happen to already use). From code, simply import SwiftShopperSDK and then from the view controller’s “viewDidLoad” method, add a SSCartButton object either as the view’s navigation controller’s right bar button, or to your view controller’s view hierarchy.

Example Assuming that your app is using an ordinary navigation controller, add the following code to the “viewDidLoad” method for your “In App Shopping” scene’s view controller class (or add this code to any view controller class that corresponds to any scene in your app where you wish to display a cart widget). This will place a cart widget in the upper right-hand corner of the scene assuming that scene is presented via an ordinary navigation controller: let ssCartButton = SSCartButton() ssCartButton.addTarget( self, action: #selector(cartButtonPressed), for: .touchUpInside)

self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: ssCartButton)

This code instantiates an SSCartButton view, which is provided by the SwiftShopperSDK. After that, this code programmatically configures the cart button such that the view controller’s “cartButtonPressed” method will be called when the cart button is tapped. (You will need to add a “cartButtonPressed” method to the same view controller class wherein you may provide the source code that executes when the cart widget is tapped.) Make sure that the view controller’s swift file has an import statement for SwiftShopperSDK:

Page 67 of 148

Page 68: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

import SwiftShopperSDK

Finally, add the following code to the view controller class to define the method that is called when the cart widget is tapped. Although the method is empty in this sample, the “Cart Scene” section guides you at displaying the “Cart Scene” when the “Cart Widget” is tapped:

@objc func cartButtonPressed() { }

Example The previous example adds a cart widget to the iOS navigation bar. The cart widget is just a custom view however. To place a cart widget on any scene or view within your app, simply add a UIView to the view hierarchy and set the custom class name for the view to SSCartButton. Set the custom class module to SwiftShopperSDK. The Cart Widget’s background color will be the background color that you define in the interface builder. If you do not define a background color or if you set the background color to ‘undefined’ then the cart widget’s background color will be the theme color that your app passed to the SwiftShopperFramework. initialize(...) method. The Cart Widget’s cart icon and text color will be white or black depending on whether the Swift Shopper SDK determines that the background color is very light. The cart icon and text color will be black if the background color is determined to be very light otherwise the cart icon and text color will be white. You may explicitly define the cart icon and text color by specifying a “foregroundColor” with a “Type” of “Color” in the “User Defined Runtime Attributes” section on the identity inspector.

Alternatively, you may set the cart icon and text color programmatically. From the view controller’s code that has a reference to a cart widget, simply assign a color to the cart widget’s “foregroundColor” variable / attribute. (You can set the “backgroundColor” too if you’d like.) Example:

import SwiftShopperSDK

...

Page 68 of 148

Page 69: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

let cartWidget = SSCartButton()

cartWidget.foregroundColor = UIColor.green

cartWidget.backgroundColor = UIColor.white

Cart Scene It is customary for shopping apps to display the contents of the user’s cart when the user taps a cart icon for those apps that provide a cart icon. The ‘Cart Widget’ section in this document explains how to display a cart icon either on a scene or a scene’s navigation bar within your app. In conjunction with the cart widget, you may create a ‘Cart Scene’ that will display the user’s cart contents when the cart widget is tapped. Simply create a scene. Perhaps name the scene as ‘Cart Scene’. Add a plain view (UIView) to your scene’s view hierarchy (or use the default ‘view’ that XCode creates within any view controller / scene after adding the view controller / scene to the storyboard. Size the view to provide a decent amount of real estate from the screen, perhaps even size the view to fill the entire screen minus any real-estate that your app uses for providing menus, navigation, etc. (If you decide to use the default ‘view’ whta XCode creates for the view controller / scene then the view will naturally occupy the entire screen). Set the custom class’s class for the view to SSCartView. Set the custom class’s module to SwiftShopperSDK. Although step-by-step illustrations are not provided, please see the “In Store Shopping” and “Select Market” sections within this document for similar steps at creating a scene, adding a basic view (UIView) to the scene, setting the view’s custom class & module to a view provided by the Swift Shopper SDK, and navigating to and from the scene. Add or update the on-click handler for the ‘Cart Widget’ (as explained in the ‘Cart Widget’ section) and provide the code that navigates the user to the Cart Scene when the ‘Cart Widget’ is tapped. The Swift Shopper framework displays the user’s cart contents and a checkout button inside your app’s Cart Scene. It is also suggested that you provide a navigation means on the cart scene for the user to navigate back to the previous scene. Depending on how your app performs its navigation, you app might receive this functionality automatically (for example, if the scene that navigates to the “Cart Scene” is already inside of a navigation controller, then a navigation bar likely appears already at the top of the app, and that navigation bar would likewise encompass the “Cart Scene” while automatically rendering a ‘back’ button.) It is also suggested that you consider adding an “Exit Store” button as the upper right navigation button for the cart scene, to allow the user the opportunity to exit the store even when viewing their cart’s contents. (See the “Exit Store” section for instructions for adding an “Exit Store” button to your app) Discussion: It is customary for apps that display a shopping cart-like widget to display that cart’s contents when the shopping cart-like widget is displayed. Although the “In Store Shopping”

Page 69 of 148

Page 70: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

scene shows the cart’s contents, the “cart scene” does not allowing scanning new items to the cart. Instead, the “cart scene” displays the contents within the cart in read/view-only fashion and provides a fully-implemented “checkout” button that allows the user to complete their purchase. Since users are accustomed to some basic behavior occurring when they tap a shopping cart-like widget, the Cart Scene is a good way to easily provide this basic customary behavior in your app when the “cart widget” is tapped.

Page 70 of 148

Page 71: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Exit Store The Swift Shopper Framework will automatically exit from the store when the user completes checkout from within your app. You should consider also providing a navigation means for the user to prematurely exit the store without completing their checkout. This is useful as this allows the user to change their mind about shopping in the store. To exit prematurely from the store, add the following code to the callback mechanism that is connected to an “exit store” navigation mechanism that you will add to your app. For example, “Exit Store” can be a navigation button (UIBarButtonItem) that one or more view controller classes within your app could define to appear in the left or right side within the app’s navigation bar: SwiftShopperFramework.exitStore(completion: { // Code promised to be executed after the exit operation completes }) Notice that the SwiftShopperFramework’s exitStore function is passed a ‘completion’ handler. In this completion handler you should navigate the user to your app’s main / home scene and consider re-assigning your navigation controller’s views to consist of just the main / home scene so as to prevent the user from being able to navigate ‘back’ into the store. (The idea is that the user exited the store and would therefore have to go back through the navigation process to officially “shop” again at the store.) The “exitStore” function clears the user’s cart and undoes the most recent check-in at the current shopping location. It is also highly suggested that you prompt the user for confirmation, just in case the user accidentally taps the exit button, since otherwise the user’s cart will be cleared.

Example Assuming that your app uses an ordinary navigation controller for back navigation, the following example replaces the ‘< Back’ button that would otherwise appear in the upper left of the scene with an ‘Exit Store’ button. Update the source code in your “In App Shopping” scene’s “view controller” class as follows. Add the following code to the ‘viewDidLoad’ method: self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Exit Store", style: .plain, target: self, action: #selector(exitButtonPressed))

Page 71 of 148

Page 72: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

This sets the upper left navigation button to an “Exit Store” button that calls the view controller’s “exitButtonPressed” method when the “Exit Store” button is clicked. Note that all iOS view controller classes have a self.navigationItem reference which can be used to customize the navigation bar that typically appears at the top the scene as rendered when the app runs (assuming that the view controller / scene is either embedded in a navigation controller or presented from another view controller / scene that is embedded in a navigation controller). Add the following method to the same view controller class that is associated to a scene on which you’d like to add an “Exit Store” button. This is the callback method that the previous code sample causes to be called when the ‘Exit Store’ button is pressed: @objc func exitButtonPressed() { let confirmationAlert = UIAlertController( title: "Exit Store Confirmation",

message: "Are you sure you want to exit the store? Any items in your cart will be removed.", preferredStyle: .alert)

confirmationAlert.addAction( UIAlertAction( title: "I'm Sure", style: .default,

handler: {(action: UIAlertAction!) in SwiftShopperFramework.exitStore(completion: {

// NOTE: The AppDelegate listens to the "finishedShopping" event, which // Swift Shopper posts when the exitStore function successfully completes.

// The AppDelegate navigates back to the main menu

})

}))

confirmationAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel,

handler: {(action: UIAlertAction!) in }))

present(confirmationAlert, animated: true, completion: nil) }

This code will be called when the “Exit Store” button is tapped. This code prompts the user for confirmation. Upon confirmation, this code calls the SwiftShopperFramework’s exitStore(...) function passing in a callback handler. Although the callback handler does nothing in this example, the Swift Shopper SDK always posts the “finishedShopping” event during the call to SwiftShopperFramework. exitStore(...). This example assumes that your AppDelegate is already listening for the “finishedShopping” event and navigating the user back to the app’s main scene as a result. See the subsection “Navigation Scenario: Return Home After Checkout” for guidance at configuring your app to navigate to the main scene upon notification of the “finishedShopping” event that the Swift Shopper SDK posts whenever the user leaves the store either via the SwiftShopperFramework. exitStore(...) mechanism or via the user completing their in-store purchase. Also see the subsections “Navigation Scenario: Keeping the User Inside Self-Scan Shopping” and “Navigation Scenario: User Leaves App While Shopping” as these topics are inter-twined

Page 72 of 148

Page 73: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

(exiting the store, leaving the app while shopping but then returning to the app while shopping, returning home after checkout, and keeping the user inside self-scan shopping while they are are shopping).

Page 73 of 148

Page 74: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Order History It is customary for apps that provide a shopping experience to also provide a means for the user to view details about previous purchases that the user has made from the app. The Swift Shopper SDK provides a custom view class that can be added to any scene within your app to display the user’s order history. This view presents a list of the user’s most recent orders for any stores at the retailer to which your app is registered (via your app’s Swift Shopper SDK Key). The user may tap any item within the “order history” list to view details about the selected order. This functionality is provided automatically via the Swift Shopper SDK. Perhaps the most challenging part to you (the app developer) will be to decide from where within your app to provide the user the option to view their order history. For example, Swift Shopper’s apps tend to feature a “hamburger” menu that is available on strategic screens within the app located in the upper left of the navigation bar. Swift Shopper’s apps then tend to place an “Order History” item in the “hamburger” menu. It is up to you to decide whether to allow your users to view their order history, and where in your app you’d to present the user with the option / navigation means to view their order history. The procedure for constructing the order history screen is essentially the same as the procedure for creating the “Cart Scene”, or any scene that displays a scene via the Swift Shopper SDK:

1. Add a scene to the storyboard (or you may even reuse an existing scene if you’d prefer). 2. Add a view to the scene (or use the “default” view that XCode generates automatically). 3. Set the view’s custom class name to “SSOrderHistory”. 4. Set the view’s custom class module to “SwiftShopperSDK”

5. Identify where in your app the option to view order history should be presented (perhaps

from a “hamburger” menu or anywhere that you choose.)

Page 74 of 148

Page 75: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

6. Add a button, navigation button, etc. labelled “Order History” (or perhaps you may

choose to render the button as an icon or graphic that represents “order history”). 7. Add a connection or handler to the chosen button, navigation button, etc with source

code that navigates the user to the “Order History” scene after the button is tapped. 8. Consider designing the app so that any existing navigation controller / bar will naturally

extend around the “Order History” scene thereby providing ‘back’ navigation automatically (or otherwise design the navigation means for the user to subsequently use to navigate away from the “Order History” scene when the user is finished viewing their order history).

Page 75 of 148

Page 76: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Shopping Lists In addition to self-scan mobile checkout, Swift Shopper provides functionality that allows users to create shopping lists. A user may create any number of named shopping lists and add shopping items to their shopping lists. The list sharing feature is available if the user is logged into Swift Shopper via the app (as opposed to being logged in anonymously). Users may create, edit, update, and share lists even if the user is not currently shopping at a store via the app. When checked into a store, the user interface for the shopping list functionality is customized to help the user to shop using their shopping lists as a guide. For example, the Swift Shopper SDK renders a small scanner button next to each item in the user’s shopping list. When the user taps the small scanner button next to a shopping list entry, the Swift Shopper SDK presents the scanner screen whereby the user may scan a barcode. The Swift Shopper SDK then knows that the shopping list entry has been scanned to the user’s cart. When the user completes checkout at the store via the app, the shopping list entry will automatically be crossed off of the shopping list. Moreover, if the shopping list is a shared list, the same shopping list entry will likewise be crossed off the list when another user views the same shared list. (This allows members of the same household, for example, to know that somebody else has purchased the item.) Although shopping lists are a nice feature that your app may choose to provide, a complexity arises when your app presents the shopping experience to the user. Some users may wish for a simple self-scan shopping experience that is equivalent to the “In App Shopping” scene described in the “Basic In-Store Shopping” section, whereas other users may wish for a customized shopping experience that is integrated with their shopping lists. Hence, the complexity involved is to provide the user the choice of shopping either with integrated list support or via the simplified “In App Shopping” experience as described in the “Basic In-Store Shopping” section.

Page 76 of 148

Page 77: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Scenario: View/Edit Shopping Lists (Support Only When Not Shopping) Simply add a UIView / View to any scene in a storyboard, give the view a decent amount of real estate on the screen, set the custom class name to SSListView, and set the custom module name to SwiftShopperSDK. Provide a means for the user to navigate to the scene. Assuming that the app is not checked into a store, the user will then experience full shopping list support when the user views the corresponding scene in the app.

Scenario: View/Edit Shopping Lists (Support Only While Shopping) The same SSListView that is described in the previous section can be used to provide the user with a customized shopping experience. Simply display the scene after rendering the Select Market Scene (multiple retailer store support) or after your app calls the SwiftShopperFramework. enterStore(...) function as described in the Basic Self-Scan Shopping / Single Location Support. The SSListView will then render itself slightly differently. The user will still be able to view and edit their shopping lists. In addition, the user will see a “Scan to Cart” button and checkout button located within the SSPlanView; along with a small scanner button beside the items in their shopping lists. Any scanned items will be added to the shopping cart and automatically crossed off of the user’s shopping lists. The user can initiate checkout directly from the SSListView to pay for their groceries in the app or at the register without having to scan the items at the cash register in the store.

Scenario: View/Edit Shopping Lists (Support When Either Shopping or Not Shopping) To support shopping lists either when checked into a store or when not checked into a store, it is suggested that you use a single scene for the shopping list. Provide a means to navigate to this scene when checked into a store and also when not checked into a store. The SSListView in the scene will render itself appropriately when the app is checked into a store versus not checked into a store.

Page 77 of 148

Page 78: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Although the SSListView renders itself appropriately when the app is checked into a store versus not checked into a store, it is suggested that the scene include a cart widget when the scene is rendered and the user is checked into a store. It is suggested that the scene’s title should perhaps be updated to indicate that the user is shopping from a list when the scene is displayed and the user is checked into a store. Conversely, it is suggested that the scene’s title should perhaps indicate that the user is viewing / editing or “planning” their shopping list when the scene is displayed yet the user is not checked into a store. You should also consider providing a means for the user to switch back and forth between the self-scan scene and the shopping list scene when the user is checked into a store. In addition, you should consider providing a means to view in-store deals from the self-scan scene and the shopping scene if your app provides the user the ability to view in-store deals.

Page 78 of 148

Page 79: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Shared Shopping Lists The SSListView features a share button that a user may click to share their list with another user. As default functionality, when this happens a text or email message with a URL link is generated and passed to iOS. iOS then prompts the user whether to share via text or email. The user chooses text or email. iOS then walks the user through the process of texting or emailing the message to the other user. The other user then receives the message, clicks the link in the message, your app then opens on the other user’s device, and the first user’s list is imported into the second user’s instance of your app.

Minimal Behavior Needed From Your App Your app needs to do the following to minimally support the second user when the second user taps the link that the second user receives from the first user in the use case scenario described in the previous section:

● Call SwiftShopperFramework. application(app, url, options) from your app delegate’s application(UIApplication, URL, options) entry point callback. Your app delegate’s application(UIApplication, URL, options) entry point will be called when the second user taps on the link that they receive from the first user when the first user shares their shopping list with the second user.

● From your app delegate’s “application(UIApplication, URL, options)” callback, after calling SwiftShopperFramework. application(app, url, options), check the boolean return value. Automatically navigate the user to your app’s scene for list planning if “true” is returned and if the lower-cased URL starts with “sslistshare://”. Or if the user is currently checked into a store, automatically navigate to your app’s scene for shopping from the user’s shopping list if your app uses a different scene for shopping from a user’s shopping list versus planning / viewing / editing shopping lists.

Although this minimal behavior allows a user to share a list with another user, this minimal behavior does not help the second user by bringing the second user to the App Store to install your app if the second user receives a shared list but does not have your app installed. Instead, this mechanism simply instructs the second user to install your app if needed, and then tap the link that the second user receives from the first user. However, if you need to implement Swift Shopper as quickly as possible, and if you do not care about this limitation, then you may leverage this minimal behavior to have your app up and running with shared list support in about an hour or less of development effort.

Page 79 of 148

Page 80: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Optimized Behavior Suggested From Your App The default (minimal) behavior described so far is not the most ideal nor the most seamless of a user experience when the second user taps the link that the second user receives from the first user. The default minimal behavior’s text / email message provides a link that the receiving user may tap assuming that the user has already installed your app. However, the user will need to understand and know how to install your app, and then click the link after the app is installed. It would be better if the second user could simply tap the link that the second user receives and then be walked through whatever might need to happen in order for the second user to access the first user’s shopping list. Your app will need to do some more work in order to support this ideal, seamless integration. A third-party service called Branch IO provides the functionality that you will need. Depending on whether or not you are familiar with Branch IO, and depending on how much experience you have at receiving and handling URLs in your AppDelegate, this procedure could take anywhere from perhaps 4 hours to 2 or 3 days to develop. Here are the steps:

Sign-up For an Account With “Branch.io” ● Visit https://branch.io ● Sign up for a developer account ● Familiarize yourself with the branch.io development documentation ● Add your app to your developer account ● Configure your app’s link settings within branch.io (as described in the branch.io

developer documentation) ● Download your app’s branch.io key file. ● Add ‘branch’ to your app’s list of pods and run pod install from the command line (as

described in the branch.io developer documentation) ● Add your app’s branch.io key to the info.plist file (as described in the branch.io developer

documentation)

Customize the Text / Email Message from First User to Second User ● Find or add a view controller class that is associated to the scene(s) in your app that

provide an SSListView within the view hierarchy. ● Make the class implement the SSListViewDelegate protocol interface ● Create a reference outlet in your view controller to the SSListView ● Set the list view’s delegate to your view controller ● Implement the shared(listId: String, type: ShareType) method in your view controller. ● Use branch.io to generate a deep link URL that encodes the given listId and type.raw

value. ● Construct a custom message for the first user to send to the second user

Page 80 of 148

Page 81: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

● Add the deep link URL ● Place the custom message and the deep link URL inside an array of type “Any”, and

pass to UIActivityViewController to entice iOS to present a dialog that allows the first user to send this message to the second user.

● See code example on the next page

Page 81 of 148

Page 82: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

import branch

...

extension YourAppShoppingListVC: SSListViewDelegate {

func shared(listId: String, type: ShareType) {

let branchUniversalObject: BranchUniversalObject = BranchUniversalObject(canonicalIdentifier: "item/\(listId)")

branchUniversalObject.title = "Replace With the Common Name of Your App"

branchUniversalObject.contentDescription = "Hey checkout my list with

<<Replace With the Common Name of

Your App>>!"

// Add custom data values that encode the list id & raw share type, so that // whenever the second user opens the app via the shared link, the second user’s

// app receives the list id & raw share type that corresponds to the first user’s

// list

branchUniversalObject.contentMetadata.customMetadata = [

"list_id": listId,

"type": type.rawValue, "link_type": "1", "uri_redirect_mode": "1"]

let linkProperties: BranchLinkProperties = BranchLinkProperties() linkProperties.feature = "share"

linkProperties.channel = "social media"

// Set your app store url here // This will help ensure that the second user is taken to the app store to

// download your app if the second user does not have your app installed

linkProperties.addControlParam("$ios_url", withValue:

"https://itunes.apple.com/us/app/

your-app-path-in-itunes/idXXXXXXX?mt=8")

linkProperties.tags = ["Created from: <<Replace With the Common Name of Your

App>>"]

branchUniversalObject.getShortUrl(with: linkProperties) { (url, error) in if error == nil && url != nil { let textToShare = "Hey checkout my list with <<Replace With Common Name of Your App>>!"

if let deeplinkUrl = URL(string: url!) { let objectsToShare = [textToShare, deeplinkUrl] as [ Any] let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) activityVC.setValue("<<Replace With Common Name of Your App>>

Share List", forKey: "subject")

UIApplication.topViewController()?.present(activityVC,

animated: true, completion: nil) }

}

}

}

}

Page 82 of 148

Page 83: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Detect When the Second User Clicks the Shared List Link Background The previous section shows how to implement your app so that the first user sends a text or email message to the second user when the first user decides to share their list. When the second use receives the text or email and subsequently clicks the URL link that is in the text or email, a Branch I/O web site is retrieved in the user’s web browser. Branch IO then executes some logic in the user’s web browser that ascertains whether the app is installed. The second user is taken to screen within the App Store for downloading your app if the second user does not have your app installed. Branch IO leverages an Apple iOS feature known as “universal (https) links” to essentially ask iOS to pass a URL with URL parameters to your app when the second user launches the app after installing your app. To support the “universal (https) link” feature, Branch IO will instruct you via Branch IO’s developer documentation to register an “entitlement” into your app that specifies the beginning portion of the “universal (https) link”. Hence, when the second user taps the link in the message / email, the link is a specially formatted iOS universal link. Since the iOS app is registered with an entitlement that specifies the beginning portion of the universal https link, iOS launches your app and passes the entire URL, including the URL parameters, into your app if your app is installed. Otherwise, iOS navigates the user to your app’s download page in the App Store. After installing your app and launching your app for the first time, iOS passes the same URL, including the URL parameters into your app. The universal https link’s URL parameters encode the shared list id and shared list type parameters, which the Swift Shopper SDK needs in order to import the shared list into the second user’s login. Development Steps

● Update your app delegate file to initialize the Branch IO library when your app starts. ● Pass a “deepLinkHandler” callback function into the Branch IO initialization mechanism. ● Your “deepLinkHandler” callback function receives the URL parameters for any Branch

IO links that a user invokes, which ultimately are passed into your app’s app delegate. ● Extract the shared list id and shared list type from the params that are passed to the

“deepLinkHandler”. ○ Either: Pass these into the SwiftShopperFramework.importList(...) function and

then navigate the user to your app’s scene that renders the shopping list ...or…

Page 83 of 148

Page 84: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

○ Stash away these values as member variables, perhaps statically via some class that your shopping list view controller can later access. Navigate your user to the shopping list screen, and have your shopping list screen’s view controller immediate pass these values into its SSListView’s “downloadShared(...)” method from the view controller's “viewDidLoad()” method. Clear these values after passing them into the “downloadShared(...)” method so as to avoid attempting to always import the shared list for any subsequent visits to the shopping list scene.

● Update your app delegate file to receive the application(...) callback for the universal link, as instructed in the Branch IO documentation.

○ iOS passes a “user activity” object to your app delegate. ○ Pass the “user activity” to the Branch IO library’s “continue(...)” method

● Branch IO will then parse the universal link, which is encapsulated in the “user activity” object, and ultimately call your “deepLinkHandler” callback passing in the universal https links’s URL parameters.

Sample Code (For Your App Delegate to Initialize Branch IO and respond to Universal Links) import Branch …

func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { …

// After initializing the Swift Shopper SDK, etc…

let branch: Branch = Branch.getInstance() branch.initSession(launchOptions: launchOptions,

automaticallyDisplayDeepLinkController: true, deepLinkHandler: { [weak self] params, error in if error == nil { let deepLinkMetadata = params as! [String: Any] print("params: %@", deepLinkMetadata)

if let listId = deepLinkMetadata["list_id"] as? String, let type = deepLinkMetadata["type"] as? String { UserDefaultManager.branchIOSharedListId = listId

UserDefaultManager.branchIOSharedListType = type

// TODO: Navigate to the shopping list scene, update the view controller // for the shopping list scene to pass the check if the listId and type

// variables are available and if so, pass them into its SSListView’s

// “downloadShared(...)” method, and clear the listId and type vars

}

}

})

}

Page 84 of 148

Page 85: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Sample Code (For Your Shopping List Scene to Load the Shared List): import SwiftShopperSDK

class YourAppShoppingListVC : UIViewController {

@IBOutlet weak var ssListView: SSListView! …

override func viewDidLoad() {

// After the view controller’s ordinary user interface initialization code

if let user = SwiftShopperFramework.getUser(), !user.isAnonymous, let listId = UserDefaultManager.branchIOSharedListId, let type = UserDefaultManager.branchIOSharedListType, let shareType = ShareType(rawValue: type) { // Imports the shared list to the user’s account, switches to the shared list, and

// displays the shared list in the SSListView

ssListView.downloadShared(listId: listId, shareType: shareType)

UserDefaultManager.branchIOSharedListId = nil UserDefaultManager.branchIOSharedListType = nil }

}

}

Sample Code (For Your App Delegate to Receive the Universal Link): NOTE: iOS calls this function to pass the universal https link into your app. The universal https link is encapsulated in the given userActivity object. import Branch …

func application( _ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { // pass the url to Branch IO, which will then call the deepLinkHandler that // was passed to Branch IO when this app initialized Branch IO

Branch.getInstance().continue(userActivity)

return true

} Fallback Non-Universal Link Support As previously described, when the second user invokes the link that the second user receives in the text / email from the first user, a web page from Branch IO is executed in the second user’s web browser. The Branch IO logic in that web page attempts to perform deep link functionality to pass the shared list id and shared list type into your app, having the user install your app from

Page 85 of 148

Page 86: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

the App Store if needed. The Branch IO logic attempts to leverage iOS universal links for this functionality. It is important to note that Branch IO falls back to using a non-universal link mechanism if the Branch IO logic detects that universal links are not supported on the user’s device. This could be the case if the user’s device is an old device running an iOS version that is earlier than iOS 9. This could also be the case if the user’s device decides to execute the shared link via a browser that might not support the iOS universal https link mechanism. (The web browser would certainly be a browser other than Safari in this type of scenario). To support this fallback mechanism, you’ll need to implement / update the corresponding callback into your app delegate that receives the fallback non-universal link URL. Sample Code (For Your App to Handle the Fallback Non-Universal Link) // Code For Your AppDelegate.swift file

import Branch

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

// Pass the URL to the SwiftShopperSDK in case the URL is a custom swift shopper

// login, apple pay, etc URL

SwiftShopperFramework.application(app, open: url, options: options)

if url.scheme == " <<Your App’s Custom Protocol that Branch IO Instructs You to Choose>>" { // pass the url to the handle deep link call Branch.getInstance().handleDeepLink(url)

return true }

}

More Notes About Branch IO As of the time that this document is being authored, the comprehensive deep link functionality that Branch IO provides is free. All you have to do is sign up for a developer account and follow the Branch IO development instructions. Swift Shopper has absolutely no affiliation with Branch IO. In theory anybody can implement all of this deep link and universal https link functionality themselves without using Branch IO. However, since Branch IO has already solved this problem, and since Branch IO provides this solution for free, Swift Shopper therefore suggests using Branch IO to achieve this functionality. In fact, Swift Shopper uses Branch IO for all Swift Shopper apps that support a user receiving a shared list from another user.

Page 86 of 148

Page 87: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Viewing Deals Swift Shopper retailers may integrate their advertised deals into the Swift Shopper infrastructure. For any such retailer, your app may provide a means for the user to browse the advertised deals that are currently available at the retailer. The process for displaying the retailer’s current deals is similar to the process for displaying any of the Swift Shopper SDK’s graphical screens, such as the process described for the “Cart Scene”:

1. Create a scene (or identify an existing scene to reuse) 2. Add a view (or use the ‘default’ view that XCode automatically creates for new scenes) 3. Set the custom class name to SSDealView 4. Set the custom class module to SwiftShopperSDK 5. Add a means within your app for the user to navigate to see the deals 6. Ensure that a navigation mechanism exists for the user to “go back” or otherwise

navigate away after viewing the deals. Note that if the app is checked into a store, the user will have an option to scan any deal into the shopping cart. Therefore, it is suggested that the “Cart Widget” be placed even on the deals screen. However, if your app presents the deals screen even when the user is not shopping in a store then your app should hide or otherwise not display the “Cart Widget” unless the user is currently checked into a store (assuming your app features a “Cart Widget” on its “deals” screen). See the “Select Market” subsection under “Basic Shopping” for details about tracking whether the user is currently checked into a store.

Page 87 of 148

Page 88: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

User Profile It is customary for apps that include a means for the user to “log in” to also provide a mechanism for a user to view their user profile. The Swift Shopper SDK features a custom view that your app may place on a scene that your app may provide for the user to view their profile. Your app will need to display the user’s name, photograph, or other information about the user. Your app’s profile scene may then also include a custom view via the Swift Shopper SDK that displays the following:

● The number of times that the user has entered a store via your app. ● The number of items that the user has ever scanned while shopping at a store via your

app. ● The number of times that the user has completed check-out at a store via your app.

The process for displaying the user’s profile is similar to the process for displaying any of the Swift Shopper SDK’s graphical screens, although you will need to go out on your own to display the user’s name, email, login, or other information about the user upon your apps profile scene.

1. Create a scene (or identify an existing scene to reuse) 2. Add views that illustrate any information about the user that you wish to display.

(Presumably your organization, or the retailer for which you are developing the app has a database of users, a means to register users, a means to retrieve data about users, etc.)

3. Add a view to an area of the scene in which to render the Swift Shopper shopping data. 4. Set the custom class name to SSProfileView 5. Set the custom class module to SwiftShopperSDK 6. Add a means within your app for the user to navigate to view their profile 7. Ensure that a navigation mechanism exists for the user to “go back” or otherwise

navigate away after viewing their profile.

Page 88 of 148

Page 89: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 1: Class Reference

SwiftShopperFramework

Purpose The SwiftShopperFramework class provides static functions that your app calls to integrate with the Swift Shopper SDK.

Static Functions

Function

initialize Your app needs to call the initialize function from its AppDelegate.application(application, didFinishLaunchingWithOptions) -> Bool callback that iOS calls when the app is launched.

Parameters

Name: Type: Description:

key String Your app is presumably being developed on behalf of a particular Swift Shopper partner SDK retailer. Each such partner retailer is assigned an SDK key. The retailer’s SDK key needs to be passed into the initialize function as the ‘key’ parameter.

color UIColor The Swift Shopper SDK provides numerous custom views that your app incorporates into the app’s various scenes or view controllers. These custom views render themselves to match your app’s general appearance using this color as the theme color.

didFinishLaunchingWithOptions

[UIApplication.LaunchOptionsKey: Any]?

iOS passes an array of launch options to your AppDelegate. Your AppDelegate should pass these same launch options to the initialize function.

icon UIImage The Swift Shopper SDK will render this in the center of the navigation bar where appropriate for any full screen views, such as the views that are presented during the in-store checkout process.

Page 89 of 148

Page 90: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

logo UIImage? Optional Parameter: If provided, the Swift Shopper SDK will render this image instead of the icon on any Swift Shopper user interface views when rendering the retailer’s logo, such as on the ‘confirm login’ screen.

fontName String? Optional Parameter: If provided, the Swift Shopper SDK will render most text using this font face, with the exception being fonts such as the font for the “Sign-in with Twitter” button which must be rendered using Twitter’s required font face. The corresponding font file must be embedded in your app unless the font is a standard iOS font. The value for this parameter must match the font name that is embedded within the corresponding font file.

stringReplacements [String: String]?

A mapping of string keys to string values. Your app may override just about any static text that the Swift Shopper SDK renders among its various custom views that are available for your app to render. Each segment of text is identified by a string key. Your app may override any such segment of text by specifying a replacement value for the particular string key. See Appendix 5 for a list of the available string keys that your app can override. It is suggested that your app define such a string mapping for each language that your app provides. Prior to calling the initialize function, your app should check which language the user understands and pass the corresponding string replacements mapping into the initialize function.

Return Value

None

Page 90 of 148

Page 91: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

application <<User Activity>> Your app needs to call this overloaded version of the application function whenever iOS invokes the corresponding application function in your app’s App Delegate and pass the same parameters that iOS passes into your App Delegate’s application function.

Parameters

Name: Type: Description:

application UIApplication iOS passes this object into your app’s corresponding application function. Your app needs to pass this same value into the SwiftShopperFramework’s corresponding application function.

userActivity NSUserActivity iOS passes this object into your app’s corresponding application function. Your app needs to pass this same value into the SwiftShopperFramework’s corresponding application function.

restorationHandler @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool

iOS passes this object into your app’s corresponding application function. Your app needs to pass this same value into the SwiftShopperFramework’s corresponding application function.

Return Value

Type: Description:

Bool

Returns true if Swift Shopper successfully consumed and acted upon the given data. Returns false if Swift Shopper ignored the given data.

Page 91 of 148

Page 92: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

application <<URL>> Your app needs to call this overloaded version of the application function whenever iOS invokes the corresponding application function in your app’s App Delegate and pass the same parameters that iOS passes into your App Delegate’s application function.

Parameters

Name: Type: Description:

application UIApplication iOS passes this object into your app delegate’s corresponding application function. Your app needs to pass this same value into the SwiftShopperFramework’s corresponding application function.

open URL iOS passes this object into your app delegate’s corresponding application function. Your app needs to pass this same value into the SwiftShopperFramework’s corresponding application function.

options [UIApplication. OpenURLOptionsKey : Any]

iOS passes this object into your app’s corresponding application function. Your app needs to pass this same value into the SwiftShopperFramework’s corresponding application function.

Return Value

Type: Description:

Bool

Returns true if Swift Shopper successfully consumed and acted upon the given data. Returns false if Swift Shopper ignored the given data.

Page 92 of 148

Page 93: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

login <<social media token>> Logs the user into Swift Shopper using a social media token that your app receives via your app’s custom user interface (not provided by Swift Shopper) for social media login. NOTE: The Swift Shopper SDK provides social media login via the SSLoginView without you having to call this function. Your app would only need to call this method if your app prefers to implement the social media login flow using its own customized user interface.

Parameters

Name: Type: Description:

socialMediaType

SocialMediaType

Identifies the social media type. Valid choices are: .facebook, .google, or .twitter.

uniqueToken

String

The social media token that your app receives from the corresponding Facebook, Twitter, or Google (Firebase) library just after the user successfully completes social media login.

userId

String

A globally unique user id for the user. This can be obtained via the social media provider’s API.

email String? Optional Parameter: The user’s email address. Although this parameter is optional, it is strongly suggested especially if the app uses Swift Shopper for in-app payments since Swift Shopper automatically emails receipts to the user’s email for any in-app payments that occur. Since your app has the user’s social media token from the social media provider, your app can call into the social media provider’s API using the social media token to ascertain the user’s email. This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the

Page 93 of 148

Page 94: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

user.

firstName String Optional Parameter: The user’s first name. This value is used to personalize the user interface. Since your app would have the user’s social media token from the social media provider, your app could call into the social media provider’s API using the social media token to ascertain the user’s name. Depending on the social media provider, your app might be able to ascertain the firstName directly or your app might need to instead ascertain the user’s display name and then parse out the first word as the firstName (and then assume that the remaining words are the user’s lastName). This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

lastName String Optional Parameter: The user’s last name. This value is used to personalize the user interface. Since your app would have the user’s social media token from the social media provider, your app could call into the social media provider’s API using the social media token to ascertain the user’s name. Depending on the social media provider, your app might be able to ascertain the lastName directly or your app might need to instead ascertain the user’s display name and then parse out the first word as the firstName (and then assume that the remaining words are the user’s lastName). This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

gender String

Optional Parameter: The user’s gender. Swift Shopper does not currently use this value, but may be used in the future to personalize the user interface. For example, if a female user shares a list with another user, and adds an item to the list afterwards, the other Swift Shopper could notify the user that “Kate added milk to her list.” Since your app would have the user’s social media token from the social media provider, your app could call into the social media provider’s API using the social media token to ascertain the user’s gender. However, social media providers generally consider the user’s gender to be a

Page 94 of 148

Page 95: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

sensitive field that might require your organization to submit itself to be vetted by the social media provider. If you already need to go through this process for your own needs, and therefore if you have access to this value anyway, you may pass this value into this function call. Otherwise you may safely omit this value from this function call. This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

imageUrl String Optional Parameter: A string that encodes an HTTP or HTTPS URL that can be invoked to get the user’s profile photograph. This value is used within the SSProfileView which your app may use to present a profile screen. This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

onSuccess @escaping (SSUser) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon successful completion of the login. This callback receives an SSUser reference to successfully the logged in user. This callback function has no return value.

onFailure @escaping (SSError) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon unsuccessful completion of the login. This callback receives an SSError reference that describes the failure.

Return Value

None, however, the given onSuccess or onFailure callbacks are called to indicate the result.

Page 95 of 148

Page 96: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

login <<custom login>> Performs a completely custom Swift Shopper login for an app user using a unique user id that the retailer or the retailer’s developer crafts that uniquely identifies the particular user. NOTE: This function is intended for retailers that maintain their own user database, their own means of registering users, their own means to allow a user to sign-in to the retailer, etc.

Parameters

Name: Type: Description:

userId

String

A globally unique user id for the user within the retailer’s infrastructure.

email String? Optional Parameter: The user’s email address. Although this parameter is optional, it is strongly suggested especially if the app uses Swift Shopper for in-app payments since Swift Shopper automatically emails receipts to the user’s email for any in-app payments that occur. This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

firstName String Optional Parameter: The user’s first name. This value is used to personalize the user interface. This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

lastName String Optional Parameter: The user’s last name. This value is used to personalize the user interface.

Page 96 of 148

Page 97: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

gender String

Optional Parameter: The user’s gender. Swift Shopper does not currently use this value, but may be used in the future to personalize the user interface. For example, if a female user shares a list with another user, and adds an item to the list afterwards, the other Swift Shopper could notify the user that “Kate added milk to her list.” This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

imageUrl String Optional Parameter: A string that encodes an HTTP or HTTPS URL that can be invoked to get the user’s profile photograph. This value is used within the SSProfileView which your app may use to present a profile screen. This value is retained upon the SSUser object that your app may use as your app sees fit, which can be attained by calling SwiftShopperFramework.getUser(). Hence your app would not have to store this value if your app passes this value to the SwiftShopperFramework when logging in the user.

onSuccess @escaping (SSUser) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon successful completion of the login. This callback receives an SSUser reference to successfully the logged in user. This callback function has no return value.

onFailure @escaping (SSError) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon unsuccessful completion of the login. This callback receives an SSError reference that describes the failure.

Return Value

Page 97 of 148

Page 98: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

None, however, the given onSuccess or onFailure callbacks are called to indicate the result.

Function

login <<loyalty token>> Performs a Swift Shopper login via a participating loyalty program’s loyalty token. This function is intended for retailers who use a participating Swift Shopper loyalty partner as their loyalty provider for those loyalty providers that maintain the retailer’s user database. This is similar to a login via a social media token with the difference being that your app would utilize the loyalty provider’s API to login the user. Your app would perhaps prompt the user for their phone number or loyalty card number. Your app would then query the loyalty provider via the loyalty provider’s API to look up the user. The loyalty provider’s API would return a loyalty token to your app. Your app would then pass the loyalty token into this overloaded SwiftShopperFramework. login(...) method to log the user into Swift Shopper. NOTE: This function only takes the loyalty token as a parameter. This function is for participating Swift Shopper loyalty partner programs. Swift Shopper will query the loyalty provider via the loyalty provider’s API to ascertain the user’s unique user id, email, first name, last name, profile photo URL, etc.

Parameters

Name: Type: Description:

loyaltyToken

String

A partner loyalty provider’s token that represents the user that is logging into the app.

onSuccess @escaping (SSUser) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon successful completion of the login. This callback receives an SSUser reference to successfully the logged in user. This callback function has no return value.

onFailure @escaping (SSError) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon unsuccessful completion of the login. This callback receives an SSError reference that describes the failure.

Return Value

Page 98 of 148

Page 99: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

None, however, the given onSuccess or onFailure callbacks are called to indicate the result.

Function

loginAnonymous Logs the app user anonymously into SwiftShopper. An app must at least log a user in anonymously in order for the user to use Swift Shopper user interface components. There are drawbacks to anonymous login though. For example, Swift Shopper will have no means to identify the same user if the same user runs your app on another device. Hence the user’s order history cannot possibly be synchronized between multiple devices that the user uses. In addition, shared shopping lists are not available for anonymous users. In addition, Swift Shopper will not be able to email a payment receipt to the user when the user completes an in-app purchase since Swift Shopper does not know the anonymous user’s email address. Despite these drawbacks, an app may invoke this function to login a user that prefers to skip logging in, or to login users in general if the app does not solicit login information from the app’s users by design.

Parameters

Name: Type: Description:

onSuccess @escaping (SSUser) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon successful completion of the anonymous login. This callback receives an SSUser reference to successfully the logged in user. This callback function has no return value. The SSUser object represents the anonymous user.

onFailure @escaping (SSError) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon unsuccessful completion of the login. This callback receives an SSError reference that describes the failure.

Return Value

None, however, the given onSuccess or onFailure callbacks are called to indicate the result.

Page 99 of 148

Page 100: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

logout Logs the current app user out of SwiftShopper. Your app may wish to provide its users with a “logout” button after the user logs in. Your app should call the SwiftShopperFramework. logout(...) method to log the user out of Swift Shopper. The user’s information, including order history and shopping lists are cleared.

Parameters

Name: Type: Description:

completion () -> ()

A callback function that the Swift Shopper SDK promises to invoke after the user is completely logged out.

Return Value

None, however, the given completion callback is called after the operation fully completes.

Page 100 of 148

Page 101: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

toggleScannerGuide Customizes the presentation for the screen that various Swift Shopper user interface components present to prompt the user to scan a barcode. This screen includes a rectangular area within the real-time camera display in which the user lines up the barcode that is being scanned. By default the scanner guide is a gently blinking red line appears in the center of this area as a hint for the user to line-up the barcode. Your app may call this function to disable or re-enable the scanner guide on all such screens that are presented to the user.

Parameters

Name: Type: Description:

isEnabled Bool

Pass in a value of ‘true’ to enable the scanner guide. Pass in a value of ‘false’ to disable the scanner guide.

Return Value

None

Page 101 of 148

Page 102: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

enterStore Causes the app user to officially enter a specific retailer store location for in-store, self-scan shopping. This function is intended for use by any app for a retailer that has exactly and only one physical retail store location. In such a scenario, it is assumed that the app provides a ‘Shop’ or ‘Shop Now’ button or other user interface control. The app must then call SwiftShopperFramework. enterStore(...) after the user taps this user interface control, prior to navigating the user to the app’s scene that includes a Swift Shopper shopping view such as SSShopOnTheFly or SSListView. For example, the SSListView renders itself differently when the app’s user is in a store in order to provide the user with a “Shop From List” experience. In addition, the Swift Shopper SDK needs to know which store location the user is shopping at in order to facilitate the shopping experience (look up the store’s pricing for scanned barcodes, submit the final checkout order to the store’s internal point-of-sale system, display current deals at the store, etc.) NOTE: For retailers that have more than one physical shopping location, the app does not call this function. Instead, the app presents a scene with an SSSelectMarket view in the scene’s view hierarchy. The SSSelectMarket view walks the user through the process of selecting a store, officially enters whatever store the user selects, and makes a callback to your app for your app to then present the scene(s) for the user’s shopping experience.

Parameters

Name: Type: Description:

retailerStoreId

Int

The unique ID that Swift Shopper assigns to the retailer’s single retail store. You may contact your retailer or Swift Shopper to attain this unique id which you may enter into your app’s source code as a constant.

onSuccess @escaping (SSStoreDetail) -> ()

A callback function that the Swift Shopper SDK promises to invoke upon successful completion of the enter store process. This callback receives an SSStoreDetail reference with

Page 102 of 148

Page 103: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

information about the particular store location, such as name and other configuration values. This callback function has no return value.

onFailure @escaping () -> ()

A callback function that the Swift Shopper SDK promises to invoke upon unsuccessful completion of the enter store process. Your app may present a general error message to the user, generate a log message, etc.

Return Value

None, however, the given onSuccess or onFailure callbacks are called to indicate the result.

Page 103 of 148

Page 104: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

exitStore Exits the current retailer store location at which the user is presumably shopping. Your app may call this function at some time after calling SwiftShopperFramework. enterStore(...) or after presenting the SSSelectMarket view and after the user has subsequently selected a retailer store location at which to shop. After calling this function the user officially leaves the store. Any items that the user may have added to the user’s shopping cart are removed. It is suggested that your app’s user interface include a scene or scenes that are dedicated to the in-store self-scan shopping experience. For iPhone apps, it is suggested that the app navigate the user into the app’s in-store self-scan shopping experience and keep the user there until the user either completes their purchase or explicitly presses an exit store user interface control to be provided by your app somewhere within your app’s ordinary navigation mechanism. Your app’s exit-store user interface control would call SwiftShopperFramework. exitStore(...) when invoked and ultimately navigate the user away from the in-store self-scan shopping experience. Similarly for iPad apps, it is suggested that the app either navigate the user into the app’s in-store self-scan shopping experience, or render the in-store self-scan shopping experience on half of the screen. The in-store self-scan shopping experience should remain on the screen until the user completes their purchase or explicitly presses an exit store user interface control to be provided by your app. Your app’s exit-store user interface control would call SwiftShopperFramework. exitStore(...) when invoked and ultimately remove or navigate the user away from the in-store self-scan shopping experience.

Parameters

Name: Type: Description:

completion () -> ()

A callback function that the Swift Shopper SDK promises to invoke after the shopping cart is cleared and the user is completely checked out of the store .

Return Value

None, however, the given completion callback is called after the operation fully completes.

Page 104 of 148

Page 105: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

getUser Gets the currently logged in user. Scenarios to Consider:

● This function returns nil if the user is not logged in at all. ● This function returns an SSUser object with an ‘isAnonymous’ property value of true if

the user is logged in anonymously. ● This function returns an SSUser object with an ‘isAnonymous’ property value of false if

the user is logged in fully. Based on these scenarios, this function is used to determine whether a user is logged in based on whether this function returns an SSUser versus nil. Then for a logged in user, this function returns the SSUser object which your app can use to ascertain whether the user is logged in anonymously or not. Your app can then use the SSUser object to ascertain the user’s name, email, etc if the user is fully logged in (in other words, if the user is not logged in anonymously).

Parameters

None

Return Value

Type: Description:

SSUser?

The SSUser object that describes the logged in user or nil if the user is not logged in.

Page 105 of 148

Page 106: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

getStore Gets information about the particular retailer store location at which the user is currently shopping. Scenarios to Consider:

● This function returns nil if the user is not currently shopping at a store. ● This function returns an SSStoreDetail object describing the store if the user is

currently checked into a store for shopping.

Parameters

None

Return Value

Type: Description:

SSStoreDetail?

The SSStoreDetail object that describes the store at which the user is currently checked in for shopping or nil if the user is not currently checked into a store.

Page 106 of 148

Page 107: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

importSharedList Imports a shared list into the user’s account. Usage Your app would call this function if your app customizes the shared list experience, in which case your app plugs a delegate into the SSListView that receives a callback when the user tries to share a list. The logic in your delegate receives a shared list id and a share type value. The logic in your delegate generates a message with a URL / link that the user then sends to a second user to invite the second user to access the first user’s list. The URL / link would resolve to a web page that you or a third party such as Branch IO would provide that executes when the second user taps the URL / link. The logic behind this web page ascertains whether the URL / link is being tapped from a mobile device and if so, ascertains whether the mobile device has your app installed. The logic redirects the user to the App Store if your app is not installed. The redirect would be via an iOS universal link which encodes the shared list id and share type which iOS passes into the app after the user installs and runs the app for the first time. If your app is already installed on the mobile device then the logic launches your app via an iOS universal link that encodes the shared list id and share type. The shared list id and share type are ultimately passed to one of your AppDelegate’s “application” callbacks when the second user invokes the URL / link that the second user receives via text message or email from the first user. The logic in your AppDelgate’s “application” callback then needs to retrieve the shared list id and share type from the URL or userActivity object that was passed to your AppDelegate’s “application” callback. After attaining the shared list id and share type, your AppDelegate’s “application” callback logic would need to:

● Ensure that the second user is logged in fully ● If the second user is not logged in fully, your app should stash away the shared list id

and share type, and navigate the user to login. ○ Your app should then call this function and pass the shared list id and share

type into this function after the user logs in. ○ Your app should then listen via the standard iOS NotificationCenter

mechanism for the shared list to finish being imported (see the reference documentation for the “sharedListImported” event) and then navigate the user to whatever scene your app provides that incorporates the SSListView into the

Page 107 of 148

Page 108: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

scene’s view hierarchy. The SSListView automatically displays the most recently imported shared list.

● If the second user is indeed logged in fully, your AppDelgate’s “application” callback should then:

○ Call this function and pass the shared list id and share type. ○ Listen via the standard iOS NotificationCenter mechanism for the shared list to

finish being imported and then navigate the user to whatever scene your app provides that incorporates the SSListView into the scene’s view hierarchy. (See the reference documentation for the “sharedListImported” event.) The SSListView automatically displays the most recently imported shared list.

Parameters

Name: Type: Description:

listId String

The shared list id to import as passed to the delegate that would have generated the sharing message including the sharing URL / link that a user sends via text or email to another user to invite the other user to view the user’s shared list; as described above.

shareType String

The share type for the list to import, as passed to the delegate that would have generated the sharing message including the sharing URL / link that a user sends via text or email to another user to invite the other user to view the user’s shared list; as described above.

Return Value

None, however, Swift Shopper posts the NSNotification.Name.sharedListImported event immediately after the shared list is imported into the user’s account. (See the reference documentation for the “sharedListImported” event.) Your AppDelegate can listen for the shared list to be imported, and react accordingly, by registering to observe the NSNotification.Name.sharedListImported event as follows: func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions:

[UIApplication.LaunchOptionsKey: Any]?) -> Bool { ...

NotificationCenter.default.addObserver( self, selector: #selector(sharedListImported), name: .sharedListImported, object: nil) ...

}

Your AppDelegate may then provide a method named “sharedListImported” to react to the list being imported (to navigate the user to a scene that includes an SSListView object in the

Page 108 of 148

Page 109: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

scene’s view hierarchy whereby the user will then see the imported shared list), as follows: @objc func sharedListImported(notification: NSNotification) { // Navigate the user to a scene with an SSListView in the scene so that

// the user can view or edit the newly imported list

}

Don’t forget to have your AppDelegate tidy up when the AppDelegate is deinitialized: deinit { NotificationCenter.default.removeObserver( self, name: .sharedListImported, object: nil) }

Page 109 of 148

Page 110: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Function

scanItemToCart Displays the Swift Shopper user interface prompting the user to scan an item into their shopping cart and passes information about the scanned item to the given callback. The scanned item is placed in the user’s shopping cart and the result including the scanned barcode is passed to the completion handler for the app to further process.

Parameters

Name: Type: Description:

parentController UIViewController

The view controller that will present the Swift Shopper user interface that prompts for and allows the user to scan an item into their cart.

completion @escaping (SSScanResult) -> ()

A callback function that the Swift Shopper SDK promises to invoke when the user finishes or cancels scanning. The SSScanResult indicates whether a barcode an item was scanned to the user cart and includes the raw barcode if so. See the SSScanResult reference for details..

Return Value

None, however, the given completion callback is called to indicate the result.

Page 110 of 148

Page 111: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SSUser

Purpose This structure describes the currently logged in user. See the SwiftShopperFramework.getUser(...) function.

Values

Values

Name: Type: Description:

userId Int? Unique identifier for the user scoped to the retailer.

firstName String? The user’s first name if known otherwise nil or empty string.

lastName String? The user’s last name if known otherwise nil or empty string.

email String? The user’s email address if known otherwise nil or empty

string.

imageUrl String? A string representation of an HTTP or HTTPS URL from

which the user’s profile picture can be attained.

gender String? The user’s gender if known otherwise nil or empty string. The

value will begin with “M” or “m” for male. The value will begin with “F” or “f” for female.

isAnonymous Bool Indicates whether the user is logged in anonymously, in

which case most of the other values will be nil or empty string. A value of true indicates anonymous login. A value of false indicates full login.

Page 111 of 148

Page 112: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SSStoreDetail

Purpose This structure describes the store at which the user is currently shopping. See also:

● The SwiftShopperFramework.getStore(...) function. ● The SwiftShopperFramework.enterStore(...) function.

Values

Values

Name: Type: Description:

name String? The name of the store

storeId Int? A unique identifier for the store, unique within the Swift

Shopper infrastructure.

latitude Double? The store’s geographical latitude.

longitude Double? The store’s geographical longitude.

isFlyPassEnabled Bool? Indicates whether “Swift Shopper FlyPass™” (in-app

payment) is enabled for the particular store. The value true means yes, false or nil means no.

isFlyThruEnabled Bool? Indicates whether “Swift Shopper FlyThru™” (pay at the cash

register or self-scan kiosk) is enabled for the particular store. The value true means yes, false or nil means no.

retailerWelcomeHtml String? A string encoding an HTML marketing / welcome message

for the store or nil if not available..

termsURL String? An HTTP(S) URL that can be rendered in a web browser to

view the particular store’s terms and conditions.

retailerName String? The name of the retailer to which the restore store belongs.

Page 112 of 148

Page 113: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SSScanResult

Purpose This structure describes the result of a special request that your app can make to prompt the user to scan an item into their cart. See the SwiftShopperFramework.scanItemToCart(...) function.

Values

Values

Name: Type: Description:

statusCode SSScanStatusCode

The general result of the prompt to the user to scan an item to cart. Possible values are:

.success Indicates that the user scanned an item into their cart.

.unknownError

Indicates that an unexpected anomaly occurred.

.notCheckedIntoStore

Indicates that the user was not prompted to scan an item due to the app not being checked into a store.

.noBarcodeScanned Indicates that the user elected to cancel instead of scanning an item to their cart.

message String? A loggable message describing the status if the statusCode

is not .success.

barcode String? The raw barcode that was scanned if the statusCode is

.success otherwise nil.

Page 113 of 148

Page 114: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SSError

Purpose This structure describes an error that is passed to a failure callback.

Values

Values

Name: Type: Description:

message String A loggable string describing the error or empty string if

unavailable or unknown..

Page 114 of 148

Page 115: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 2: Posted Events This section describes the events that Swift Shopper framework posts via the standard iOS NotificationCenter mechanism, which your app can listen for and react to.

Events

Event

sharedListImported Indicates that a shared list was just imported either via your app’s custom logic for handling shared lists or via the default mechanism that the Swift Shopper SDK provides.

Suggested Use

Consider having your app delegate register as a listener for this event. When this event happens, consider navigating the user to the scene that your app provides that includes the SSListView in the scene’s hierarchy. See the various discussions elsewhere in this document that pertain to importing shared lists.

Example

UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate { ...

func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions:

[UIApplication.LaunchOptionsKey: Any]?) -> Bool { ...

NotificationCenter.default.addObserver( self, selector: #selector(sharedListImported), name: .sharedListImported, object: nil) ...

}

@objc func sharedListImported(notification: NSNotification) { // Navigate the user to a scene with an SSListView in the scene so that

// the user can view or edit the newly imported list

}

deinit { NotificationCenter.default.removeObserver( self, name: .sharedListImported, object: nil) }

Page 115 of 148

Page 116: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

...

}

Event

finishedShopping Indicates that the user just completed their purchase or the Swift Shopper SDK has just finished exiting the store due to your app having called SwiftShopperFramework. exitStore(...)

Suggested Use

Consider having your app delegate register as a listener for this event. When this event happens, consider navigating the user to an initial home screen that your app presumably provides if the app is executing in an iPhone. Consider hiding or removing the views that provide the shopping experience if the app is executing in an iPad and your app divides the screen while the user is shopping.

Example

UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate { ...

func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions:

[UIApplication.LaunchOptionsKey: Any]?) -> Bool { ...

NotificationCenter.default.addObserver( self, selector: #selector(finishedShopping), name: .finishedShopping, object: nil) ...

}

@objc func finishedShopping(notification: NSNotification) { // Navigate the user back to your app’s initial scene (iPhone)

// or hide the shopping experience (iPad)

}

deinit { NotificationCenter.default.removeObserver( self, name: .finishedShopping, object: nil) }

...

}

Page 116 of 148

Page 117: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 3: Swift Shopper Views The Swift Shopper SDK provides the following views that your app may include within the view hierarchy for any of your app’s scenes or view controllers. These views color themselves in accordance with the color that your app passes to the SwiftShopperFramework.initialize(...) function. In addition, you may set the background color for the for these views either programmatically or graphically via the XCode interface builder. These views renders static text and dynamic content. You may customize the static text via the stringReplacements object that your app may pass to the SwiftShopperFramework. initialize(...) function.

Views

View

SSCartView Displays the contents of the user’s shopping cart. Also provides a checkout button that the user may tap to initiate the checkout process. Depending on the retailer’s configuration within Swift Shopper, the user may purchase from within the app and/or have a code rendered on their device’s screen that they can present to a cashier or scan off of their device’s screen at a self-checkout kiosk that is located in the store in order to pay for their goods at the store.

Suggestions

Use this in conjunction with the SSCartButton. Present the SSCartButton on the scene(s) or view(s) that your app presents while the user is shopping. Present the SSCartView or a scene that includes the SSCartView when the SSCartButton is tapped.

Page 117 of 148

Page 118: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSCartButton A button-sized view that illustrates the number of items in the user’s shopping cart along with a cart icon.

Suggestions

Render an SSCartButton perhaps in the upper right-hand corner of your app’s navigation bar when the user is shopping. Use this in conjunction with the SSCartView. Present the SSCartView or a scene that includes the SSCartView when the SSCartButton is tapped.

Further Customization

By default the cart button will render its background in the color that your app passes to the SwiftShopperFramework. The cart button will render the cart icon and the text that indicates the number of items that are in the user’s shopping cart both in either white or black. The icon and text will be black if background color is a very light color otherwise the icon and text will be white. Your app may customize this behavior by setting the SSCartButton’s backgroundColor and/or foregroundColor. Your app may set these values programmatically via a view controller class that is associated with the scene that displays the SSCartButton, or your app may set these graphically via the XCode interface builder. Setting the backgroundColor is no different than setting the background color for any view via the XCode interface builder. To set the foregroundColor via the interface builder, select the SSCartButton view and view the “Identity Inspector”. Add an item to the “User Defined Runtime Attributes” whose “Key Path” is “foregroundColor”, whose “Type” is Color, and whose “Value” is the color for the icon and text within the SSCartButton.

Properties

You may set these properties programmatically or via the XCode interface builder using the Identity Inspector’s “User Defined Runtime Attributes” section.

Name: Type: Description:

backgroundColor Color Defines the SSCartButton’s background color. Defaults to the color that the app passes to SwiftShopperFramework.initialize(...) unless otherwise specified.

Page 118 of 148

Page 119: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

foregroundColor Color Defines the color for the cart icon and the text that the SSCartButton renders. Unless specified, this defaults to black if the backgroundColor is very light or white otherwise.

Page 119 of 148

Page 120: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSOrderHistory Displays a list of the user’s past in-app purchases that occurred at any of the retailer’s stores. The user may view a copy of their receipt for any of their past purchases. The user may download, email, or print the receipt via the ‘Share’ button that is rendered on the screen while the user is viewing a receipt for a past purchase.

Suggestions

Create a scene for viewing order history. Fill the scene minus navigation with an SSOrderHistory view. Assuming that your app presents some sort of options menu, or perhaps a menu that appears after tapping a “hamburger” icon, include an option for the user to view their order history. Navigate the user to this scene when the user chooses to view their order history.

Page 120 of 148

Page 121: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSShopOnTheFlyView Displays a self-scan shopping experience that allows the user to scan products off of the shelves at the store in which the user is currently shopping. Prior to displaying an SSShopOnTheFly view, your app must somehow have the user enter a store. If your app is for a retailer with exactly and only one store location, your app would need to call SwiftShopperFramework. enterStore(...) just prior to displaying an SSShopOnTheFly view. If your app is for a retailer with multiple store locations, your app would need to present an SSSelectMarket view. The user would then need to select and check into a nearby store. Your app would then receive a callback after the user enters a store and present the SSShopOnTheFly view thereafter.

Suggestions

Create a scene for simple self-scan shopping at the store. Fill most of the scene minus navigation with an SSShopOnTheFly view. Consider customizing the ‘back’ button that your app presumably provides via a presumed navigation bar to become an “Exit Store” button. The idea is to help keep the user inside of your app’s shopping experience until the user explicitly chooses to exit the store or until the user completes their purchase. Consider prompting the user for confirmation if they click the “Exit Store” button, warning the user that any items in their cart will be lost. Consider displaying an SSCartButton in the upper right-hand corner within the navigation bar that your app presumably provides. See the SSCartButton view reference for details. Consider listening for the finishedShopping event and then navigate the user to the opening screen of your app (presumably a main screen that provides the user with options such as “Shop”, “View Retailer Info”, “View Weekly Specials”, “View Upcoming Events”, etc. when the user finishes shopping. Reset the navigation stack so that the user can not navigate back into the shopping experience after completing the purchase or exiting the store. (It would not make sense to allow the user to navigate back. Of course the user may re-enter the store, or view their order history if your app integrates order history. See the finishedShopping event reference for details.

Page 121 of 148

Page 122: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSProfileView Displays the user’s Swift Shopper profile illustrating the user’s name, photo, number of items ever scanned, and the total number of checkouts ever completed via Swift Shopper.

Suggestions

Create a scene for the user to view their profile. Fill the scene minus navigation with an SSProfileView view. Assuming that your app presents some sort of options menu, or perhaps a menu that appears after tapping a “hamburger” icon, include an option for the user to view their profile. Navigate the user to this scene when the user chooses to view their profile. Consider including a “logout” mechanism (UIButton, etc) on the scene that includes the SSProfileView. Alternately, some apps display an icon of the user’s photograph in a corner of the screen after the user logs in. If your app exhibits this behavior, your app may display the scene that includes the SSProfileView when the user taps the icon of the user’s photograph.

Page 122 of 148

Page 123: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSLoginView Presents login buttons for social media login and walks the user through social media login.

Suggestions

Assuming that your app does not need to log users in via a user account that the retailer themselves might use, and assuming that neither you, your organization, nor the retailer wishes to maintain the accounts for your app’s users, simply create a scene for login. Fill the scene with an SSLoginView and any navigation controls. Create and associate a view controller class with the login scene. Add an outlet reference within your login view controller to the SSLoginView. Override the “viewDidLoad” method upon your login view controller. Call the ‘setLoginSuccessListener(...)’ on the SSLoginView outlet reference. Pass in an inline function that pops the navigation stack or navigates the user to whatever scene your app would like to bring the user to after the user either logs in or explicitly skips login (the user would then be logged in anonymously). Consider whether your app supports importing shared lists. A user must fully login in order to import a shared list. If your app supports importing shared lists, and a non-logged in user attempts to access a shared list, seamlessly walk the user through the login process. Your AppDelegate receives an “application” callback when the user first tries to access another user’s list. From the “application” callback, if the user is not fully logged in, stash away the URL or userActivity for the shared list and present the login scene. Craft the logic in the login view controller’s success listener function to check if there is a stashed away URL or userActivity for a shared list. If so, either pass the URL or userActivity to the corresponding SwiftShopperFramework. application(...) function or extract the shared list id and share type and call SwiftShopperFramework.importSharedList(...). Assuming that your AppDelegate responds to the “sharedListImported” event, your app will then navigate the user to a scene within your app that includes an SSListView object and clears the stashed away URL, userActivity, shared list id, and/or share type.

Further Customization

By default the user is presented with all Swift Shopper supported login mechanism as well as the option to skip login. The user is logged in anonymously if the user opts to skip login. You may customize this behavior by specifying which options to remove.

Page 123 of 148

Page 124: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Properties

You may set these properties programmatically or via the XCode interface builder using the Identity Inspector’s “User Defined Runtime Attributes” section.

Name / Key Path: Type Description:

allowSkipLogin Boolean Specifies whether to render the option for the user to skip login (which results in the user being logged in anonymously). The default value is true unless specified otherwise.

allowGoogleLogin Boolean Specifies whether to render the option for the user to login via Google. The default value is true unless specified otherwise.

allowFacebookLogin Boolean Specifies whether to render the option for the user to login via Facebook. The default value is true unless specified otherwise.

allowTwitterLogin Boolean Specifies whether to render the option for the user to login via Twitter. The default value is true unless specified otherwise.

Page 124 of 148

Page 125: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSSelectMarketView Displays a list of nearby retail store locations prompting the user to choose a location to shop at.

Suggestions

Create a scene that fills most of the screen with an SSSelectMarket view if your app’s retailer has more than one physical store location. Your app will not need to use the SSSelectMarketView if your app’s retailer has exactly and only one physical store location. Create an associate a view controller to the scene for selecting a market. Add a reference outlet to the SSSelectMarket view within the view controller. Add a “checkedIn(...)” callback to your view controller and update its class declaration to indicate that the view controller adheres to the SSSelectMarketViewDelegate protocol. Set the SSSelectMarketView’s delegate to your view controller’s “self” instance from within the view controller’s “viewDidLoad” method. Add logic to the view controller’s “checkedIn(...)” method that navigates the user to your app’s scene that includes the SSShopOnTheFly view. Provide a means on your app’s initial scene that your user would invoke to start shopping. When invoked, your app should check if the user is currently checked into a retail store [see the SwiftShopperFramework.getStore() function]. If the user is not currently checked into a retail store, navigate the user to the scene that includes the SSSelectMarket view. The user will then be prompted to select a nearby store. The user will then be navigated to the shopping scene per the previous paragraph’s suggestion. If the user is already checked into a retail store, navigate the user directly to the shopping scene that includes the SSShopOnTheFly view.

Page 125 of 148

Page 126: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSListView Displays the contents of the user’s current shopping list. Allows the user to add new shopping lists. Allows the user to change the currently shopping list to a different shopping list. Allows the user to view and edit the items in the current shopping list. Indicates whether the retailer has any deals for items in the current shopping list. Allows the user to view the deals for any items in their shopping list. Allows the user to delete any of their shopping lists. Allows a fully logged in user to share their shopping list with another user. Allows a fully logged in user to view or edit a shared list. The SSListView customizes the user experience based on whether the user is currently checked into a store. Allows the user to scan items from their shopping list into their shopping cart if the user is checked into a store. Allows the user to scan an item in general to their shopping cart if the user is checked into a store. The SSListView allows the user to scan items to their shopping list if the user is not currently checked into a store. The idea is that the user is probably at their house and scanning items that they have around the house into their shopping list as a reminder to themselves to purchase the items the next time that they go shopping at one of the retailer’s stores.

Suggestions

Create a scene that includes an SSListView that fills most of the screen. Consider whether to allow your users to shop from their shopping lists. If so, provide a means from your shopping scene that includes the SSShopOnTheFly view to navigate to the shopping list scene that includes the SSListView. Also consider providing a means for the user to navigate from the shopping list scene to the regular shopping scene with the SSShopOnTheFly view but only reveal this mechanism (programmatically via the scene’s view controller) if the user is currently checked into a store. Create and associate a view controller class to the scene for viewing shopping lists. Check if the user is currently checked into a store from within the view controller’s “viewDidLoad” method. Set the screen’s title to indicate whether the user is shopping from their list or just viewing / editing their list from within the view controller’s “viewDidLoad” method assuming that your app uses the standard iOS navigation bar mechanism. Add an SSCartButton to the upper right in the navigation bar if the user is currently checked into a store. Reveal any navigation mechanism that your shopping list scene may provide in order for the user to navigate to the ordinary shopping scene that includes the SSShopOnTheFly view if the user is checked into a store. Navigate the user to the SSCartView when the user taps the

Page 126 of 148

Page 127: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

SSCartButton. Consider optimizing for iPad devices by rendering the SSListView and the SSShopOnTheFlyView from within the same scene, perhaps having one of the views located on the top / left while having the other view located on the bottom / right.

Page 127 of 148

Page 128: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

View

SSDealView Displays the current weekly deals at all nearby stores for the retailer if the user is not checked into a particular store. Displays the current weekly deals at the current store if the user is checked into a store. The user may add a deal to the user’s shopping list if the user is not checked into a store. The user may scan a deal into the user’s shopping cart if the user is checked into a store.

Suggestions

Create a scene that includes an SSDealView in the scene’s view hierarchy and fills most of the screen with the SSDealView. Provide a user interface mechanism for the user to invoke to view deals. Navigate the user to this scene when the user invokes the user interface mechanism to view deals. Assuming that your app allows the user to view deals both when they are checked into a store and even when they are not checked into a store, consider programmatically adding an SSCartButton to the upper right of the navigation bar if the user is checked into a store and navigating to the scene within your app that displays an SSCartView when the user taps the SSCartButton.

Page 128 of 148

Page 129: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 4: Delegate Protocols The Swift Shopper SDK provides various user interface views that your app may incorporate into the view hierarchy on various scenes within the app. iOS allows you to define and associate one view controller class per scene. iOS allows you to define outlet references in your view controller class that allow your view controller class to programmatically access any views in the scene’s view hierarchy. Some of the Swift Shopper view classes support a “delegate” pattern whereby a view controller having an outlet reference to the view can assign itself or another object as a “delegate” to receive specific callbacks when certain milestones occur at runtime as the user interacts with the scene. This section documents each such “delegate” that any Swift Shopper views support. Each “delegate” has a corresponding protocol that the corresponding view controller would need to adhere to. To assign itself as the corresponding “delegate”, the view controller or other object’s class would need to explicitly state that the class extends the protocol and provided a corresponding implementation for the method or methods that the protocol defines. The available delegate protocols are defined here-in for reference.

Page 129 of 148

Page 130: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Protocol

SSSelectMarketViewDelegate Receives a callback immediately after a user selects and checks into a retail store for in-store shopping.

Provided By

SSSelectMarketView

Required Method

checkedIn This is a callback method that is called immediately after a user selects and checks into a retail store for in-store shopping.

Parameters

Name: Type: Description:

to SSStoreDetail Describes the particular retail store at which the user has checked in for in-store shopping. See the SSStoreDetail reference documentation for details.

Page 130 of 148

Page 131: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Protocol

SSListViewDelegate Provides a custom implementation for a user to share a shopping list with another user.

Provided By

SSListView

Required Method

shared This is a callback method that is called when the user presses the “share” button on a shopping list that they are viewing via the SSListView. The custom logic that is provided needs to take the given listId and type and somehow deliver these to another user’s running instance of your app. The other user’s running instance of your app needs to pass these values to the SwiftShopperFramework. importSharedList(...) function to import the first user’s list into the second user’s account. Any SSListView objects will then display the first user’s list in the second user’s app. Moreover the list will be synchronized between the two users. Any changes that one user makes to the list will be automatically reflected in the second user’s SSListView and vice-versa. The suggested implementation is to generate a text message or email with an HTTP(S) link that encodes the listId and type, including some verbiage such as “Hey, click here to check out my list!”, then prompt the user to send this text message or email to the second user. The second user will tap the link to see the first user’s list. The second user’s web browser opens when they tap the link. The web page asks the user to click the link from an iOS device if the second user’s web browser is not running on an iOS. The web page may offer to text the link to the second user if the second user wishes to enter their mobile phone number onto the web page. Ultimately the second user taps the link on an iOS device. If the link adheres to iOS universal link standards, iOS will either open the app and pass the link to the app if the app is installed or navigate the user to the App Store to download the app if the app is not installed. iOS then automatically passes the link into the app after the user installs the app and subsequently runs the app for the first time.

Page 131 of 148

Page 132: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

The logic in your AppDelegate then receives the link, parses out the linkId and type, and either calls SwiftShopperFramework.importSharedList(...) if the second user is logged in or temporarily stores the listId and type aside while navigating the second user to the app’s login scene. The login scene’s logic then clears calls SwiftShopperFramework. importSharedList(...), passes in the listId and type, and clears the listId and type’s temporary storage variables. Your app would pass an ‘onSuccess’ callback to the importSharedList(...) function which then navigates the user to your app’s shopping list scene that incorporates an SSListView in the scene’s view hierarchy. The second user then sees the first user’s list. NOTE: There are third-party services such as “Branch IO” that provide most of this functionality for free.

Parameters

Name: Type: Description:

listId String Uniquely identifies the user’s list as a shared list within the Swift Shopper infrastructure. As described above, this value needs to be ultimately passed into the SwiftShopperFramework. importSharedList(...) function in the other user’s running instance of your app provided that the other user is logged in fully to Swift Shopper.

type ShareType An object that represents the type of shared list. As described above, this value needs to be ultimately passed into the SwiftShopperFramework. importSharedList(...) function as the “shareType” parameter value in the other user’s running instance of your app provided that the other user is logged in fully to Swift Shopper. More specifically, this object wraps a “rawValue” string attribute. The “rawValue” string is what needs to be passed into the SwiftShopperFramework. importSharedList(...) function as the “shareType” value in the other user’s running instance of your app.

Page 132 of 148

Page 133: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 5: String Customizations The various Swift Shopper view objects display static text and dynamic content. Your app may customize any static text value via the “stringReplacements” map that your app may pass to the SwiftShopperFrameowork.initialize(...) function. For example, define a string to string mapping in your source code and provide text only for string keys that you wish to change as follows: let customStringReplacements = [ "paymentPopUpInApp": "Mobile Checkout",

"paymentPopTMLabel": "Mobile Checkout",

"flyPassSelectPaymentType": "Select Payment Type:",

"ageRestrictedWarningMessage": "Please see an attendant.",

"itemNotFoundWarningMessage": "Please try again or see an attendant.",

"troubleScanningWarningMessage": "Please see an attendant.",

"paymentByApplePayFailed": "Payment Failed. Please verify your payment details in your

Apple

Wallet are current or try another payment method.",

"paymentByCardFailed": "Payment Failed. Please verify your card information is current or

try

another card.",

"permissionsViewCameraUsageDescription": "Camera is needed to allow you to scan barcodes

as

you shop!",

"permissionsViewGpsUsageDescription": "Location is needed to find nearby <<<Your Retailer

Name>> locations for you to shop at.",

]

Pass your string to string mapping into the SwiftShopperFramework. initialize(...) method as the “stringReplacements” value: import SwiftShopperSDK

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate { ...

func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey:

Any]?) -> Bool { ...

SwiftShopperFramework.initialize(key:”...”, color: ..., icon: ..., logo: ...,

fontName: ..., stringReplacements: customStringReplacements) ...

}

}

Page 133 of 148

Page 134: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

TIP: In some instances the static strings are rendered in a fixed amount of on-screen real estate and may not necessarily accommodate arbitrary lengths of custom text. Please run your app and verify that any string customizations render sensibly on the corresponding user interface screen(s) or control(s) and moderately adjust any custom verbiage accordingly. TIP: To support multiple languages your app may define a string to string mapping for each language that your app supports. Query iOS for the user’s preferred language prior to calling SwiftShopperFramework. initialize(...) and pass in your app’s string to string mapping that corresponds closest to the user’s preferred language.

Available Strings for Customization The following is a list of all available string customizations as of this document’s date. The value on the left of each equals sign (=) is the “key” (the left side of the mapping) that you would place in your string to string mapping. "appDisplayName" = "This Swift Shopper Partner App"; "scan" = "Scan"; "None" = "None"; "scanner" = "Scanner"; "StringFormat" = "$%.2f"; "creatingLinkError" = "Error while creating the link!"; "yes" = "Yes"; "add" = "Add"; "no" = "No"; "loading" = "Loading..."; "updating" = "Updating..."; "Okay" = "Okay"; "ok" = "Ok"; "buttonTitleCreateList" = "Create a List"; "delete" = "Delete"; "cancel" = "Cancel"; "loginSkipConfirmDialogTitle" = "Are you sure you want to skip login?"; "loginSkipConfirmDialogButtonNo" = "Login"; "loginSkipConfirmDialogButtonYes" = "I'm Sure"; "buttonTitleGoToLogin" = "Go to Login"; "loyaltyCardDeleteConfirmation" = "Are you sure you want to delete this card?"; "cartZero" = "0 "; "noInternetTitle" = "No internet connection"; "noInternetMessage" = "Make sure your device is connected to the internet."; "noInternetAddThePrivatePist" = "Make sure your device is connected to the internet to add the private list items."; "noInternetUpdateThePrivatePist" = "Make sure your device is connected to the internet to update the private list items."; "noInternetDeletePrivatePist" = "Make sure your device is connected to the internet to delete the private list item."; "loginRequiredForSharing" = "To use the Share Feature please login and accept the terms of service."; "listEmptyError" = "Your list is empty, Please add some items and try."; "errorWhileUpdatingItem" = "Error while updating this item."; "enterItemName" = "Enter item name"; "giveListNameAddItem" = "Please give list name to add new item in the list"; "notAddItemAllList" = "You can not add item to All Lists"; "somethingWentWrongMessage" = "Something went wrong. Please try again later.";

Page 134 of 148

Page 135: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

"errorAddingItem" = "Error while adding this item"; "emptyListAlertMessage" = "You must create a list first. Would you like to create a list?"; "deleteListItemTitle" = "Delete List Item"; "deleteListItemMessage" = "Would you like to clear crossed off items from your list?"; "clearedCheckedItems" = "Successfully cleared checked items!"; "deleteLocallistConfirmationMessage" = "Are you sure, you want to delete this list?"; "deletelistConfirmationTitle" = "Delete List"; "listNameEmpty" = "Enter list name"; "enablelocationServiceTitle" = "Enable Location Service"; "enablelocationServiceMessage" = "To see deals, please turn your location services on. To enable, please go to Settings->Privacy->Location Services"; "areYouSure" = "Are you sure?"; "deleteItemConfirmation" = "This is a shared list. Deleting this item will delete it from everyone’s %@. Proceed?"; "errorDeletingItem" = "Error while deleting this item."; "NoitemsScanningToAdd" = "No items found in your recent list."; "SpecificNoitemsScanningToAdd" = "was not found in your recent list."; "ClearCartNCancelCheckIn" = "Are you sure, you want to clear your cart and cancel your check-in?"; "exitStoreConfirmationMessage" = "Are you sure, you want to clear the cart and exit the store?"; "SelectLIstToAddItem" = "Select list in which you want to add this item."; "AddItemRelevantDeals" = "Add items to your lists for Relevant Deals"; "DealEndsOn" = "Deal ends on"; "addedToList" = " added to list"; "addedToCart" = " added to cart"; "addLoyaltyCardImage" = "Please add loyalty card image"; "scanLoyaltyCardBarcode" = "Please scan loyalty card barcode"; "EnterCardName" = "Enter card name"; "EditLoyaltyCard" = "Edit Loyalty Card"; "TakePhoto" = "Take Photo"; "PhotoLibrary" = "Photo Library"; "ChooseImage" = "Choose Image"; "termsServiceStr" = "Terms of Service"; "privacyPolicyStr" = "Privacy Policy."; "termsConditionAlertMessage" = "Please accept the Terms & Conditions."; "cameraPermissionAlertMessage" = "%@ is not authorized to use the camera, Please check app permissions: Settings->%@->Camera"; "pointsNotEnough" = "There are not have enough points to purchase this item. To purchase, please remove other items from the cart."; "locationError" = "Unable to detect your current location. Please check your internet connection or make sure location services are enabled for %@"; "dealsBarcodeNotMatchConfirmation" = "Scanned item does not match this deal."; "cartAmoutZeroError" = "Total amount should be greater than zero."; "paymentFailedError" = "Payment Failed!, Please try again."; "paymentReceiptDownloadFailed" = "Receipt not available at the moment. Please try again later or contact customer support"; "applePayNotSupported" = "Either Apple Pay is not configured or not supported in your device."; "deleteLocalItemConfirmation" = "Are you sure, you want to delete this item?"; "paymentByCardFailed" = "Payment Failed. Please verify your card information is current or try another card."; "paymentByApplePayFailed" = "Payment Failed. Please verify your payment details in your Apple Wallet are current or try another payment method."; "addDealtoListConfirmationTitle" = "Add to List"; "addDealtoListConfirmationMessage" = "Do you want to add %@ into your list?"; "enterFirstName" = "Enter first name"; "enterLastName" = "Enter last name"; "listViewShareEventControlParamURLType" = "$ios_url"; "listViewShareEventControlParamValue" = "https://itunes.apple.com/us/app/swift-shopper-shared-grocery-list-app-weekly-ads/ id606710282?mt=8"; "ageRestrictedTitle" = "Age Restricted Item";

Page 135 of 148

Page 136: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

"ageRestrictedWarningMessage" = "Please set the item aside & checkout with attendant using FlyThru checkout lane."; "itemNotFoundTitle" = "Item/Price not recognized"; "itemNotFoundWarningMessage" = "Please set the item aside & checkout with attendant using FlyThru checkout lane."; "troubleScanningTitle" = "Trouble Scanning"; "troubleScanningWarningMessage" = "Please set the item aside & checkout with attendant using FlyThru checkout lane."; "yourCartIsEmpty" = "Your cart is empty!"; // PastOrder Screen "pastOrderApiParamPageIndex" = "pageIndex"; "pastOrderApiParamPageSize" = "pageSize"; "pastOrderApiDataNext_page" = "next_page"; "pastOrderApiDataTransactionlist" = "transactionlist"; // PastOrderDetails Screen "payment_receipt_subject" = "%@ payment receipt"; "orderDetailsSubjectKey" = "subject"; // PaymentShopper Screens Text "paymentNoCheckoutConfigurationForStore" = "Checkout misconfigured for this store. Please contact technical support"; // Common Text of Payment "paymentRetailerStoreId" = "retailerStoreId"; // PaymentSelectionPopUp Screen "paymentPopUpAttended" = "FlyThru™ Checkout Line"; "paymentPopUpInApp" = "FlyPass™ Checkout Line"; "paymentPopNAApplePay" = "n/a: apple pay"; "paymentPopTMLabel" = "Swift Shopper FlyPass™"; "flyPassSelectPaymentType" = "Mobile Payment"; "finalizePayment" = "Finalize Payment"; "payByAppleButton" = "Proceed"; // ListView Screen "listViewSubTotal" = "Subtotal"; "listViewEstimatedTotal" = "Estimated total"; "listViewSharedList" = "%@ Share List"; "listViewStartPlanning" = "Please create a list to start planning"; "listViewStartShopping" = "Please create a list to start shopping"; "listViewScanToCart" = "Tap to SCAN item to CART"; "listViewScanToList" = "Tap to SCAN item to LIST"; "listViewListNotFound" = "List not found"; "listViewAlreadyDownloaded" = "already downloaded"; "listViewMessageProgress" = "Downloading images"; "listViewShareWithoutLogin" = "To share list you have to login first, Please login and try again."; "listImportShareWithoutLogin" = "Please login and then try again to access this shared list."; // Edit list screen "saveChangesConfirmation" = "Save changes?"; // Create List "listWithSameNameExist" = "List with name \"%@\" already exists. Try again with another name."; // DealsView "dontHaveDeals" = "Hey! looks like you don't have any deals yet."; // Alert Message

Page 136 of 148

Page 137: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

"dialog_delete_share_list_desc" = "This is a shared list. Deleting this list will delete it from everyone’s %@. Proceed?"; "skip_login_confirm_desc" = "The login syncs your order history among your devices, syncs your payment preferences among your devices, and allows you to share your shopping lists with others.\n\n %@ will never post to your social media account, never read any of your posts, and never access your friends."; "you_may_still_use" = "You may still use %@ to scan and purchase all of your items that are not age restricted."; "item_not_available_hint_message" = "You may still use %@ to scan and purchase any other items which have successfully been scanned to your cart."; // CreateList Screen "createListEditList" = "Edit List"; "createListErrorWhileUpdatingList" = "Error while updating this list."; // Check In "noStoresAvailable" = "No Stores Available"; "selectMarket" = "Select Market"; // AddToList Screen "addToListDescription" = "Description"; "addToListEditItem" = "Edit Item"; "addToListOne" = "1"; "addToListSelectCategory" = "Select Category"; "addToListItemsDetailsUpdated" = "Item details updated."; // ScanToUserList Screen "scanToList" = "Scan to List"; // ScanCardView Screen "scanLoyaltyCard" = "Scan Loyalty Card"; // ScanToCart Screen "scanToCartItem" = "Scan to Cart Item"; "troubleScanning" = "Trouble Scanning?"; // ScanDealToCart Screen "category" = "Category:"; "store" = "Store:"; "aisle" = "Aisle:"; "description" = "Description:"; // CartView Screen "loyaltyCard" = "Loyalty Card"; "items" = "Items"; "subTotal" = "Subtotal"; "checkout" = "Checkout"; // CheckInScan Screen "back" = "Back"; "successfullyCheckedIn" = "Successfully Checked In"; "NotValidQRCode." = "Not a valid QR Code."; // CheckOut Screen "checkoutComplete" = "Checkout Complete"; "wouldYouLikeToClearCrossedOffItemsFromYourList?" = "Would you like to clear crossed off items from your list?"; // RetailerWelcome Screen "terms&Conditions" = "Terms & Conditions"; "iAccept" = "I accept";

Page 137 of 148

Page 138: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

"tax" = "Tax"; "total" = "Total"; // RetailerWelcome Screen "enter" = "Enter"; // SortByOption screen "sortDefault" = "Default"; "sortCategory" = "Category"; "alphabetically" = "Alphabetically"; "sortAisleNumberName" = "Aisle Number"; "sortAisleNumberValue" = "Aisle"; // Login Function "invalidUserId" = "Invalid User Id"; "inValidUniqueToken" = "Please provide unique token received from social media login"; // Stand Alone scanner "noBarcodeScan" = "No barcode scanned!"; "notCheckedIn" = "Not checked in!"; // Permissions View "permissionsViewStartShoppingLabel" = "Start Shopping"; "permissionsViewSubtitleText" = "For a great experience, we need a few things before you start shopping."; "permissionsViewCameraUsageDescription" = "Camera is used to scan items to your lists & your cart and to take images for items."; "permissionsViewGpsUsageDescription" = "GPS location required for Local Deals from your favorite stores.";

Page 138 of 148

Page 139: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 6: Troubleshooting

Build Problems

Build Failed: Linker Command (app does not contain bitcode)

Cause: By default, all apps created in XCode are automatically configured to include bitcode in the app when building the app. The Swift Shopper SDK uses some additional frameworks that unfortunately do not provide bitcode for the latest iOS versions. (AWS-Cognito is the culprit!) Unfortunately, this means that all apps that use the Swift Shopper SDK cannot include bitcode in the app. Solution: Disable bitcode in your app’s build settings:

Page 139 of 148

Page 140: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 7: App Store Release The Swift Shopper SDK available from http://developer.swiftshopper.com is a version of the Swift Shopper SDK that uses the prerelease, sandboxed version of the Swift Shopper cloud infrastructure that is suitable for development, testing and verification of apps that use Swift Shopper prior to publicly releasing any such apps. The Swift Shopper SDK is also available to licensed retailers and their agents in a format that uses the live, production version of the Swift Shopper cloud infrastructure. Retailers may download the production format of the Swift Shopper SDK from the Swift Shopper retailer portal. Differences Between Prerelease and Production SDK: Both versions of the Swift Shopper SDK are full versions built from the same Swift Shopper code base. The prerelease version is simply configured to communicate with the servers and services in the Swift Shopper prerelease cloud infrastructure. The live, production version is configured to communicate with the servers and services in the Swift Shopper live, production cloud infrastructure. Differences Between Prerelease and Production Infrastructure: Payment Processing: The Swift Shopper prerelease infrastructure processes payments in “dry-run” fashion only. When testing Apple Pay, you’ll need to provide valid credit card data in order to fully “dry-run” test Apple Pay. However, the Swift Shopper prerelease infrastructure will not actually charge the card. When paying directly in your app with a credit card, outside of Apple Pay, you will need to enter special test card numbers as described here: https://stripe.com/docs/testing For example: Card number 4242 4242 4242 4242 with any expiration date in the future; and with any 3 digits for the CVC. You can also test negative scenarios such as card declined using corresponding test card numbers as documented at https://stripe.com/docs/testing. Point-Of-Sale Integration: The Swift Shopper prerelease infrastructure synchronizes in-app purchases with the retail store’s back-end point-of-sale system in “dry-run” fashion only, in order to not interfere with ordinary business transactions at the store. SDK Key: Each retailer has two SDK keys: an SDK key valid for development/test apps that are compiled with a Swift Shopper prerelease SDK and an SDK key valid for live/released apps that are compiled with a Swift Shopper production SDK.

Page 140 of 148

Page 141: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Retailer Store Id: The retailer store id that your app passes to SwiftShopperFramework. enterStore(...) will be a different id for apps that are compiled with a Swift Shopper prerelease SDK versus a Swift Shopper live/production SDK. This affects only those apps that by design work with only and exactly one physical retail store location. Background: iOS CPU Architectures Real iOS devices such as iPhone and iPad feature ARM CPU architectures whereas iOS simulator devices run within Macintosh personal computers which feature INTEL/AMD CPU architectures. iOS frameworks (and iOS apps) in general are built with machine code support for one or more CPU architectures. The Swift Shopper SDK prerelease framework version includes machine code support for both ARM and INTEL/AMD CPU architectures for your convenience during development and testing. This means that when you incorporate the framework into your app as specified in this document, you may run your app on either a real iOS device such as an iPhone or iPad; and you may also run your app on any iOS simulator device via XCode. Consequently, this means that when you build your app using the Swift Shopper SDK prerelease framework, your app contains machine code for ARM and INTEL/AMD CPU architectures. The Swift Shopper SDK production framework is distributed in two forms: a framework for ARM and a framework for INTEL/AMD. Compile your app with the Swift Shopper SDK production framework for INTEL/AMD in order to perform final testing on simulator devices. Finally, compile your app with the Swift Shopper SDK production framework for ARM in order to perform final testing on real iOS devices and to create your final build that you will upload to Apple “iTunes Connect” and ultimately release in the Apple App Store. The Apple App Store will only allow you to publish an app that is compiled exclusively for ARM CPU architectures. Apple will reject any app that is submitted to the App Store if the app contains machine code for any CPU architecture other than ARM. Your app will exclusively contain Swift Shopper SDK machine code for ARM CPU architectures after compiling your app with the Swift Shopper SDK production framework for ARM. (The resulting app would no longer run on any iOS simulator devices since the resulting app would not feature machine code for the INTEL/ARM CPU architecture.) Preparing Your App For App Store Release:

1. Prepare your app for App Store release following current Apple guidelines. 2. Acquire the latest Swift Shopper SDK live/production framework file for ARM, the latest

Swift Shopper SDK live/production framework file for INTEL/AMD, your retailer’s production SDK key, and your retailer’s production retail store id if applicable. If you are an agent for a retailer, ask the retailer to acquire these from the “Swift Shopper Retailer Portal” and securely provide them to you. For example, do NOT use email since email is

Page 141 of 148

Page 142: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

not secure. For example, use a password-protected file sharing mechanism such as your retailer’s internal SFTP service if one exists, Google Drive with a non-public, user-to-user file share, or Drop Box via a non-public user-to-user file share, or a similar password-protected / user-verified file sharing mechanism.

3. Update your App Delegate to pass the retailer’s production key into the SwiftShopperFramework. initialize(...) function.

4. Update any location(s) in your source code that call SwiftShopperFramework. enterStore(...) to pass in the retailer’s production retail store id if your app calls into SwiftShopperFramework. enterStore(...).

5. Production Test Using iOS Simulators: a. Replace the SwiftShopperSDK.framework file in your app’s source code directory

with the INTEL / simulator version of the live/production Swift Shopper SDK. [Framework files are actually directories with a specified format of sub-directories and files. However, the Macintosh “Finder” utility displays each Framework as being a single file.]

b. From XCode, build and deploy your app to an iOS simulator. c. Test your app. Any product barcodes that you scan will reflect the real, up-to-date

pricing at the store. Any deals that you view will be real, current advertised deals at the store. Use Caution / Restraint: any purchases that you make will cost real money and will be synchronized into the store’s live point-of-sale back-end system.

d. Repeat (b) and (c) for all iOS platforms that you wish to support. This is also a good, final opportunity for you to verify that all of your app’s user interfaces layout and render nicely on all possible iOS platforms.

6. Production Test Using Real iOS Devices a. Replace the SwiftShopperSDK.framework directory in your app’s source code

directory with the ARM / “generic iOS device” version of the live/production Swift Shopper SDK.

b. From XCode, build and deploy your app to your real iOS device. (At this point the resulting app only contains machine code for ARM CPU architectures.)

c. Test your app. Any product barcodes that you scan will reflect the real, up-to-date pricing at the store. Any deals that you view will be real, current advertised deals at the store. Use Caution / Restraint: any purchases that you make will cost real money and will be synchronized into the store’s live point-of-sale back-end system.

d. Repeat (b) and (c) as you wish for any other real iOS devices in which you wish to test your app.

7. Archive / package / upload your app to iTunes Connect following current Apple guidelines.

8. Test your app directly from iTunes Connect per current Apple guidelines.

Page 142 of 148

Page 143: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

HINTS:

a. First uninstall your previously deployed app from your real iOS test device(s) b. Make sure that you have configured iTunes connect and TestFlight for your

“iTunes Connect” account, make sure that your real iOS test device(s) is/are logged into your “iTunes Connect” account, make sure that you have downloaded and installed the Apple “Test Flight” app on your real iOS test device(s), make sure you have invited your “iTunes Connect” account to test your app, and make sure you have accepted the “iTunes Connect” invitation from your real iOS test device(s).

c. Install your app from “Test Flight” onto your test device(s). d. Test your app again on your test device(s). e. Optional / Suggestion: Release your app to one or more “beta” testers via the

“iTunes Connect” console. f. Optional / Suggestion: Recruit and solicit feedback from “beta” testers of your

app, preferably using your app to shop for real at your retailer’s physical location(s).

g. Assuming that your app performs and behaves sufficiently well (using yours and/or your retailer’s judgement), submit your app to the Apple App Store for public release following current Apple guidelines.

Page 143 of 148

Page 144: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

Appendix 8: License Agreement SOFTWARE DEVELOPMENT KIT (SDK) LICENSE AGREEMENT Swift Shopper, Inc. DEVELOPMENT KIT (SDK) LICENSE AGREEMENT Thank you for your interest in Swift Shopper, Inc. ("Swift Shopper"), and its shopping platform and associated services (the "Service"), and related software development kit, consisting of the documentation ("Documentation"), redistributable libraries ("Libraries"), sample code ("Sample Code"), and other materials provided to you directly in the applicable SDK download, and any upgrades, modified versions, additions, and improvements therefor, if any (collectively, the "SDK") designed to enable software developers to build applications on top of the Service. This Software License Agreement (the "Agreement") governs use of the SDK by you, and/or the entity on whose behalf you are downloading the SDK ("you"). BY DOWNLOADING, INSTALLING, OR OTHERWISE ACCESSING OR USING THE SDK, YOU AGREE THAT YOU HAVE READ, UNDERSTOOD, AND AGREE TO BE BOUND BY THE AGREEMENT. IF YOU DO NOT AGREE, YOU MAY NOT USE THE SDK. Accordingly, you and Swift Shopper acknowledge and agree as follows: 1. LIMITED LICENSE. Subject to your complete and ongoing compliance with all the terms and conditions set forth in this Agreement, including without limitation all license limitations and restrictions set forth herein, Swift Shopper grants you the following limited, non-exclusive, non-transferable, non-sublicensable, revocable licenses to: a. use, and (where applicable) authorize your employees to use, the Documentation internally solely in connection with developing your own branded applications that interoperate with the Service ("Applications"); b. incorporate unmodified Libraries into your Application, solely for the purpose of enabling interoperability with the Service, solely in accordance with all applicable Documentation and applicable terms, and subject to you obtaining and maintaining an SDK key from Swift Shopper, to distribute Libraries so incorporated in your compliant Application to end users in executable form (except and solely to the extent that the Libraries are written in a language that is traditionally delivered for runtime interpretation in source code form); and c. use, modify, and redistribute the Sample Code pursuant to the applicable open source license, as identified in the headers or associated Documentation.

Page 144 of 148

Page 145: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

2. RESTRICTIONS. By accessing or using the SDK, you represent, warrant, and covenant that (a) you are a person or business entity engaged in the development of software applications, and (b) in the case of a business entity, you have the full power and authority to bind such entity to the terms of this Agreement. References to "you" herein shall refer to you, and/or the entity on whose behalf you are using the SDK, and all individual users of the SDK on behalf of such entity. You acknowledge that the foregoing license does not include any right to (i) redistribute, sell, lease, license, or modify any portion of the SDK, or (ii) distribute, deploy, or otherwise utilize Applications on a public, production, commercial, or other similar purpose other than internal use for evaluation and the development of non-public, experimental Applications (any other public, production, commercial, or similar use requires a separate agreement with Swift Shopper), or (iii) use or implement any undocumented feature or API, or use any documented feature or API other than in accordance with applicable documentation. You may not reproduce, distribute, publicly display, or publicly perform any part of the SDK, except as provided herein or in the applicable open source license. Except if, and solely to the extent that, such a restriction is not authorized herein, or impermissible under applicable law or applicable Third Party Software (defined below) license terms, you may not (w) decompile, reverse engineer, or otherwise access or attempt to access the source code for the SDK not made available to you in source code form, or make or attempt to make any modification to the SDK; or (x) remove, obscure, interfere with or circumvent any feature of the SDK, including without limitation any copyright or other intellectual property notices, security, or access control mechanism; or (y) access the service or the servers or networks providing the service except via the SDK; or (y) create a library, application programming interface, or SDK that functions substantially the same as the service and offer it for use by third parties; or (z) interfere with or disrupt the service or the servers or networks providing the service. You may not use the SDK for any purpose other than interoperating with the Service in a manner for which the SDK and Service are expressly designed. If you are prohibited under applicable law from using the SDK, you may not use them, and you will comply with all applicable laws and regulations (including without limitation laws and regulations related to export controls) in connection with your use of the SDK. Without limiting the generality of the foregoing, you represent and warrant that the SDK will not be shipped, transferred or exported into any country or used in any manner prohibited by the United States Export Administration Act or any other export laws, restrictions or regulations (collectively the "Export Laws"). In addition, if the SDK is identified as export controlled items under the Export Laws, you represent and warrant that you are not a citizen, or otherwise located within, an embargoed nation (including without limitation Crimea, Cuba, Iran, North Korea, Sudan, or Syria and that you are not otherwise prohibited under the Export Laws from receiving the SDK. You may not use the SDK for any purpose, or use the SDK in the development of any Application that is for the purpose of lifesaving, emergency response, or otherwise for deployment in any circumstance in which failure would be likely to lead to property damage, environmental damage, personal injury, or death. ANY USE IN VIOLATION OF THE FOREGOING LIMITATIONS AND RESTRICTIONS IS STRICTLY PROHIBITED, AND UNLICENSED.

Page 145 of 148

Page 146: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

3. RESERVATION OF RIGHTS. The SDK is owned by Swift Shopper and licensed, not sold, to you. The SDK, content, visual interfaces, interactive features, information, graphics, design, compilation, computer code, products, services, and all other elements of the SDK and related documentation (the "Swift Shopper Materials"), are protected by copyright, trade dress, patent, and trademark laws of the United States and other jurisdictions, international conventions, and all other relevant intellectual property and proprietary rights, and applicable laws. As between you and Swift Shopper, all Swift Shopper Materials, including intellectual property rights therein and thereto, are the sole and exclusive property of Swift Shopper or its subsidiaries or affiliated companies and/or its third-party licensors. You may not to sell, license, distribute, copy, modify, publicly perform or display, transmit, publish, edit, adapt, create derivative works from, or make any use of the Swift Shopper Materials except as expressly authorized hereunder. Swift Shopper reserves all rights not expressly granted in this Agreement. You do not acquire any right, title or interest to the Swift Shopper Materials, whether by implication, estoppel, or otherwise, except for the limited rights set forth in this Agreement. 4. CONFIDENTIALITY. The SDK (including as embodied in or utilized by any Application) is the confidential and proprietary information of Swift Shopper, and you may not, during the term or thereafter, disclose them to any third party, or to use them for any purpose other than as expressly provided herein, without a separate written agreement with Swift Shopper authorizing you to do so. 5. FEEDBACK. If you provide Swift Shopper with any comments, bug reports, feedback, enhancements, or modifications proposed or suggested by you for the SDK or the Service ("Feedback"), such Feedback is provided on a non-confidential basis (notwithstanding any notice to the contrary you may include in any accompanying communication), and Swift Shopper shall have the right to use such Feedback at its discretion, including, but not limited to the incorporation of such suggested changes into the Swift Shopper Materials, SDK or Service. You hereby grant Swift Shopper a perpetual, irrevocable, transferable, sublicensable, nonexclusive license under all rights necessary to so incorporate and use your Feedback for any purpose, including to make and sell products and services. 6. THIRD PARTY SOFTWARE. The SDK consists of a package of components, including certain third party software ("Third Party Software") that are provided by their authors under separate license terms (the "Third Party Terms"), as described in more detail in the SDK, and online at https://developer.swiftshopper.com/licenses. Your use of the Third Party Software in conjunction with the SDK in a manner consistent with this Agreement is permitted, however, you may have broader rights under the applicable Third Party Terms and nothing in this Agreement is intended to impose further restrictions on your use of the Third Party Software. 7. TERM AND TERMINATION. This Agreement will remain in effect until terminated. The Agreement, and your rights and licenses hereunder, will terminate immediately upon your breach of the Agreement. You may terminate the Agreement by uninstalling and ceasing all use

Page 146 of 148

Page 147: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

of the SDK. Swift Shopper may terminate this Agreement at any time for any reason, including without limitation any actual or suspected misuse or abuse by you of the SDK or any violation of this Agreement. Following any termination of this Agreement, you must immediately uninstall and cease use of the SDK, and destroy all copies. Sections 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, and 11 shall survive any termination of this Agreement. 8. WARRANTY DISCLAIMER AND LIMITATION OF LIABILITY. THE SDK AND ALL ASSOCIATED DOCUMENTATION, LIBRARIES, AND SAMPLE CODE ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, SWIFT SHOPPER DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OR CONDITIONS OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, TITLE, QUALITY, RESULTS, AND NON-INFRINGEMENT. SWIFT SHOPPER EXPRESSLY DISCLAIMS ANY WARRANTIES OF ANY KIND WITH RESPECT TO THE ACCURACY OR FUNCTIONALITY OF THE SDK, AND WITH RESPECT TO THE ACCURACY, VALIDITY, OR COMPLETENESS OF ANY INFORMATION OR FEATURES AVAILABLE THROUGH THE SDK, OR THE QUALITY OR CONSISTENCY OF THE SDK OR RESULTS OBTAINED THROUGH ITS USE. UNDER NO CIRCUMSTANCES WILL SWIFT SHOPPER BE LIABLE FOR ANY CONSEQUENTIAL, SPECIAL, INDIRECT, INCIDENTAL OR PUNITIVE DAMAGES WHATSOEVER ARISING OUT OF THE USE OR INABILITY TO USE THE SDK, EVEN IF SWIFT SHOPPER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, AND NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. IN NO EVENT WILL SWIFT SHOPPER'S AGGREGATE LIABILITY FOR DAMAGES ARISING OUT OF THIS AGREEMENT OR THE TERMS EXCEED THE GREATER OF AMOUNTS PAID BY YOU FOR THE SDK, IF ANY, OR $50USD. SOME JURISDICTIONS DO NOT ALLOW LIMITATIONS ON IMPLIED WARRANTIES OR THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, SO THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU. IN SUCH AN EVENT THE ABOVE LIMITATIONS AND EXCLUSIONS WILL BE ENFORCED TO THE MAXIMUM EXTENT PERMITTED UNDER APPLICABLE LAW. 9. INDEMNITY. You agree to indemnify, defend and hold Swift Shopper and its affiliates, officers, directors, suppliers, licensors, and other customers harmless from and against any and all liability and costs, including reasonable attorneys' fees incurred by such parties, in connection with or arising out of your Applications, your use or misuse of the SDK, or your violation of this Agreement, any applicable law or regulation. 10. GOVERNING LAW; VENUE. Any claim relating to the SDK or Service shall be governed by the laws of California, without regard to conflict of laws provisions. Disputes arising under this shall be resolved in, and subject to the sole and exclusive jurisdiction of the state and federal courts located in the Northern District of California.

Page 147 of 148

Page 148: Swift Shopper Native SDK for iOS Development Guide · Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30 As the command executes, the pod utility will download and install

Swift Shopper Native SDK for iOS Development Guide 2018-Apr-30

11. MISCELLANEOUS. This Agreement is the entire agreement between you and Swift Shopper, and supersedes any and all prior agreements, negotiations, or other communications between you and Swift Shopper, whether oral or written, with respect to the subject matter hereof, and, except as expressly provided herein, cannot be modified except in writing signed by both parties. In the event that any provision of this Agreement is held to be invalid or unenforceable, then: (a) such provision shall be deemed reformed to the extent strictly necessary to render such provision valid and enforceable, or if not capable of such reformation shall be deemed severed from this Agreement; and (b) the validity and enforceability of all of the other provisions hereof, shall in no way be affected or impaired thereby. You may not assign this Agreement without the prior written consent of Swift Shopper, whether expressly or by operation of law, including in connection with a merger or change of control, and any such attempted assignment shall be void and of no effect. Swift Shopper may assign this Agreement without restriction and without any notice to you. Subject to the foregoing, this Agreement shall be binding on the parties and their respective successors and permitted assigns. You acknowledge and understand that if Swift Shopper is unable to provide the SDK as a result of a force majeure event Swift Shopper will not be in breach of this Agreement. A force majeure event means any event beyond the control of Swift Shopper. The failure to exercise, or delay in exercising, a right, power or remedy provided in this Agreement or by law shall not constitute a waiver of that right, power or remedy. Swift Shopper's waiver of any obligation or breach of this Agreement shall not operate as a waiver of any other obligation or subsequent breach of the Agreement. The English language version of this Agreement shall be the official and controlling version, and any translation provided is solely for convenience. The SDK is a "Commercial Item" as that term is defined at 48 C.F.R. 2.101, consisting of "Commercial Computer Software" and "Commercial Computer Software Documentation." If and to the extent the SDK is supplied to or purchased by or on behalf of a United States government entity or an entity licensing the SDK for or on behalf of a United States government entity, the SDK is licensed (a) only as a Commercial Item and (b) with only those rights as are granted to all other end users pursuant to the terms and conditions of this agreement. Last updated: April 30, 2019

Page 148 of 148