Airship iOS Gimbal 适配器
Airship Gimbal 适配器是一个可插入类,允许用户将 Gimbal 地点事件与 Airship 集成。
资源
安装
Airship Gimbal 适配器可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:
pod "GimbalAirshipAdapter"
使用方法
导入
Swift
import AirshipAdapter
Obj-C
@import AirshipAdapter
启用事件跟踪
默认情况下,事件跟踪是禁用的,因此必须显式启用,如下所述。
区域事件
要启用或禁用对 Airship RegionEvent
对象的跟踪,请使用 shouldTrackRegionEvents
属性
AirshipAdapter.shared.shouldTrackRegionEvents = true // enabled
AirshipAdapter.shared.shouldTrackRegionEvents = false // disabled
自定义事件
要启用或禁用对 Airship CustomEvent
对象的跟踪,请使用 shouldTrackCustomEntryEvents
和 shouldTrackCustomExitEvents
属性来跟踪地点进入和退出的事件,如下所示。有关 Airship 自定义事件的相关信息,请参阅此处文档:这里。
// To enable CustomEvent tracking for place exits
AirshipAdapter.shared.shouldTrackCustomExitEvents = true
// To disable CustomEvent tracking for place exits
AirshipAdapter.shared.shouldTrackCustomExitEvents = false
// To enable CustomEvent tracking for place entries
AirshipAdapter.shared.shouldTrackCustomEntryEvents = true
// To disable CustomEvent tracking for place entries
AirshipAdapter.shared.shouldTrackCustomEntryEvents = false
恢复适配器
在您的应用程序代理器中,在 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;
AirshipGimbalAdapter 迁移
AirshipGimbalAdapter
是此适配器的旧版本;如果您之前使用了 AirshipGimblAdapter
并想迁移,请参阅以下步骤
- 如果您使用 Cocoapods,请将 pod 的名称从
AirshipGimbalAdapter
更改为GimbalAirshipAdapter
- 在您的代码中,对
AirshipGimbalAdapter
类的引用应更改为AirshipAdapter
- 较旧的
AirshipGimbalAdapter
跟踪区域事件,但不跟踪自定义事件;如果您想保留此类功能,请禁用CustomEvent
跟踪并启用RegionEvent
跟踪,如上所述。