Velocidi iOS SDK in Objective-C
VelocidiSDK 是 Velocidi 用于与 iOS 应用集成的 Objective-C SDK。
安装
使用 CocoaPods 进行安装
要使用 CocoaPods 将 VelocidiSDK 集成到您的 Xcode 项目中,请在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.1'
project 'MyProject.xcodeproj'
target "MyProject" do
pod 'VelocidiSDK', '~> 0.3.2'
end
然后,运行
$ pod install
使用 Carthage 进行安装
要使用 Carthage 将 VelocidiSDK 集成到您的 Xcode 项目中,请在您的 Cartfile
中指定它
github "velocidi/velocidi-ios-objc-sdk" ~> 0.3.2
然后,运行 carthage
来构建框架,并将构建的 VelocidiSDK.framework 拖入您的 Xcode 项目。
需求
VelocidiSDK应与iOS 11.0及以上版本的任何版本兼容。
设置
使用必要的trackingBaseUrl
和matchBaseUrl
URL初始化VelocidiSDK。没有这些,VelocidiSDK将无法工作。我们建议在应用启动时执行此操作。
Swift
import VelocidiSDK
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let config = VSDKConfig(trackingBaseUrl: "https://tr.yourdomain.com", "https://match.yourdomain.com")!
VSDKVelocidi.start(config)
return true
}
Objective-C
@import VelocidiSDK;
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
VSDKConfig * config = [[VSDKConfig alloc] initWithTrackingBaseUrl:@"https://tr.yourdomain.com": @"https://match.yourdomain.com"];
[VSDKVelocidi start: config];
return YES;
}
发送跟踪事件
跟踪事件将在Velocidi的CDP中记录用户操作。
为了发送跟踪事件,创建一个VSDKTrackingEvent
实例。然后调用VSDKVelocidi
的单一实例并使用track
方法。
Swift
import VelocidiSDK
...
let trackingEvent = VSDKPageView()
trackingEvent.siteId = "RandomSiteId"
trackingEvent.clientId = "RandomClientId"
VSDKVelocidi.sharedInstance().track(trackingEvent)
Objective-C
@import VelocidiSDK;
...
VSDKTrackingEvent * trackingEvent = [[VSDKPageView alloc] init];
trackingEvent.clientId = @"RandomSiteId";
trackingEvent.siteId = @"RandomClientId";
[VSDKVelocidi.sharedInstance track: trackingEvent]
您还可以传递回调块,当请求成功或失败时,将调用这些回调块。
Swift
VSDKVelocidi.sharedInstance().track(trackingEvent, onSuccess:{ (response: URLResponse, responseObject: Any) in
print("Success! Response: \(response)")
}, onFailure:{(error: Error) in
print("Failed! Error: \(error.localizedDescription)")
})
Objective-C
[VSDKVelocidi.sharedInstance track: trackingEvent onSuccess: ^(NSURLResponse * response, id responseObject){
NSLog(@"Success! Response: %@", trackingNumber);
} onFailure: ^(NSError * error){
NSLog(@"Failed! Error: %@", [error localizedDescription]);
}];
存在一个大的跟踪事件类列表跟踪事件类以进行选择。如果没有任何一个符合所需操作,您也可以创建自己的自定义跟踪事件
匹配制作
匹配请求用于在Velocidi的CDP中链接多个标识符。这样,任何跨多个渠道(浏览器、移动应用等)通过任何标识符进行的操作都可以关联到同一用户。
在VelocidiSDK中,匹配请求将链接用户的广告标识符与其他提供的标识符(如内部ID)。一个典型的用例是,例如,在登录操作期间,将用户ID与Apple的广告标识符(用于所有跟踪事件请求的标识符)相关联。
Swift
@IBAction func sendMatchEvent(_ sender: Any) {
let userId1 = VSDKUserId(userId: "bar", "fooType")
let userId2 = VSDKUserId(userId: "baz", "fooType")
let idsArray = NSMutableArray(array: [userId1, userId2])
VSDKVelocidi.sharedInstance().match("1234-providerId-56789", userIds: idsArray, onSuccess:{ (response: URLResponse, responseObject: Any) in
print("Success! Response: \(response)")
}, onFailure:{(error: Error) in
print("Failed! Error: \(error.localizedDescription)")
})
}
Objective-C
- (IBAction)sendMatch:(id)sender {
VSDKUserId * userId1 = [[VSDKUserId alloc] initUserId:@"bar":@"fooType"];
VSDKUserId * userId2 = [[VSDKUserId alloc] initUserId:@"baz":@"fooType"];
NSMutableArray * idsArray = [[NSMutableArray alloc] initWithObjects: userId1, userId2, nil];
[VSDKVelocidi.sharedInstance match: @"1234-providerId-56789"
userIds: idsArray
onSuccess: ^(NSURLResponse * response, id responseObject){
NSLog(@"Success! Response: %@", trackingNumber);
} onFailure: ^(NSError * error){
NSLog(@"Failed! Error: %@", [error localizedDescription]);
}];
需要帮助?
您可以在以下网址找到关于 Velocidi 隐私 CDP 的更多信息:https://docs.velocidi.com/ 及 https://developers.velocidi.com。
请将错误或问题报告给 https://github.com/velocidi/velocidi-ios-objc-sdk/issues,或发送电子邮件至 [email protected]。