Overview

Get your API Keys

Connect App Clip & Instant App

Simply launch the Connect in your application using a URL. Here’s how to construct the Connect URL.

App Clips & Instant Apps let users enjoy native app experiences without the need to download a full app. Apple Developers & Android Developers.

Connect Helper Package

We provide packages to make it easy to generate a valid Connect URL. The Connect helper handles parameter validations automagically!

Install Using Swift Package Manager in Xcode

  1. Open your project in Xcode.
  2. Go to File > Add Packages....
  3. Enter the repository URL: https://github.com/gandalf-network/connect-ios-sdk.git.
  4. Choose the version rule (e.g., “Up to Next Major”) and click Add Package.
  5. Select the GandalfConnect package for your target.

Or Update Package.swift

// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "YourProjectName",
    dependencies: [
        .package(url: "https://github.com/gandalf-network/connect-ios-sdk.git", .upToNextMajor(from: "1.0.0"))
    ],
    targets: [
        .target(
            name: "YourTargetName",
            dependencies: ["GandalfConnect"]
        )
    ]
)

Then, run swift package update to fetch the dependency.

Usage

Import the package

import GandalfConnect

Initialization

Create an instance of ConnectInput with the necessary details:

let services: InputData = [
    "uber": .service(Service(traits: ["rating"], activities: ["trip"]))
]

let input = ConnectInput(
    publicKey: "yourPublicKey",
    redirectURL: "https://example.com",
    services: services
)

Initialize the Connect class:

let connect = Connect(input: input)

Generating URL

To generate a URL, call the generateURL method:

do {
    let generatedURL = try await connect.generateURL()
    print("Generated URL: \(generatedURL)")
} catch {
    print("Error generating URL: \(error)")
}

Read more on Github.

Finally, pull the data

1

Get Data Key

After your user is done linking their accounts, Connect will navigate to your redirectUrl with a query parameter called dataKey.

You can use the packages to get the dataKey easily.

Proceed by sending the dataKey to your server, where you can securely request the data you seek.

Alternatively, your redirectURL could be a server-side endpoint. You can get the dataKey directly from your application’s server.
2

Securely request the data (server-side)

Sauron Helper Packages

We provide packages that makes it super easy to interact with the Sauron API. They completely abstract away the complexity of authentication and interacting with the GraphQL APIs.

Installation

npm i -g @gandalf-network/eyeofsauron

eyeofsauron generate

This will generate an eyeofsauron folder in your project root directory.

Usage

Import the package

// Typescript
import Eye, { Source } from './eyeofsauron';
// ESModules
import Eye, { Source } from './eyeofsauron/index.js';
// CommonJS
const Eye = require('./eyeofsauron').default
const { Source } = require('./eyeofsauron');

Get Activity

const eye = new Eye({privateKey: process.env.PRIVATE_KEY})

const { data } = await eye.getActivity({dataKey: dataKey,  source: Source.Amazon, limit: 100, page: 2})

Get Traits

const { data: traits } = await eye.getTraits({
    dataKey: dataKey,
    source: Source.UBER,
    labels: [TraitLabel.RATING, TraitLabel.TRIP_COUNT],
})

Read more on Github.


That’s all!