Get in touch! Contact the Mosaic team by email (ishaan at mosaic.io) or phone: (484) 340-9892

MOSAIC


Download the SDK and Get an API Key

Create an account or log in to get access to the Mosaic SDK. It's completely free for users under 1,000 swipes per month.


Getting started

Download the SDK, then add libMosaic.a and MosaicClient.h to your project.

Set your Mosaic API key, and connect to the Mosaic server when your app starts:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    [[MosaicClient sharedClient] setAPIKey:@"YOUR_API_KEY_HERE"];
    [[MosaicClient sharedClient] connect];
    return YES;
}

Attach Mosaic to a view in your application to detect swipes on that view.

Important: you must only attach Mosaic to a full-screen view.
// in UIViewController viewDidLoad, or somewhere equivalent
[[MosaicClient sharedClient] attachToView:self.view];

Implement a Mosaic delegate and assign it. Usually, this will be your main view controller.

[[MosaicClient sharedClient] setDelegate:self];

State updates

When you swipe between two devices with Mosaic, you connect them into a "device group". When you swipe from any device in a group to another device, you add that device to the group.

State updates let you share information between devices in a group. Each group has a state associated with it, which is accessible to all devices in the group. To share information with other devices in the group, update the state:

[[MosaicClient sharedClient] updateState:[@"Hi guys!" dataUsingEncoding:NSUTF8StringEncoding]];

Every other device in the group can get notified of the state update by implementing the following delegate method:

-(void)mosaicStateUpdated:(NSData *)state {
    NSLog(@"Somebody updated the group state!");
}

Frame updates

Each device group (see "state updates") in Mosaic can function as a large screen. Whenever a device is added, removed, or repositioned in a group, "frame updates" are sent to all devices describing their position relative to the other devices.

-(void)mosaicFrameUpdated:(CGRect)frame{
    NSLog(@"Frame updated: %@",NSStringFromCGRect(frame));
}
Note: The frame parameter in a frame update gives the frame of the big "virtual screen", in the coordinate system of the device's view. This means the origin will usually be negative, and the size will usually be larger than the device's size.

Swipe events

Swipe gestures are automatically recognized and used to associate devices together into groups. To be notified of swipe events on the device (not the group), containing the direction of the swipe and its origin, implement the following delegate method:

-(void)mosaicSwipeOccurred:(MosaicSwipe)swipe{
    NSLog(@"A swipe occurred at %i x and %i y in %i direction", swipe.point.x, swipe.point.y, swipe.direction);
}