Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

sensorkitsensorkit 搜索

Agent Skill

sensorkit 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

14,811

周安装

611

GitHub Stars

533

下载量

4,839
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:sensorkit(sensorkit 搜索)
来源仓库:https://github.com/dpearson2699/swift-ios-skills
仓库路径:skills/sensorkit
安装命令:
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill sensorkit
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill sensorkit

简介

用于查找、检索和筛选相关信息,支持关键词和任务场景匹配。

  • 适合快速定位候选结果,提升信息获取效率。sensorkit 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 可结合来源仓库和原始 README 进一步验证功能细节。
  • 安装前建议确认权限范围和维护状态,避免意外联网或命令执行。
  • 注意工具输出不能直接作为最终结论,需人工复核关键信息。

SKILL.md

SensorKit

Collect research-grade sensor data from iOS and watchOS devices for approved research studies. SensorKit provides access to ambient light, motion, device usage, keyboard metrics, visits, phone/messaging usage, speech metrics, face metrics, wrist temperature, heart rate, ECG, and PPG data. Targets Swift 6.3 / iOS 26+.

SensorKit is restricted to Apple-approved research studies. Apps must submit a research proposal to Apple and receive the com.apple.developer.sensorkit.reader.allow entitlement before any sensor data is accessible. This is not a general-purpose sensor API -- use CoreMotion for standard accelerometer/gyroscope needs.

Contents

Overview and Requirements

SensorKit enables research apps to record and fetch sensor data across iPhone and Apple Watch. The framework requires:

  1. Apple-approved research study -- submit a proposal at researchandcare.org.
  2. SensorKit entitlement -- Apple grants com.apple.developer.sensorkit.reader.allow only for approved studies.
  3. Manual provisioning profile -- Xcode requires an explicit App ID with the SensorKit capability enabled.
  4. User authorization -- the system presents a Research Sensor & Usage Data sheet that users approve per-sensor.
  5. 24-hour data hold -- newly recorded data is inaccessible for 24 hours, giving users time to delete data they do not want to share.

An app can access up to 7 days of prior recorded data for an active sensor.

Entitlements

Add the SensorKit reader entitlement to a .entitlements file. List only the sensors your study uses:

<key>com.apple.developer.sensorkit.reader.allow</key>
<array>
    <string>ambient-light-sensor</string>
    <string>motion-accelerometer</string>
    <string>motion-rotation-rate</string>
    <string>device-usage</string>
    <string>keyboard-metrics</string>
    <string>messages-usage</string>
    <string>phone-usage</string>
    <string>visits</string>
    <string>pedometer</string>
    <string>on-wrist</string>
</array>

Xcode build settings for manual signing:

SettingValue
Code Signing EntitlementsYourApp.entitlements
Code Signing IdentityApple Developer
Code Signing StyleManual
Provisioning ProfileExplicit profile with SensorKit capability

Info.plist Configuration

Three keys are required:

<!-- Study purpose shown in the authorization sheet -->
<key>NSSensorKitUsageDescription</key>
<string>This study monitors activity patterns for sleep research.</string>

<!-- Link to your study's privacy policy -->
<key>NSSensorKitPrivacyPolicyURL</key>
<string>https://example.com/privacy-policy</string>

<!-- Per-sensor usage explanations -->
<key>NSSensorKitUsageDetail</key>
<dict>
    <key>SRSensorUsageMotion</key>
    <dict>
        <key>Description</key>
        <string>Measures physical activity levels during the study.</string>
        <key>Required</key>
        <true/>
    </dict>
    <key>SRSensorUsageAmbientLightSensor</key>
    <dict>
        <key>Description</key>
        <string>Records ambient light to assess sleep environment.</string>
    </dict>
</dict>

If Required is true and the user denies that sensor, the system warns them that the study needs it and offers a chance to reconsider.

Authorization

Request authorization for the sensors your study needs. The system shows the Research Sensor & Usage Data sheet on first request.

import SensorKit

let reader = SRSensorReader(sensor: .ambientLightSensor)

// Request authorization for multiple sensors at once
SRSensorReader.requestAuthorization(
    sensors: [.ambientLightSensor, .accelerometer, .keyboardMetrics]
) { error in
    if let error {
        print("Authorization request failed: \(error)")
    }
}

Check a reader's current status before recording:

switch reader.authorizationStatus {
case .authorized:
    reader.startRecording()
case .denied:
    // User declined -- direct to Settings > Privacy > Research Sensor & Usage Data
    break
case .notDetermined:
    // Request authorization first
    break
@unknown default:
    break
}

Monitor status changes through the delegate:

func sensorReader(_ reader: SRSensorReader, didChange authorizationStatus: SRAuthorizationStatus) {
    switch authorizationStatus {
    case .authorized:
        reader.startRecording()
    case .denied:
        reader.stopRecording()
    default:
        break
    }
}

Available Sensors

Device Sensors

SensorTypeSample Type
.deviceUsageReportDevice usageSRDeviceUsageReport
.keyboardMetricsKeyboard activitySRKeyboardMetrics
.onWristStateWatch wrist stateSRWristDetection

App Activity Sensors

SensorTypeSample Type
.messagesUsageReportMessages app usageSRMessagesUsageReport
.phoneUsageReportPhone call usageSRPhoneUsageReport

User Activity Sensors

SensorTypeSample Type
.accelerometerAcceleration dataCMAccelerometerData
.rotationRateRotation rateCMGyroData
.pedometerDataStep/distance dataCMPedometerData
.visitsVisited locationsSRVisit
.mediaEventsMedia interactionsSRMediaEvent
.faceMetricsFace expressionsSRFaceMetrics
.heartRateHeart rateHeart rate data
.odometerSpeed/slopeOdometer data
.siriSpeechMetricsSiri speechSRSpeechMetrics
.telephonySpeechMetricsPhone speechSRSpeechMetrics
.wristTemperatureWrist temp (sleep)SRWristTemperatureSession
.photoplethysmogramPPG streamSRPhotoplethysmogramSample
.electrocardiogramECG streamSRElectrocardiogramSample

Environment Sensors

SensorTypeSample Type
.ambientLightSensorAmbient lightSRAmbientLightSample
.ambientPressurePressure/tempPressure data

SRSensorReader

SRSensorReader is the central class for accessing sensor data. Each instance reads from a single sensor.

import SensorKit

// Create a reader for one sensor
let lightReader = SRSensorReader(sensor: .ambientLightSensor)
let keyboardReader = SRSensorReader(sensor: .keyboardMetrics)

// Assign delegate to receive callbacks
lightReader.delegate = self
keyboardReader.delegate = self

The reader communicates entirely through SRSensorReaderDelegate:

Delegate MethodPurpose
sensorReader(_:didChange:)Authorization status changed
sensorReaderWillStartRecording(_:)Recording is about to start
sensorReader(_:startRecordingFailedWithError:)Recording failed to start
sensorReaderDidStopRecording(_:)Recording stopped
sensorReader(_:didFetch:)Devices fetched
sensorReader(_:fetching:didFetchResult:)Sample received
sensorReader(_:didCompleteFetch:)Fetch completed
sensorReader(_:fetching:failedWithError:)Fetch failed

Recording and Fetching Data

Start and Stop Recording

// Begin recording -- sensor stays active as long as any app has a stake
reader.startRecording()

// Stop recording -- framework deactivates the sensor when
// no app or system process is using it
reader.stopRecording()

Fetch Data

Build an SRFetchRequest with a time range and target device, then pass it to the reader:

let request = SRFetchRequest()
request.device = SRDevice.current
request.from = SRAbsoluteTime(CFAbsoluteTimeGetCurrent() - 86400 * 2)  // 2 days ago
request.to = SRAbsoluteTime.current()

reader.fetch(request)

Receive results through the delegate:

func sensorReader(
    _ reader: SRSensorReader,
    fetching request: SRFetchRequest,
    didFetchResult result: SRFetchResult<AnyObject>
) -> Bool {
    let timestamp = result.timestamp

    switch reader.sensor {
    case .ambientLightSensor:
        if let sample = result.sample as? SRAmbientLightSample {
            let lux = sample.lux
            let chromaticity = sample.chromaticity
            let placement = sample.placement
            processSample(lux: lux, chromaticity: chromaticity, at: timestamp)
        }
    case .keyboardMetrics:
        if let sample = result.sample as? SRKeyboardMetrics {
            let words = sample.totalWords
            let speed = sample.typingSpeed
            processKeyboard(words: words, speed: speed, at: timestamp)
        }
    case .deviceUsageReport:
        if let sample = result.sample as? SRDeviceUsageReport {
            let wakes = sample.totalScreenWakes
            let unlocks = sample.totalUnlocks
            processUsage(wakes: wakes, unlocks: unlocks, at: timestamp)
        }
    default:
        break
    }

    return true  // Return true to continue receiving results
}

func sensorReader(_ reader: SRSensorReader, didCompleteFetch request: SRFetchRequest) {
    print("Fetch complete for \(reader.sensor)")
}

func sensorReader(
    _ reader: SRSensorReader,
    fetching request: SRFetchRequest,
    failedWithError error: any Error
) {
    print("Fetch failed: \(error)")
}

Data Holding Period

SensorKit imposes a 24-hour holding period on newly recorded data. Fetch requests whose time range overlaps this period return no results. Design data collection workflows around this delay.

SRDevice

SRDevice identifies the hardware source for sensor samples. Use it to distinguish data from iPhone versus Apple Watch.

// Get the current device
let currentDevice = SRDevice.current
print("Model: \(currentDevice.model)")
print("System: \(currentDevice.systemName) \(currentDevice.systemVersion)")

// Fetch all available devices for a sensor
reader.fetchDevices()

Handle fetched devices through the delegate:

func sensorReader(_ reader: SRSensorReader, didFetch devices: [SRDevice]) {
    for device in devices {
        let request = SRFetchRequest()
        request.device = device
        request.from = SRAbsoluteTime(CFAbsoluteTimeGetCurrent() - 86400)
        request.to = SRAbsoluteTime.current()
        reader.fetch(request)
    }
}

func sensorReader(_ reader: SRSensorReader, fetchDevicesDidFailWithError error: any Error) {
    print("Failed to fetch devices: \(error)")
}

SRDevice Properties

PropertyTypeDescription
modelStringUser-defined device name
nameStringFramework-defined device name
systemNameStringOS name (iOS, watchOS)
systemVersionStringOS version
productTypeStringHardware identifier
currentSRDeviceClass property for the running device

Common Mistakes

DON'T: Attempt to use SensorKit without the entitlement

// WRONG -- fails at runtime with SRError.invalidEntitlement
let reader = SRSensorReader(sensor: .ambientLightSensor)
reader.startRecording()

// CORRECT -- obtain entitlement from Apple first, configure manual
// provisioning profile, then use SensorKit

DON'T: Expect immediate data access

// WRONG -- fetching data recorded moments ago returns nothing
reader.startRecording()
// ... record for a few minutes ...
let request = SRFetchRequest()
request.from = SRAbsoluteTime(CFAbsoluteTimeGetCurrent() - 300)
request.to = SRAbsoluteTime.current()
reader.fetch(request)  // Empty results due to 24-hour hold

// CORRECT -- fetch data that is at least 24 hours old
request.from = SRAbsoluteTime(CFAbsoluteTimeGetCurrent() - 86400 * 3)
request.to = SRAbsoluteTime(CFAbsoluteTimeGetCurrent() - 86400)
reader.fetch(request)

DON'T: Forget to set the delegate before fetching

// WRONG -- no delegate means no callbacks, results are silently lost
let reader = SRSensorReader(sensor: .accelerometer)
reader.startRecording()
reader.fetch(request)

// CORRECT -- assign delegate first
reader.delegate = self
reader.startRecording()
reader.fetch(request)

DON'T: Skip per-sensor Info.plist usage detail

// WRONG -- missing NSSensorKitUsageDetail for the sensor
// Authorization sheet shows no explanation, user is less likely to approve

// CORRECT -- add usage detail for every sensor you request
// See Info.plist Configuration section above

DON'T: Ignore SRError codes

// WRONG -- generic error handling
func sensorReader(_ reader: SRSensorReader, fetching: SRFetchRequest, failedWithError error: any Error) {
    print("Error")
}

// CORRECT -- handle specific error codes
func sensorReader(_ reader: SRSensorReader, fetching: SRFetchRequest, failedWithError error: any Error) {
    if let srError = error as? SRError {
        switch srError.code {
        case .invalidEntitlement:
            // Entitlement missing or sensor not in entitlement array
            break
        case .noAuthorization:
            // User has not authorized this sensor
            break
        case .dataInaccessible:
            // Data in 24-hour holding period or otherwise unavailable
            break
        case .fetchRequestInvalid:
            // Invalid time range or device
            break
        case .promptDeclined:
            // User declined the authorization prompt
            break
        @unknown default:
            break
        }
    }
}

Review Checklist

  • Apple-approved research study in place before development
  • com.apple.developer.sensorkit.reader.allow entitlement lists only needed sensors
  • Manual provisioning profile with explicit App ID and SensorKit capability
  • NSSensorKitUsageDescription in Info.plist with clear study purpose
  • NSSensorKitPrivacyPolicyURL in Info.plist with valid privacy policy URL
  • NSSensorKitUsageDetail entries for every requested sensor
  • Required key set appropriately for essential vs. optional sensors
  • Authorization requested before recording, status checked before fetching
  • Delegate assigned before calling startRecording() or fetch(_:)
  • Fetch request time ranges account for 24-hour data holding period
  • SRError codes handled in all failure delegate methods
  • fetchDevices() used to discover available devices before fetching
  • stopRecording() called when data collection is complete
  • sensorReader(_:fetching:didFetchResult:) returns true to continue or false to stop

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.49%
按下载量换算1,717

Claude

31.81%
按下载量换算1,539

Cursor

18.32%
按下载量换算887

Gemini CLI

9.97%
按下载量换算482

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills