/StreetPassBLE-iOS

iOSのすれ違い通信ライブラリ / iOS' s StreetPass Communication library

Primary LanguageSwiftMIT LicenseMIT

header

StreetPassBLE すれ違い通信

iOS's StreetPass Communication library

What is StreetPass Communication?

StreetPass is a Nintendo 3DS functionality which allows passive communication between Nintendo 3DS systems held by users in close proximity, an example being the sharing of Mii avatars in the StreetPass Mii Plaza application, and other game data. New data received from StreetPass is indicated via a green status light on the system.

Wiki

About this library

When the terminal with each other has become close to, it is capable of transmitting and receiving data of about 100 bytes.

8.1 is available in more than.

Questions and requests is here.

Animation

CocoaPods

pod 'StreetPass'

Carthage

github "gupuru/StreetPassBLE-iOS"

Run carthage update to build the framework and drag the built StreetPass.framework into your Xcode project.

Usage

Please add the following to the info.plist.

<key>Required background modes</key>
  <array>
       <string>App communicates using CoreBluetooth</string>
       <string>App shares data using CoreBluetooth</string>
  </array>

Start StreetPass

let street: StreetPass = StreetPass()
street.start()

Settings

  • UUID
  • Transmitted data
let street: StreetPass = StreetPass()

let streetPassSettings: StreetPassSettings = StreetPassSettings()
                .sendData(sendData)
                .allowDuplicates(false)
                .isConnect(true)
      
street.start(streetPassSettings)

Stop StreetPass

Please stop sure.

let street: StreetPass = StreetPass()
street.stop()

Delegate

Received data.

func receivedData(receivedData: ReceivedData) {
  //received data
}

Error

func streetPassError(error: NSError) {
  //error
}

Sample

class ViewController: UIViewController, StreetPassDelegate {

let street: StreetPass = StreetPass()

override func viewDidLoad() {
  super.viewDidLoad()

  street.delegate = self
  //start
  street.start()
}

override func viewDidDisappear(animated: Bool) {
     super.viewDidDisappear(animated)

     //stop
     street.stop()
}

func streetPassError(error: NSError) {
  //error
}

func receivedData(receivedData: ReceivedData) {
  //received data
}

License

The MIT License (MIT)

Copyright (c) 2017 Kohei Niimi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.