AZPeerToPeerConnectivity is a wrapper on top of Apple iOS Multipeer Connectivity framework. It provides an easier way to create and manage sessions. Easy to integrate

Overview

AZPeerToPeerConnection Controller

Awesome Swift version Support Dependecy Manager Version License Platform

Features

  • Multipeer Connectivity
  • Connection via Bluetooth or Wifi
  • No need write all session, browser, services delegate

Installation

CocoaPods

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

$ gem install cocoapods

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

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

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

Then, run the following command:

$ pod install

Usage

Step 1

  • With P2PServiceHandler.sharedInstance setup connection and make sure to implement it's delegate
    let connection = P2PServiceHandler.sharedInstance
    override func viewDidLoad() {
        super.viewDidLoad()
        connection.delegate = self
        connection.setupConnection(serviceName: "AZP2Ptest")

        tableView.estimatedRowHeight = 50
        tableView.rowHeight = UITableViewAutomaticDimension
        textField.delegate = self
        
    }

Step 2

  • Next you need to connect to other devices, to do taht you just need to open McBrowser
  • You can pass your own McBrowser or just nil, it will present browser
    connection.joinSession(vc: self, mcBrowser: nil) // nil == default mcbrowsr

Step 3

  • Send data to other devices
  • To send data it is better to send in form of Dictionary
connection.sendData(data: ["message": textField.text ?? "defaultValue"]) // send data of type [String: Any]

Step 4

  • To receive data you have to implement delegate method
    func didRecieve(_ serviceHandler: P2PServiceHandler, data: [String : Any]) {
    
        DispatchQueue.main.async {
            if let val = data["message"] {
                print(val)// data recieved
            }
        }
    }

Done

Thats it, you successfully integrate AZPeerToPeerConnection

License

AZPeerToPeerConnection is available under the MIT license. See the LICENSE file for more info.

Author

Afroz Zaheer - (https://github.com/AfrozZaheer)

You might also like...
Bluejay is a simple Swift framework for building reliable Bluetooth LE apps.
Bluejay is a simple Swift framework for building reliable Bluetooth LE apps.

Bluejay is a simple Swift framework for building reliable Bluetooth LE apps. Bluejay's primary goals are: Simplify talking to a single Bluetooth LE pe

The Bluetooth LE library for iOS and Mac. 100% Swift.
The Bluetooth LE library for iOS and Mac. 100% Swift.

iOS-BLE-Library An in-development Bluetooth Low Energy Library by Nordic Semiconductor to interact with the , which is not complicated, but requires w

MacOS app which allows drag and drop of images to BLE thermal printers
MacOS app which allows drag and drop of images to BLE thermal printers

Print2BLE Copyright (c) 2021 BitBank Software, Inc. Written by Larry Bank [email protected] What is it? This project is a MacOS GUI applicatio

This is a simple app, which scans for BLE Peripherials and connect to them. The example works with NORDIC_UART_SERVICE.
This is a simple app, which scans for BLE Peripherials and connect to them. The example works with NORDIC_UART_SERVICE.

BLE Serial IOs Example This is a simple app, which scans for BLE Peripherials and connect to them. The example works with NORDIC_UART_SERVICE. UUIDS H

A very simple library to discover and retrieve data from nearby devices (even if the peer app works at background).
A very simple library to discover and retrieve data from nearby devices (even if the peer app works at background).

Discovery: A simple library to discover and retrieve data from nearby devices. Discovery is a very simple but useful library for discovering nearby de

An app for questioning people to try on different names and pronouns. A winner of the Swift Student Challenge 2022.
An app for questioning people to try on different names and pronouns. A winner of the Swift Student Challenge 2022.

DiscoverMe is an app for questioning, trans, nonbinary, and gender-nonconforming people to try on different names and pronouns that better suit their

The official Swift Library for Vital API, HealthKit and Devices

vital-ios The official Swift Library for Vital API, HealthKit and Devices Install We currently support SPM. Documentation Please refer to the official

BluetoothKit Easily communicate between iOS devices using BLE.

BluetoothKit Easily communicate between iOS devices using BLE. Background Apple mostly did a great job with the CoreBluetooth API, but because it enca

Fluetooth - Flutter library for sending bytes to Bluetooth devices on Android/iOS

A Flutter library for sending bytes to Bluetooth devices. Available on Android a

Owner
Afroz Zaheer
Afroz Zaheer
Blocks Based Bluetooth LE Connectivity framework for iOS/watchOS/tvOS/OSX. Quickly configure centrals & peripherals, perform read/write operations, and respond characteristic updates.

ExtendaBLE Introduction ExtendaBLE provides a very flexible syntax for defining centrals and peripherals with ease. Following a blocks based builder a

Anton 94 Nov 29, 2022
CombineCoreBluetooth is a library that bridges Apple's CoreBluetooth framework and Apple's Combine framework

CombineCoreBluetooth is a library that bridges Apple's CoreBluetooth framework and Apple's Combine framework, making it possible to subscribe to perform bluetooth operations while subscribing to a publisher of the results of those operations, instead of relying on implementing delegates and manually filtering for the results you need.

Starry 74 Dec 29, 2022
Functional wrapper for Apple's MultipeerConnectivity framework.

A functional wrapper for the MultipeerConnectivity framework. PeerConnectivity is meant to have a lightweight easy to use syntax, be extensible and fl

Reid Chatham 48 Jun 28, 2021
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices

A wrapper for Apple's MultipeerConnectivity framework for offline data transmission between Apple devices. This framework makes it easy to automatical

Wilson Ding 197 Nov 2, 2022
Build your own 'AirTags' 🏷 today! Framework for tracking personal Bluetooth devices via Apple's massive Find My network.

OpenHaystack is a framework for tracking personal Bluetooth devices via Apple's massive Find My network.

Secure Mobile Networking Lab 5.8k Jan 9, 2023
A simple framework that brings Apple devices together - like a family

Apple Family A simple framework that brings Apple devices together - like a family. It will automatically use bluetooth, wifi, or USB to connect and c

Kiran 62 Aug 21, 2022
The easiest way to use Bluetooth (BLE )in ios,even bady can use.

The easiest way to use Bluetooth (BLE )in ios,even bady can use.

刘彦玮 4.6k Dec 27, 2022
Diabetes: test the FreeStyle Libre glucose sensor as a Bluetooth Low Energy device, even directly from an Apple Watch.

Since the FreeStyle Libre 2 / 3 glucose sensors are Bluetooth Low Energy devices, I am trying to leverage their capabilities to implement something ne

Guido Soranzio 6 Jan 2, 2023
MiniVendingMachine - SwiftUI demo Apple Watch app to open a mini vending machine via bluetooth

Mini Vending Machine Use Apple Watch to open vending machine cells. Note: This a

CGH 3 Apr 8, 2022
iOS Bluetooth LE framework

Features A futures interface replacing protocol implementations. Timeout for Peripheral connection, Service scan, Service + Characteristic discovery a

Troy Stribling 696 Dec 25, 2022