Latest 1.1.6
Homepage https://github.com/brainblocks/brainblocks-ios-sdk
License Apache License, Version 2.0 Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Platforms ios 11.0
Dependencies Alamofire, QRCode

brainblocks-ios-sdk

iOS SDK for integrating BrainBlocks into a mobile app

SDK Video Demo

demo

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.4+ is required to build BrainBlocksKit.

To integrate BrainBlocks into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target '<Your Target Name>' do
  pod 'BrainBlocksKit'
end

Then, run the following command:

$ pod install

Usage

In the ViewController that you would like to use BrainBlocks, import BrainBlockKit and implement code like the following.

import UIKit
import BrainBlocksKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        showPayment()
    }

    // Example Function
    func showPayment() {

        // payment nano amount. nano = 1 NANO/1000000
        var amount: Double = 1

        // payment view
        let style: UIBlurEffectStyle = .light

        // Follow the URL/QR standard here: https://github.com/clemahieu/raiblocks/wiki/URI-and-QR-Code-Standard
        let paymentAccount: String = "<Your Nano Payment Address Here>"

        //set time before session timeout. must be between 120-300 seconds
        let sessionTime: Int = 300

        // Launch BrainBlocks Popup Payment UI
        BrainBlocksPayment().launchBrainBlocksPaymentView(viewController: self, paymentCurrency: .nano, paymentDestination: paymentAccount, paymentAmount: amount, sessionTime: sessionTime, paymentMode: .Pay, backgroundStyle: style)
    }
 }

BrainBlocksKit Events

The BrainBlocksKit uses local notifications to send events. Each of the following event observer’s is optional but are needed to know when a specific event happens.

BrainBlocksSessionStart notification

// Example BrainBlocksSessionStart notification and function
NotificationCenter.default.addObserver(self, selector: #selector(sessionStart), name: NSNotification.Name(rawValue: "BrainBlocksSessionStart"), object: nil) 

@objc func sessionStart() {
    print("BrainBlocks Payment Session Started")
}

BrainBlocksSessionStartFailed notification

// BrainBlocksSessionStartFailed notification and function
NotificationCenter.default.addObserver(self, selector: #selector(sessionStartFailed), name: NSNotification.Name(rawValue: "BrainBlocksSessionStartFailed"), object: nil) 

@objc func sessionStartFailed() {
    print("BrainBlocks Payment Session Failed")
}

BrainBlocksPaymentSuccess notification

// BrainBlocksPaymentSuccess notification and function
NotificationCenter.default.addObserver(self, selector: #selector(sessionSuccess), name: NSNotification.Name(rawValue: "BrainBlocksPaymentSuccess"), object: nil) 

@objc func sessionSuccess() {
    print("session success")
}

BrainBlocksPaymentFailed notification

// BrainBlocksPaymentFailed notification and function
NotificationCenter.default.addObserver(self, selector: #selector(sessionFailed), name: NSNotification.Name(rawValue: "BrainBlocksPaymentFailed"), object: nil) 

@objc func sessionFailed() {
    print("session failed")
}

BrainBlocksSessionCancelled notification

// BrainBlocksSessionCancelled notification and function
NotificationCenter.default.addObserver(self, selector: #selector(sessionCancelled), name: NSNotification.Name(rawValue: "BrainBlocksSessionCancelled"), object: nil) 

@objc func sessionCancelled() {
    print("session cancelled")
}

BrainBlocksSessionTimeOut notification

// BrainBlocksSessionTimeOut notification and function
NotificationCenter.default.addObserver(self, selector: #selector(sessionTimeOut), name: NSNotification.Name(rawValue: "BrainBlocksSessionTimeOut"), object: nil) 

@objc func sessionTimeOut() {
    print("session time out")
}

BrainBlocksInsufficientPayment notification

// BrainBlocksInsufficientPayment notification and function
NotificationCenter.default.addObserver(self, selector: #selector(insufficientPayment), name: NSNotification.Name(rawValue: "BrainBlocksInsufficientPayment"), object: nil)

@objc func insufficientPayment() {
    print("session insufficient payment")
}

Donate

Donate to schenkty (contributor): xrb_1jnatu97dka1h49zudxtpxxrho3j591jwu5bzsn7h1kzn3gwit4kejak756y

Donate to BrainBlocks: xrb_1brainb3zz81wmhxndsbrjb94hx3fhr1fyydmg6iresyk76f3k7y7jiazoji

Latest podspec

{
    "name": "BrainBlocksKit",
    "version": "1.1.6",
    "summary": "A Payment Framework for Nano.",
    "description": "The BrainBlocksKit is a complete payment framework that can be used in any iOS app to accept Nano.",
    "homepage": "https://github.com/brainblocks/brainblocks-ios-sdk",
    "license": {
        "type": "Apache License, Version 2.0",
        "text": "    Licensed under the Apache License, Version 2.0 (the "License");n    you may not use this file except in compliance with the License.n    You may obtain a copy of the License atnn    http://www.apache.org/licenses/LICENSE-2.0nn    Unless required by applicable law or agreed to in writing, softwaren    distributed under the License is distributed on an "AS IS" BASIS,n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.n    See the License for the specific language governing permissions andn    limitations under the License.n"
    },
    "authors": "BrainBlocks",
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/brainblocks/brainblocks-ios-sdk.git",
        "tag": "v1.1.6"
    },
    "source_files": [
        "BrainBlocksKit",
        "BrainBlocksKit/**/*.{h,m,swift}"
    ],
    "resource_bundles": {
        "BrainBlocksKit": [
            "BrainBlocksKit/*.{storyboard,xib,png}"
        ]
    },
    "dependencies": {
        "Alamofire": [
            "~> 4.5"
        ],
        "QRCode": []
    },
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4"
    },
    "swift_version": "4.1"
}

Pin It on Pinterest

Share This