All Projects â†’ dingwilson â†’ Multipeer

dingwilson / Multipeer

Licence: mit
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Multipeer

Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+6197.65%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+948.24%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+21603.53%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Freedom
The Freedom to Open URLs in Third-Party Browsers on iOS with Custom UIActivity Subclasses.
Stars: ✭ 85 (-50%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Bluetoothkit
Easily communicate between iOS/OSX devices using BLE
Stars: ✭ 2,027 (+1092.35%)
Mutual labels:  bluetooth, cocoapods, carthage
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (-47.06%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Berkanansdk
Bluetooth mesh messaging SDK for apps
Stars: ✭ 150 (-11.76%)
Mutual labels:  bluetooth, mesh-networks, offline
Cameramanager
Simple Swift class to provide all the configurations you need to create custom camera view in your app
Stars: ✭ 1,130 (+564.71%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-7.06%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Coregpx
A library for parsing and creation of GPX location files. Purely Swift.
Stars: ✭ 132 (-22.35%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+615.29%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Bluetonium
Bluetooth mapping in Swift
Stars: ✭ 159 (-6.47%)
Mutual labels:  bluetooth, cocoapods, carthage
Dikit
Dependency Injection Framework for Swift, inspired by KOIN.
Stars: ✭ 77 (-54.71%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Buckets Swift
Swift Collection Data Structures Library
Stars: ✭ 106 (-37.65%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+594.12%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Randomkit
Random data generation in Swift
Stars: ✭ 1,458 (+757.65%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Sketchkit
A lightweight auto-layout DSL library for iOS & tvOS.
Stars: ✭ 40 (-76.47%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Wstagsfield
An iOS text field that represents tags, hashtags, tokens in general.
Stars: ✭ 1,013 (+495.88%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-22.94%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-18.82%)
Mutual labels:  cocoapods, carthage, swift-package-manager

Build Status CocoaPods Version Status Carthage compatible doccov iOS MacOS tvOS Swift MIT License

A wrapper for Apple's MultipeerConnectivity framework for offline data transmission between Apple devices. This framework makes it easy to automatically connect to multiple nearby devices and share information using either bluetooth or wifi radios.

  1. Features
  2. Integration
  3. Usage
  4. Example
  5. License
  6. Authors

Features

  • [x] Supports iOS/macOS/tvOS
  • [x] Auto Connection
  • [x] Auto Invitations/Advertising
  • [x] Send/Receive data via MultipeerConnectivity Framework
  • [x] Specify data types for easy handling

Integration

CocoaPods

You can use CocoaPods to install MultiPeer by adding it to your Podfile:

pod 'MultiPeer'

Carthage

You can use Carthage to install MultiPeer by adding it to your Cartfile:

github "dingwilson/MultiPeer"

Swift Package Manager

For SPM, add the following to your package dependencies:

.package(url: "https://github.com/dingwilson/MultiPeer.git", .upToNextMinor(from: "0.0.0"))

Usage

To get started, import MultiPeer.

import MultiPeer

Then, simply initialize MultiPeer with the name of your session (serviceType). There are two modes of connections (advertiser and browser). To utilize both, simply use .autoConnect().

MultiPeer.instance.initialize(serviceType: "demo-app")
MultiPeer.instance.autoConnect()

Any data transmitted by MultiPeer will always be accompanied by a numerical "type", to ensure other peers know what kind of data is being received, and how to properly process it. You can manage this by creating a UInt32 enum, as shown below:

enum DataType: UInt32 {
  case string = 1
  case image = 2
  // ...
}

To send data, simply use the .send(object: type:) function:

MultiPeer.instance.send(object: "Hello World!", type: DataType.string.rawValue)

To receive data, we must conform to the MultiPeerDelegate protocol:

func multiPeer(didReceiveData data: Data, ofType type: UInt32, from peerID: MCPeerID) {
  switch type {
    case DataType.string.rawValue:
      let string = data.convert() as! String
      // do something with the received string
      break
      		
    case DataType.image.rawValue:
      let image = UIImage(data: data)
      // do something with the received UIImage
      break
      		
    default:
      break
  }
}

func multiPeer(connectedDevicesChanged devices: [String]) {
}

Ensure that you set the MultiPeer delegate.

MultiPeer.instance.delegate = self

Finally you'll need to enable incoming / outgoing connections in your entitlements.

Congratulations! You have successfully sent data using MultiPeer! For more detailed information (including details of other functions), please see the docs.

Example

For an example app using MultiPeer, checkout MultiPeer_Sample.

License

MultiPeer is released under an MIT License. See LICENSE for details.

Authors

Project heavily inspired by Apple-Signal.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].