Configure the Application

How to use Ring iOS SDK

The CRApplication class

CRApplication class provides the interface to use a Ring device from your iOS app.
It has mainly three features.

How to implement

The simplest way to use the CRApplication class is like following:

1. Implementing CRApplicationDelegate protocol

Overview of CRApplicationDelegate Protocol
You must implement the 6 functions of CRApplicationDelegate protocol to receive information from a Ring device.
These protocols are defined in CRApplication.h.
To receive information from a Ring device, pass the instance which implements these protocols to CRApplication when you initialize it.

Functions

For more details, see þǫ0þǫ.

2. Create the instance of the CRApplication class

initWithDelegate:background

CRApplication needs an implementation of CRApplicationDelegate when it is initialized.
You must keep this instance to control the Ring device.
The background argument is explained in Running your app in the background in details.

3. Start Using CRApplication

start

Once you run the start function, the service of Ring iOS SDK will be started.

Implementation Example

These examples shows how to implement the procedure explained above.
Logging some messages when the connection between the Ring device and the iOS device is established.

Swift

ViewController.swift
import UIKit
class ViewController: UIViewController, CRApplicationDelegate {
  var ringApp: CRApplication!
  override func viewDidLoad() {
    super.viewDidLoad()
    ringApp = CRApplication(delegate:self, background: false)
    ringApp.start()
  }
  func didReceiveEvent(event: CRRingEvent) {
  }
  func didReceivePoint(point: CGPoint) {
  }
  func didReceiveQuaternion(quaternion: CRQuaternion) {
  }
  func didReceiveGesture(identifier: String!) {
  }
  func deviceDidInitialize() {
    print("deviceDidInitialize")
  }
  func deviceDidDisconnect() {
  }
}

Objective-C

ViewController.m
#import "ViewController.h"
#import <CoreRing/CoreRing.h>
@interface ViewController () <CRApplicationDelegate>
@property (nonatomic, strong) CRApplication *ringApp;
@end
@implementation ViewController
- (void)viewDidLoad {
  [super viewDidLoad];
  self.ringApp = [[CRApplication alloc] initWithDelegate:self background:NO];
  [self.ringApp start];
}
- (void)didReceiveEvent:(CRRingEvent)event {
}
- (void)didReceivePoint:(CGPoint)point {
}
- (void)didReceiveQuaternion:(CRQuaternion)quaternion {
}
- (void)didReceiveGesture:(NSString *)identifier {
}
- (void)deviceDidInitialize {
  NSLog(@"deviceDidInitialize");
}
- (void)deviceDidDisconnect {
}
@end


<Setup the Libraries     |     TOP     |     モードについて>