Latest 1.1
License Copyright
Platforms ios 11.0
Dependencies RealmSwift

CI Status


To run the example project, clone the repo, and run from the Example directory first.


iOS Version required is 11.0


SmartMultipeer is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SmartMultipeer'


  1. Import the module
    import SmartMultipeer

Classes & Protocol

You need to use PeerConnectivity.swift file that manages everything and contains all required methods. DataSync.swfit protocol contains DataSyncDelegate that needs to be implemented in class to receive data. It contains 4 methods that are:

    func sync(dataDidReceive: Any, ofType: Type, at: Date)

Method is called when data is received on other device

    func update(devices: [PeerDevice], at: Date)

Method is called when any device is added / lost

    func lost(device: PeerDevice, at: Date)

Method is called when any device is lost. This method is optional

    func acknowledge(from: PeerDevice, at: Date, forDataID: Any)

Method is called when data is received and sender will be acknowledged. This method is optional

How to start

  1. Initialize service type by using:

    PeerConnectivity.instance.service = "sample-service"
  2. Setup Multipeer Connectivity

    PeerConnectivity.instance.setup(fromViewController: self, withDelegate: self)
  3. Connect Users

    a. Individually

    PeerConnectivity.instance.connect(forUser: .Peer)
    PeerConnectivity.instance.connect(forUser: .Host)

    b. Simultaneously

  4. To send data to connected peers
    func send(data: Any, ofType: Type, withID: Any)

    You can send data of any type whether its primitive or custom model that is designed or encapsulated in class and ‘ofType’ that can contain values defined in Type.swift enum. ‘withID’ can be used to validated at the time of acknowledgement.

Other helper methods & properties


Disconnect all peers and will stop advertising and browsing


Returns the history of devices connected up till now


Returns the information of current device


Return all available peers ready to get connected


Returns all connected peers


AJ Sagar Parwani
Email: [email protected]


SmartMultipeer is available under the Author’s license. See the LICENSE file for more info.

Latest podspec

    "name": "SmartMultipeer",
    "version": "1.1",
    "summary": "Multipeer Connectivity for iOS Devices with Acknowlegement",
    "platforms": {
        "ios": "11.0"
    "swift_version": "4.2",
    "description": "Smart Multipeer Connectivity designed with acknowledgment facility that includes the time of delivery with the id of data sent. You can set primary id of your model which you want to sync",
    "homepage": "",
    "license": {
        "type": "Copyright",
        "file": "LICENSE"
    "authors": {
        "Ajay Sagar Parwani": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.1"
    "source_files": "SmartMultipeer/**/*.{swift}",
    "dependencies": {
        "RealmSwift": []

Pin It on Pinterest

Share This