Easy Proximity-based Bluetooth LE Sharing for iOS

Overview

Description

Easy Proximity-based Sharing for iOS

Perfect for any iOS app that needs to quickly share items with nearby friends, such as groups, photo albums, photos, links, user profiles, etc, using Bluetooth Low Energy.

Users simply click "find nearby", and items from their friends' phones magically pop up on their screen for them to add with one tap.

Credits

SimpleShare was created by Laura Skelton.

Features

  • Easiest way to share items with nearby friends
  • Shares an array of item IDs over Bluetooth LE
  • Best way to allow users to join groups based on proximity
  • Shares info even when the app is in background mode (unlike iBeacons)

Installation

  • Open the SimpleShare Demo project and your XCode project
  • Drag the "SimpleShare" directory to your project (Make sure "Copy items into destination group folder", "Create groups for any added folders", and your target are all selected.)
  • Add the CoreBluetooth framework to your project (Under Build Phases -> Link Binary With Libraries, click the "+" to add "CoreBluetooth.framework" to your project.)
  • In your app's Info.plist file, add "Required Background Modes" -> "App shares data using CoreBluetooth", if you would like your devices that are sharing items to keep sharing even if they are in background mode.
  • Create a unique UUID to identify your app in SimpleShare. You can generate one here: http://www.uuidgenerator.net . Then plug it in to your application (after importing SimpleShare.h in any file you use SimpleShare in).
#import "SimpleShare/SimpleShare.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [SimpleShare sharedInstance].simpleShareAppID = @"your-uuid-goes-here";
    return YES;
}

Usage

See the SimpleShare Demo app for examples.

For simplicity, the SimpleShare Demo generates random UUIDs and shares them with nearby friends using the app. In a real app, you would probably get a user's items (such as their photo album IDs, or group IDs) from a web server, share those items with nearby friends, and then download the item details using the itemIDs from the server on your friend's phone.

Usage Examples:

#import "SimpleShare/SimpleShare.h"

@interface MyViewController : UITableViewController <SimpleShareDelegate>

@property (nonatomic, retain) NSMutableArray *myItemIDs;

@end

@implementation MyViewController
@sythesize myItemIDs;

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Normally we'd get this array from a server that sends us a list of the user's items. For simplicity we're just creating a randomly generated array of item ID's to share.
    self.myItemIDs = [[NSMutableArray alloc] initWithObjects:[[NSUUID UUID] UUIDString], [[NSUUID UUID] UUIDString], [[NSUUID UUID] UUIDString], [[NSUUID UUID] UUIDString], [[NSUUID UUID] UUIDString], nil];

    // Tell SimpleShare the item IDs we are sharing
    [SimpleShare sharedInstance].delegate = self; // lets this file receive delegate messages, such as the following:

    [SimpleShare sharedInstance].myItemIDs = self.myItemIDs; // send the array of itemIDs you are sharing to SimpleShare

}

#pragma mark - SimpleShare Delegate

- (void)simpleShareFoundFirstItems:(NSArray *)itemIDs
{
    // get rid of old found nearby items
    _nearbyItems = nil;

    _nearbyItems = [[NSMutableArray alloc] init];

    // add the first items to the array
    [_nearbyItems addObjectsFromArray:itemIDs];

    // pop up nearby items controller to show found items
    [self performSegueWithIdentifier:@"addNearbyItems" sender:self];
}

- (void)simpleShareFoundMoreItems:(NSArray *)itemIDs
{
    // add the new items to the array
    [_nearbyItems addObjectsFromArray:itemIDs];

    // update nearby items controller
    [_nearbyItemsController setNearbyItemIDs:_nearbyItems];
    [_nearbyItemsController.tableView reloadData];
}

- (void)simpleShareFoundNoItems:(SimpleShare *)simpleShare
{
    // update UI to show it is done looking for items
    [self.navigationItem setRightBarButtonItem:_findItemsButton];

}

- (void)simpleShareDidFailWithMessage:(NSString *)failMessage
{
    // update UI to show it is not looking for items
    [self.navigationItem setRightBarButtonItem:_findItemsButton];

    // update UI to indicate it is not sharing items
    _shareItemsButton.title = @"Share";
    _shareItemsButton.action = @selector(shareMyItems:);

}

@end

Flickr Demo

A second demo app uses the Flickr API to show how to use the shared item IDs to get useful information from one phone to another with bluetooth magic by connecting with a web API. SimpleShare sends the IDs of Flickr photos over Bluetooth LE between nearby users, and connects with the Flickr API to fill in image thumbnails and titles for the photos found from nearby users.

Future

Since the sharing is simply done over Bluetooth LE, with a comma-separated string of item IDs shared between phones, this should work well cross-platform. An Android version of this project would allow the phones to easily share items regardless of platform.

Comments
  • semaphore_wait_trap hang with using in XCode 6 / Swift project

    semaphore_wait_trap hang with using in XCode 6 / Swift project

    I successfully used the SimpleShare code in an XCode 5 project and I'm now bringing my code into a new XCode 6 / Swift project. I'm using the SimpleShare code as-is in Objective-C and importing through my bridging header.

    The app hangs with a semaphore_wait_trap during init on this line:

    _centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:centralQueue];

    Setting the queue to nil or to DISPATCH_QUEUE_CONCURRENT does not make any difference. It still hangs on init.

    opened by dethell 3
  • Mach-O Linker Errors

    Mach-O Linker Errors

    Hi Laura, Thanks for putting this together. When compiling I'm running into the issues below. If you know what they are or how to make them go away I'd be appreciative!

    Thanks!

    1. Undefined symbols for architecture i386: "OBJC_CLASS$_SimpleShare", referenced from: objc-class-ref in MyItemsViewController.o objc-class-ref in AppDelegate.o ld: symbol(s) not found for architecture i386
    2. clang: error: linker command failed with exit code 1 (use -v to see invocation)
    opened by BrettyWhite 1
  • some times when I want to stop sharing my items, this action crashes my app with this error.

    some times when I want to stop sharing my items, this action crashes my app with this error.

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'

    and the exactly sentence is [[SimpleShare sharedInstance] stopSharingMyItems:self];

    opened by ArthurMav 0
  • something similar in Swift?

    something similar in Swift?

    Hi all! Anyone know of something similar in Swift? Or how would I even go about starting to convert this to Swift? Any articles or blogs you'd recommend would be fantastic!

    opened by cdbattags 0
  • does this still work on the latest version of iOS?

    does this still work on the latest version of iOS?

    there have been quite a few bluetooth policy changes in the recent iOS releases. does this code still work as is on the latest version? or are additional updates needed? thx

    opened by morgunder 2
Owner
Laura Skelton
Laura Skelton
A clima based app with use of API

Clima Our Goal It’s time to take our app development skills to the next level. We’re going to introduce you to the wonderful world of Application Prog

null 0 Nov 28, 2021
Easy and powerful way to interact with VK API for iOS and macOS

Easy and powerful way to interact with VK API for iOS and macOS. Key features ?? It's not ios-vk-sdk ?? ?? One library for iOS and mac OS ?? ?? Fully

null 260 Dec 22, 2022
An easy-to-use Objective-C wrapper for the Uber API (no longer supported)

UberKit UberKit is a simple Objective-C wrapper for the new Uber API . Installation Cocoapods UberKit is available through Cocoapods. To install it, s

Sachin Kesiraju 95 Jun 30, 2022
SwiftCloudDrive - An easy to use Swift wrapper around iCloud Drive.

SwiftCloudDrive Author: Drew McCormack (@drewmccormack) An easy to use Swift wrapper around iCloud Drive. SwiftCloudDrive handles complexities like fi

Drew McCormack 11 Dec 21, 2022
Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)

DribbbleSDK DribbbleSDK is easy-to-use iOS wrapper for Dribbble SDK. We're working hard to complete the full coverage of available methods and make th

Agilie Team 74 Dec 2, 2020
Giphy API client for iOS in Objective-C

Giphy-iOS Giphy-iOS is a Giphy API client for iOS in Objective-C. Usage To run the example project, clone the repo, and run pod install from the Examp

alex choi 52 Jul 11, 2019
The unofficial Instagram iOS SDK

InstagramKit An extensive Objective C wrapper for the Instagram API, completely compatible with Swift. Here's a quick example to retrieve trending med

Shyam Bhat 955 Dec 12, 2022
The Easiest and Simplest iOS library for Twitter and Facebook. Just Drop in and Use!

EasySocial iOS Library for Twitter and Facebook This library allows your apps to use Twitter and Facebook with minimal understanding of the relevant S

pj 124 Nov 17, 2022
A Swift wrapper for Foursquare API. iOS and OSX.

Das Quadrat Das Quadrat is Foursquare API wrapper written in Swift. Features Supports iOS and OSX. Covers all API endpoints. Authorization process imp

Constantine Fry 171 Jun 18, 2022
A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

Matt Donnelly 2.4k Dec 30, 2022
An Elegant Spotify Web API Library Written in Swift for iOS and macOS

Written in Swift 4.2 Spartan is a lightweight, elegant, and easy to use Spotify Web API wrapper library for iOS and macOS written in Swift 3. Under th

Dalton Hinterscher 107 Nov 8, 2022
iOS/macOS Cross-platform Ark-Ecosystem Framework in Swift | Powered by Ѧrk.io |

a macOS & iOS Swift Framework for Ark.io. What is ARKKit? ARKKit is wrapper for interacting with the Ark Ecosystem. It is written purely in Swift 4.0,

Simon 19 Jun 28, 2022
The Waterwheel Swift SDK provides classes to natively connect iOS, macOS, tvOS, and watchOS applications to Drupal 7 and 8.

Waterwheel Swift SDK for Drupal Waterwheel makes using Drupal as a backend with iOS, macOS, tvOS, or watchOS enjoyable by combining the most used feat

Kyle Browning 414 Jul 26, 2022
Twitter Clone for iOS With Swift

Postwitter Date: December 1, 2021 Product Name: Postwitter Problem Statement: iO

Shohin Abdulkhamidov 3 Aug 16, 2022
This repository is for the new ARGear SDK library for the iOS platform

This repository is for the new ARGear SDK library for the iOS platform. The library is not official yet. The library will be updated frequently by applying user feedback. When the APIs are fixed, the official library will be released.

ARGear 2 Apr 5, 2022
Studio Ghibli Movie database in Swift. For iOS, iPadOS, and MacOS.

Ghibliii Studio Ghibli Movie database in Swift *Colours are shifted due to compression About This started as a way for me to do something in this quar

Kevin Laminto 19 Dec 9, 2022
Photo-Sharing-App - Photo Sharing App With Swift

Photo Sharing App You can register and log in to this application and share your

Yağız Savran 2 Jun 14, 2022
ProximitySensor - Property wrappers for using the Proximity Sensor from the SwiftUI app

ProximitySensor Property wrappers for using the Proximity Sensor from the SwiftU

null 2 Aug 20, 2022
BLE (Bluetooth LE) for U🎁 Bleu is the best in the Bluetooth library.

Bleu Bleu is a Bluetooth library. Bleu is the easiest way to operate CoreBluetooth. Bleu is possible to operate by replacing Bluetooth 's Peripheral a

1amageek 484 Dec 29, 2022
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