com.awareframework.ios.sensor.timezone 0.5.0

com.awareframework.ios.sensor.timezone 0.5.0

tetujinyuuki.nishiyama 维护。



  • Yuuki Nishiyama

AWARE: 时区

CI Status Version License Platform

时区传感器跟踪用户的当前时区。

要求

iOS 10 或更高版本

安装

com.awareframework.ios.sensor.timezone 通过 CocoaPods 提供。

  1. 要安装它,只需将以下行添加到您的 Podfile 中
pod 'com.awareframework.ios.sensor.timezone'
  1. 将 com.awareframework.ios.sensor.timezone 库导入到您的源代码中。
import com_awareframework_ios_sensor_timezone 

公共函数

TimezoneSensor

  • init(config:TimezoneSensor.Config?) : 使用可选配置初始化时区传感器。
  • start(): 以可选配置启动时区传感器。
  • stop(): 停止服务。

TimezoneSensor.Config

表示传感器配置的类。

Fields

  • sensorObserver: TimezoneObserver: 实时数据更新的回调。
  • enabled: Boolean 传感器是否启用。 (默认 = false)
  • debug: Boolean 启用/禁用向Logcat记录日志。 (默认 = false)
  • label: String 数据的标签。 (默认 = "")
  • deviceId: String 将与事件和传感器相关联的设备ID。 (默认 = "")
  • dbEncryptionKey 数据库的加密密钥。 (默认 = null)
  • dbType: Engine 用于保存数据的数据库引擎。 (默认 = Engine.DatabaseType.NONE)
  • dbPath: String 数据库的路径。 (默认 = "aware_timezone")
  • dbHost: String 同步数据库的主机。 (默认 = null)

Broadcasts

  • TimezoneSensor.ACTION_AWARE_TIMEZONE 当有新的时区信息时广播。额外包含TimezoneSensor.EXTRA_DATA作为新时区的数据。

Data Representations

时区数据

字段 类型 描述
timezoneId 字符串 时区ID字符串,例如,“America/Los_Angeles, GMT-08:00”
deviceId 字符串 AWARE设备的UUID
label 字符串 可自定义标签。用于数据校准或追踪
timestamp 长整型 自1970年以来的Unix时间(毫秒)
timezone 整型 设备的时区
os 字符串 设备的操作系统(例如:android)

示例用法

let timezoneSensor = TimezoneSensor.init(TimezoneSensor.Config().apply{ config in
    config.sensorObserver = Observer()
    config.debug = true
    config.dbType = .REALM
})
timezoneSensor?.start()
class Observer:TimezoneObserver{
    func onTimezoneChanged(data: TimezoneData) {
        // Your code here..
    }
}

作者

Yuuki Nishiyama, [email protected]

许可证

版权所有 (c) 2021 AWARE移动上下文仪器中间件/框架(《http://www.awareframework.com》)

许可协议:Apache License, Version 2.0(“许可证”);除非遵守许可证规定,否则不得使用此文件。您可以在以下位置获得许可证副本:

https://apache.ac.cn/licenses/LICENSE-2.0除非适用法律要求或书面同意,否则按照许可证分发软件是按“原样”基础进行的,不提供任何明示或暗示的保证或条件。有关许可证的具体语言管辖权限和限制,请参阅许可证。