Events and the Event mode

What is Events?

A Ring device sends two types of events to the SDK, Tap and Long Tap.
You can handle them in the didReceiveEvent method in CRApplicationDelegate.

CRRingEvent

didReceiveEvent

The Event Mode

In the event mode, the SDK receives only tap and long tap.

Implementation Example

A example which receives only tap and long tap events.

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) {
    switch event {
    case .Tap:
      print("Tap")
    case .LongPress:
      print("LongPress")
      ringApp.setRingMode(.Event)
    }
  }

  func didReceivePoint(point: CGPoint) {
  }

  func didReceiveQuaternion(quaternion: CRQuaternion) {
  }

  func didReceiveGesture(identifier: String!) {
  }

  func deviceDidInitialize() {
    ringApp.setRingMode(.Event)
  }

  func deviceDidDisconnect() {
  }
}

Objective-C

#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 {
  switch (event) {
    case CRRingEventTap:
      NSLog(@"Tap");
      break;
    case CRRingEventLongPress:
      NSLog(@"LongPress");
      [self.ringApp setRingMode:CRRingModeEvent];
      break;
  }
}

- (void)didReceivePoint:(CGPoint)point {
}

- (void)didReceiveQuaternion:(CRQuaternion)quaternion {
}

- (void)didReceiveGesture:(NSString *)identifier {
}

- (void)deviceDidInitialize {
  [self.ringApp setRingMode:CRRingModeEvent];
}

- (void)deviceDidDisconnect {
}

@end

<About Modes     |     TOP     |     The Point mode>