UriBeacon 0.0.8

UriBeacon 0.0.8

测试已测试
Lang语言 SwiftSwift
许可 MIT
发布最后发布2015年4月
SPM支持 SPM

Tanner Nelson 维护。



UriBeacon 0.0.8

  • Tanner Nelson

UriBeacon Swift / Objc CocoaPod

通过使用这个 Cocoapod 连接到物理网,将 UriBeacon 功能添加到您的应用中。

pod 'UriBeacon'

添加 Podfile

在您的项目目录中运行:

pod init

打开新建的 Podfile 并添加以下行:

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
use_frameworks!

target '<<App Name Here>>' do
    pod 'UriBeacon'
end

现在下载并安装 Pod:

pod install

实现 UriBeacons

这里是一个示例视图控制器:

//
//  ViewController.swift
//  Physical Web
//
//  Created by Tanner Nelson on 3/31/15.
//  Copyright (c) 2015 Blue Bite. All rights reserved.
//

import UIKit
import UriBeacon

class ViewController: UIViewController, UriBeacon.DiscoveryDelegate {

    var beaconScanner: UriBeacon.Scanner?

    override func viewDidLoad() {
        super.viewDidLoad()

        self.beaconScanner = UriBeacon.Scanner(delegate: self)
        self.beaconScanner?.startScanning()
    }

    func updateURIs() {
        print("URIs: ")
        println(self.beaconScanner?.uris)
    }

    func scanner(scanner: Scanner, discoveredURI: URI) {
        self.updateURIs()
    }

    func scanner(scanner: Scanner, lostURI: URI) {
        self.updateURIs()
    }

}

注意,您可以直接通过添加以下代码使用 Google 的 UriBeacon SDK:

import GoogleUriBeacon

这为您提供了对所有底层 Google SDK 类的访问,如 UBUriBeacon 和 UBUriBeaconScanner。