>  Switch To Link 5 and API v2 Documentation

iOS

Follow these instructions to set up your iOS integration.

Setup#

Argyle iOS SDK provides a way to integrate Argyle Link into your iOS app.

Requirements:

  • iOS 12.0+
  • Xcode 12.0+
  • Swift 5+

Argyle recommends that you lock your app to portrait orientation.

Adding the SDK dependency#

You can add the SDK dependency with Swift Package Manager or CocoaPods.

Swift Package Manager#

Swift Package Manager, or SwiftPM, is a tool for managing the distribution of Swift code. It is integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

To integrate Argyle Link into your Xcode project using SwiftPM follow the Apple documentation. Search for the argyle-link-ios package and use the version-based package requirements.

CocoaPods#

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Argyle into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Argyle', '4.x.x'

Use pod install and pod update commands to install/update pods afterward.

Configuring and starting the flow#

Replace YOUR_LINK_KEY with your own Link key. Find your Link key in the Link keys section of Argyle Console.

iOS SDK configuration:

1class ViewController: UIViewController {
2
3 override func viewDidLoad() {
4    _ = Argyle.shared
5      .loginWith(linkKey: "YOUR_LINK_KEY", apiHost: "https://api-sandbox.argyle.com/v1")
6      .linkItems(["amazon_flex", "uber"]) // Can be skipped if all Link items are needed
7      .resultListener(self)
8    }
9
10  @IBAction func argyleNewUser(_ sender: Any) {
11    let argyle = Argyle.shared.controller
12    argyle.modalPresentationStyle = .fullScreen
13    self.present(argyle, animated: true, completion: nil)
14  }
15}
16
17extension ViewController: ArgyleResultListener {
18
19    func onUserCreated(token: String, userId: String) {
20        print("APP: onUserCreated((token: \(token), userId: \(userId))")
21    }
22
23    func onAccountCreated(accountId: String, userId: String, linkItemId: String) {
24        print("APP: onAccountCreated(accountId: \(accountId), userId: \(userId), linkItemId: \(linkItemId))")
25    }
26
27    func onAccountConnected(accountId: String, userId: String, linkItemId: String) {
28        print("APP: onAccountConnected(accountId: \(accountId), userId: \(userId), linkItemId: \(linkItemId))")
29    }
30
31    func onAccountUpdated(accountId: String, userId: String, linkItemId: String) {
32        print("APP: onAccountUpdated(accountId: \(accountId), userId: \(userId), linkItemId: \(linkItemId))")
33    }
34
35    func onAccountRemoved(accountId: String, userId: String, linkItemId: String) {
36        print("APP: onAccountRemoved(accountId: \(accountId), userId: \(userId), linkItemId: \(linkItemId))")
37    }
38
39    func onAccountError(accountId: String, userId: String, linkItemId: String) {
40        print("APP: onAccountError(accountId: \(accountId), userId: \(userId), linkItemId: \(linkItemId))")
41    }
42
43    func onPayDistributionSuccess(accountId: String, userId: String, linkItemId: String) {
44        print("APP: onPayDistributionSuccess(accountId: \(accountId), userId: \(userId), linkItemId: \(linkItemId))")
45    }
46
47    func onPayDistributionError(accountId: String, userId: String, linkItemId: String) {
48        print("APP: onPayDistributionError(accountId: \(accountId), userId: \(userId), linkItemId: \(linkItemId))")
49    }
50  
51    func onUserCreated(token: String, userId: String) {
52          print("APP: onWorkerCreated((token: \(token), userId: \(userId))")
53    }
54
55    func onError(error: ArgyleErrorType) {
56        print("APP: onError(error: \(error.rawValue))")
57    }
58  
59    func onUIEvent(name: String, properties: [String: Any]) {
60        print("APP: onUIEvent(name: \(name), properties: \(properties)")
61    }
62  
63    func onTokenExpired(handler: @escaping (String) -> ()) {
64        handler("new_token")
65    }
66
67    func onClose() {
68        print("APP: onClose")
69    }
70}

The apiHost in this iOS SDK configuration example is set to the Argyle Sandbox API (https://api-sandbox.argyle.com/v1). It's a good idea to test your implementation in Sandbox mode first, then change this to the Production API (https://api.argyle.com/v1) when you are ready to go live.

Normally, the user closes Link but you can also close it by calling Argyle.shared.close().

We strongly recommend upgrading the SDK as soon as there is a new version available. This helps you provide the best Argyle Link experience in your application.

To receive notifications when a new release is issued, you can watch for releases on our repositories or subscribe to our Changelog.

Configuration#

Argyle Link provides multiple configuration options and callbacks that customize how this UI element functions in your application. The only argument that is mandatory when invoking Argyle Link is the Link key, which you can find in Argyle Console.

By default, anytime Argyle Link is initialized, it will be treated as a new session for a new user. To ensure your users retain their previous state in Argyle Link when it is re-initialized for them, your application must use the userToken parameter.

For a full list of Link configuration parameters, see the Link reference.

User tokens#

User tokens are temporary access keys that let you start Argyle Link for an existing user.

Tokens are short-lived. Generate a new token using the API every time you initialize Argyle Link for a returning user.

You can create user tokens using the /user-tokens endpoint.

Make sure that you request user tokens on your server-side and your client_id and client_secret are never exposed on the front-end.

Callbacks#

For a full list of callbacks, see the Link reference.

Upgrade#

See the Link SDK for iOS upgrade guide for instructions on upgrading your integration.

Updating Argyle status...
© 2024 Argyle Systems Inc.argyle.com