Simple motion detector for ⌚️ (watchOS) shake gesture.

Overview

WatchShaker

Simple motion detector for ⌚️ (watchOS) shake gesture.

Swift Version Platform


WatchShaker is a watchOS helper to get your ⌚️ shake movements

Requirements

  • watchOS 6.0+
  • Xcode 11.0+

Installation

Swift Package Manager

Once you have your Swift package set up, adding WatchShaker as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ezefranca/WatchShaker.git", .upToNextMajor(from: "1.0.2"))
]

Manually

  1. Download and drop WatchShaker folder in your project to your watch target.
  2. Congratulations!

Usage example

Closure Style

import WatchKit
import Foundation
import WatchShaker

class InterfaceController: WKInterfaceController {
    
    var shaker:WatchShaker = WatchShaker(shakeSensibility: .shakeSensibilityNormal, delay: 0.2)
    
    override func awake(withContext context: Any?) {
        super.awake(withContext: context)
    }
    
    override func willActivate() {
        super.willActivate()
        
        shaker.start()
        
        shaker.startWatchShakerUpdates = { shakeSensibility, error in
            
            guard error == nil else
            {
                print(error?.localizedDescription)
                return
            }
            print("I'm shook! ⌚️⌚️⌚️")
        }
    }
    
    override func didDeactivate() {
        super.didDeactivate()
        shaker.stop()
    }

}

Delegate Style

import WatchKit
import Foundation


class InterfaceController: WKInterfaceController {

    override func awake(withContext context: Any?) {
        super.awake(withContext: context)
        // Configure interface objects here.
    }

    var shaker:WatchShaker = WatchShaker(shakeSensibility: .shakeSensibilityNormal, delay: 0.2)

    override func willActivate() {

        super.willActivate()
        shaker.delegate = self
        shaker.start()
    }

    override func didDeactivate() {

        super.didDeactivate()
        shaker.stop()

    }

}

extension InterfaceController: WatchShakerDelegate
{
    func watchShaker(_ watchShaker: WatchShaker, didShakeWith sensibility: ShakeSensibility) {
        print("I'm shook! ⌚️⌚️⌚️")
    }

    func watchShaker(_ watchShaker: WatchShaker, didFailWith error: Error) {
        print(error.localizedDescription)
    }
}

Optional Directions

If you interested you can get the direction of the shake on the didShakeWith method.

func watchShaker(_ watchShaker: WatchShaker, didShakeWith sensibility: ShakeSensibility, 
                     direction: ShakeDirection) {
    print("I'm shook! ⌚️⌚️⌚️ \(direction)")
}

ShakeDirection is a simple enum who gives you up, down, left or right direction. The image bellow is the way used to determine what is each direction.


This gentleman bellow for example, is clearly doing a shake with ShakeDirection.shakeDirectionRight 😂


Contribute

We would love for you to contribute to WatchShaker, check the LICENSE file for more info.

Meta

Ezequiel França – @ezefranca and all awesome Contributors

Distributed under the MIT license. See LICENSE for more information.

You might also like...
NSData Detector with swift

NSDataDetector This playground demonstrates a weird difference in behaviour between Xcodes 12.5.1 and 13.1 regarding NSDataDetector. Try to run it usi

An NSFW image detector for Swift built as an extension on UIImage.

Swift_NSFW_Detector An NSFW image detector for Swift built as an extension on UIImage. If you've ever allowed users to share images you are probably w

Fashion Detection in the Wild (Deep Clothes Detector)
Fashion Detection in the Wild (Deep Clothes Detector)

Deep Clothes Detector is a clothes detection framework based on Fast R-CNN. Given a fashion image, this software finds and localizes potential upper-body clothes, lower-body clothes and full-body clothes in it, respectively.

SwiftUI Animation Library. Useful SwiftUI animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can directly implement in your next iOS application or project. The library also contains huge examples of spring animations such as Inertial Bounce, Shake, Twirl, Jelly, Jiggle, Rubber Band, Kitchen Sink and Wobble effects. Browse, find and download the animation that fits your needs. Snow globe framework is delightful / slightly cheese easter egg for christmas season. Turns your awesome app into a snow globe, when user shake the device.
Snow globe framework is delightful / slightly cheese easter egg for christmas season. Turns your awesome app into a snow globe, when user shake the device.

SnowGlobe.framework SnowGlobe.framework its easy to use, open source iOS framework written in swift. It allows you to ad delightful / cheesy Christmas

UIView category that adds shake animation
UIView category that adds shake animation

UIView category that adds a shake animation like the password field of the OSX login screen. Screenshot Setup with CocoaPods Add pod 'UIView+Shake' to

UITextField category that adds shake animation
UITextField category that adds shake animation

UITextField category that adds a shake animation like the password field of the OsX login screen. Screenshot Setup with CocoaPods pod 'UITextField+Sha

UITextField extension in Swift that adds shake animation

UITextField-Shake-Swift UITextField extension in Swift that adds shake animation Initially created by Andrea Mazzini (using Objective-C) on 08/02/14:

Advanced Natural Motion Animations, Simple Blocks Based Syntax
Advanced Natural Motion Animations, Simple Blocks Based Syntax

FlightAnimator Moved to Swift 3.1 Support: For Swift 3.1 - Use tag Version 0.9.9 See Installation Instructions for clarification Introduction FlightAn

CTPanoramaView is a library that displays spherical or cylindrical panoramas with touch or motion based controls.
CTPanoramaView is a library that displays spherical or cylindrical panoramas with touch or motion based controls.

CTPanoramaView is a high-performance library that uses SceneKit to display complete spherical or cylindrical panoramas with touch or motion based controls.

Location, motion, and activity recording framework for iOS

LocoKit A Machine Learning based location recording and activity detection framework for iOS. Location and Motion Recording Combined, simplified Core

📸 iOS Media Capture – features touch-to-record video, slow motion, and photography
📸 iOS Media Capture – features touch-to-record video, slow motion, and photography

PBJVision PBJVision is a camera library for iOS that enables easy integration of special capture features and camera interface customizations in your

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing

SCRecorder A Vine/Instagram like audio/video recorder and filter framework in Objective-C. In short, here is a short list of the cool things you can d

A free, multiplatform SDK for real-time facial motion capture using blendshapes, and rigid head pose in 3D space from any RGB camera, photo, or video.
A free, multiplatform SDK for real-time facial motion capture using blendshapes, and rigid head pose in 3D space from any RGB camera, photo, or video.

mocap4face by Facemoji mocap4face by Facemoji is a free, multiplatform SDK for real-time facial motion capture based on Facial Action Coding System or

A custom image view that implements device motion scrolling
A custom image view that implements device motion scrolling

YXTMotionView A custom image view that implements device motion scrolling Installation CocoaPods Add the dependency to your Podfile: platform :ios pod

MotionBlur allows you to add motion blur effect to iOS animations.
MotionBlur allows you to add motion blur effect to iOS animations.

MotionBlur MotionBlur allows you to add motion blur effect to your animations (currently only position's change). See the accompanying blog post to le

AirPodsMotionAPI - Test Swift's AirPods Motion API in this sample project

AirPods Motion API Overview Swift provides an AirPods motion API that works on s

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

PinpointKit is an open-source iOS library in Swift that lets your testers and users send feedback with annotated screenshots using a simple gesture.
PinpointKit is an open-source iOS library in Swift that lets your testers and users send feedback with annotated screenshots using a simple gesture.

PinpointKit is an open-source iOS library in Swift that lets your testers and users send feedback with annotated screenshots using a simple gesture. F

Comments
  • Shake gesture not recognized

    Shake gesture not recognized

    I implemented this and was working yesterday, now I am getting the following in the debugger: "[Gyro] Manually set gyro-interrupt-calibration to 800"

    opened by noahbino 1
  • Two copies of WatchShaker source code

    Two copies of WatchShaker source code

    Can we remove the copy in WatchShaker WatchKit Extension/WatchShaker.swift and have the project reference the copy in ./Pod/Classes/WatchShaker.swift?

    bug duplicate enhancement 
    opened by ghv 1
  • Alternate license?

    Alternate license?

    First of all, thanks so much for this. It looks absolutely lovely!

    However: while I'm interested in using it for a project, I'm concerned about its use of the GPL. Specifically, it's widely believed that the terms of the GPL are generally incompatible with the iOS App Store terms of service (there are some exceptions and caveats to that, but they don't really apply here).

    Is there any chance you'd be willing to relicense this library under a more permissive license, such as the MIT or BSD license? I fully understand if not, and if you don't feel comfortable licensing this under a non-copyleft license, but as it stands I don't think there is any way for anyone to use your library with their Apple Watch app and also release it on the App Store, even if their app is also GPL.

    (If this isn't something you're too familiar with, happy to explain more or answer questions, with the caveat that I am not a lawyer).

    opened by lazerwalker 1
Releases(1.04)
Owner
Ezequiel França
Software Development, Games, Mechatronics, Education, and Basil Pesto.
Ezequiel França
WatchCon is a tool which enables creating easy connectivity between iOS and WatchOS.

WatchCon WatchCon is a tool which enables creating easy connectivity between iOS and WatchOS Requirements iOS 9.0+ / watchOS 2.0+ CocoaPods CocoaPods

Abdullah Selek 33 Sep 22, 2022
:mag_right: A simple and beautiful barcode scanner.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

HyperRedink 1.6k Jan 3, 2023
Simple QRCode reader in Swift

QRCodeReader.swift is a simple code reader (initially only QRCode) for iOS in Swift. It is based on the AVFoundation framework from Apple in order to

Yannick Loriot 1.3k Jan 5, 2023
A simple Swift framework for building reliable Bluetooth LE apps.

Bluejay is a simple Swift framework for building reliable Bluetooth LE apps. Bluejay's primary goals are: Simplify talking to a single Bluetooth LE pe

Steamclock Software 1k Dec 13, 2022
Just simple template - example how to use haptics in iOS Development

Haptics Just simple template - example how to use haptics in iOS Development imp

Alexander Ryakhin 1 Jan 31, 2022
A simple shake-one-shake, Convenient for us to integrate the shake-one-shake.

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

null 3 Nov 21, 2021
Cheap price detector - Cheap Flight Ticket Price Detector

Cheap Flight Price Detector ✈️ Have you ever searched for flight tickets in a wa

Daniel Grimm 1 Mar 11, 2022
Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event.

Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event. Goals of this project One of th

Zigii Wong 410 Sep 9, 2022
Simple library to detect motion type (walking, running, automotive) and count users steps. This library will make motion detection much more easily.

SOMotionDetector Simple library to detect motion for iOS by arturdev . Based on location updates and acceleration. ###Requierments iOS > 6.0 Compatibl

Artur  Mkrtchyan 1.1k Nov 25, 2022
QR code detector. Simple usage, you can get recognition results via delegate or callback.

SPQRCode QR code detector. Simple usage, you can get recognition results via delegate or callback. Installation Swift Package Manager CocoaPods Manual

Sparrow Code 58 Jan 6, 2023