Airship iOS Gimbal Adapter
Airship Gimbal Adapter 是一个可插入类,允许用户将 Gimbal 场地事件与 Airship 集成。
资源
安装
Airship Gimbal Adapter 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到您的 Podfile 中
pod "AirshipGimbalAdapter"
用法
导入
Swift
import AirshipGimbalAdapter
Obj-C
@import AirshipGimbalAdapter
恢复适配器
在您的应用程序代理中,在didFinishLaunchingWithOptions
期间调用restore
Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
// after Airship.takeOff
AirshipGimbalAdapter.shared.restore()
...
}
Obj-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// after UAirship.takeOff
[[AirshpGimbalAdapter shared] restore];
...
}
恢复将自动在应用程序启动时恢复适配器。
启动适配器
Swift
AirshipGimbalAdapter.shared.start("## PLACE YOUR API KEY HERE ##")
Obj-C
[[AirshpGimbalAdapter shared] start:@"## PLACE YOUR API KEY HERE ##"];
停止适配器
Swift
AirshipGimbalAdapter.shared.stop()
Obj-C
[[AirshpGimbalAdapter shared] stop];
启用蓝牙警告
在监控位置时如果蓝牙被禁用,Gimbal适配器可以通过一个警告视图提示用户启用蓝牙。此功能默认禁用,但可以通过将AirshipGimbalAdapter的bluetoothPoweredOffAlertEnabled
属性设置为true来启用。
Swift
AirshipGimbalAdapter.shared.bluetoothPoweredOffAlertEnabled = true
Obj-C
[AirshpGimbalAdapter shared].bluetoothPoweredOffAlertEnabled = YES;