Giter Club home page Giter Club logo

ios-vanilla's Introduction

ios-vanilla

A vanilla flavour version of basic Flybits iOS application for V3

This is an as-simple-as-you-get demostration of the Flybits V3 platform. Here you will learn how our Context, Content and Push SDKs are implemented in an application and learn how to leverage our SDKs and provide contextually relevant content to your users.

Our SDK is supported on iOS version 8 and up!

Documentation

Please visit our developer portal

Installation

CocoaPods

CocoaPods is a dependency manager for macOS, iOS, tvOS and watchOS projects. You can install it with the following command:

$ gem install cocoapods

To integrate the Flybits SDK into your Xcode project, add a Podfile file to your project and add the following lines:

use_frameworks!

pod 'FlybitsKernelSDK'
pod 'FlybitsContextSDK'
pod 'FlybitsPushSDK'

Manually

Add any Flybits frameworks to your project, navigate to your project file, project target, and ensure to add the frameworks to both Linked Frameworks and Libraries and Embedded Binaries sections.

Code Implementation

First import the relevant SDKs into your project:

import FlybitsKernelSDK
import FlybitsContextSDK
import FlybitsPushSDK

Implementation

Flybits Project ID

Obtain your Project ID from the Flybits Developer Portal

Once you have created an account on the Flybits Developer Portal and logged in, click the "MyProjects" link in the top right corner and "Create new project". Once you have finished creating a project, a Project ID is assigned to your new project - this identifier is required for you to access our services. Add this to a new Property List file (plist) with one key-value pair in your Xcode project. Supply the key "ProjectID" and value set to your new Project ID.

Logging in with Single Sign-On

For your user-login logic, use our connect(completion:) API

let manager = FlybitsManager()
let flybitsManager = FlybitsManager(projectID: projectID, idProvider: flybitsIDP, scopes: scopes)
let scopes: [FlybitsScope] = [KernelScope(), ContextScope(timeToUploadContext: 1, timeUnit: Utilities.TimeUnit.minutes), PushScope()]

let connectRequest = flybitsManager.connect { user, error in
    guard let user = user, error == nil else {
        print("Failed to connect")
        return
    }
    print("Welcome, \(user.firstname!)")
    // Logged in
}

Or if a user has already signed in, avoid asking them for their credentials a second time by using the isConnected(scopes:completion:) API

let isConnectedRequest = FlybitsManager.isConnected(scopes: scopes) { isConnected, user, error in
    guard error == nil else {
        print(error!.localizedDescription)
    }
    guard isConnected, let user = user else {
        // Not logged in
        return
    }
    // Logged in
}

Uploading Context

let contextPlugin = BankingDataContextPlugin(accountBalance: 50, segmentation: "Student", creditCard: "VISA")
_ = try? ContextManager.shared.register(self.contextPlugin!)

// ... Potentially mutate context plugin data here ...

let contextData = contextPlugin.toDictionary()

// Upload any context data you want to update here by passing it in an array
let contextDataRequest = ContextDataRequest.sendData([contextData]) { (error) -> () in
    guard error == nil else {
        // Error sending context data
        return
    }
    // Successfully uploaded context data
}.execute()

Getting Content

let contentDataRequest = Content.getAllRelevant(with: templateIDsAndClassModelsDictionary, pager: pager) { pagedContent, error in
    guard let pagedContent = pagedContent, error == nil else {
        // Returned without any relevant content
        return
    }
    // Valid content
}

Push

Implementation description will be added soon...

ios-vanilla's People

Contributors

alexsmith84 avatar chirayupatel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.