IncentCleaner 1.12

IncentCleaner 1.12

Vladimir Vasilev维护。



  • Vladimir Vasilev

incent-cleaner-ios

用于停止激励流量的框架。

安装

需要根据您的 Xcode 版本安装适当的框架版本

  1. 获取 Xcode 的主要版本,例如:12
  2. CocoaPods
pod 'IncentCleaner' # to install last `1.12` version compatible with Xcode12

或者

pod 'IncentCleaner', '<LAST_RELEASE_VERSION>-xcode<MAJOR_VERSION_OF_XCODE>' # e.g. `1.12-xcode12`
  1. Info.plist 中需要添加 App Transport Security Settings

属性列表:App Transport Security Settings字典 > Allow Arbitrary Loads布尔值 = YES

源代码

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

或者

属性列表:App Transport Security Settings字典 > Exception Domains字典 > localhost字典 > NSExceptionAllowsInsecureHTTPLoads布尔值 = YES

源代码

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

使用方法

import IncentCleaner

如何检查激励流量?

IncentCleaner.checkForIncenting(completion: { incent in })

另外,您也可以使用 "do-activate-do" 方法。

"do-activate-do" 方法

存在三种类型的块

  1. 初始 - 例如,初始化某些分析服务的操作
  2. 预处理 - 例如,配置某些分析服务(设置用户属性)
  3. 公共 - 例如,跟踪某些事件

存在一个块队列,只有在激励检查完成时才开始执行。在此之前,所有传入的块都被放入队列并按以下优先级顺序排序:初始 > 预处理 >公共。当你需要按特定顺序跟踪事件但缺乏初始化或配置某些分析服务的信息时,这可能会很有帮助。

激活

重要:仅在主线程中使用

IncentCleaner.activate() // to start the check for incenting 

如果用户不是激励的,如何入队代码块以供执行?

重要:仅在主线程中使用

IncentCleaner.doIfNonIncent(type: .initial, // .initial|.pre|.common, .common by default
                            desc: "Some analytics service initialization", // optional, for debug
                            block: {
    // Some analytics service initialization
})

如何调试?

IncentCleaner.showDebug = true // false by default, to print all debugging info in the console
IncentCleaner.log = { text in } // to define your own log handler 

==================================================

您可以在附带的项目中查看使用示例。