开发者的客户数据平台
该存储库包含集成RudderStack iOS SDK与Braze所需的资源和资产。
有关如何在RudderStack中配置Braze作为目标及其支持的事件的映射的更多信息,请参阅Braze文档。
重要:此设备模式集成支持Braze v4.7.0及以上版本。 |
---|
- 在RudderStack仪表板中将 Braze添加为目标。
RudderBraze
通过 CocoaPods提供。要安装它,请将以下行添加到您的Podfile中,然后运行pod install
,如下所示
pod 'RudderBraze', '~> 1.1.0'
- 运行
pod install
命令。
import RudderBraze
@import RudderBraze;
在您的AppDelegate
文件中,将以下代码放在didFinishLaunchingWithOptions
方法下
RSConfig *config = [[RSConfig alloc] initWithWriteKey:WRITE_KEY];
[config dataPlaneURL:DATA_PLANE_URL];
[[RSClient sharedInstance] configureWith:config];
[[RSClient sharedInstance] addDestination:[[RudderBrazeDestination alloc] init]];
let config: RSConfig = RSConfig(writeKey: WRITE_KEY)
.dataPlaneURL(DATA_PLANE_URL)
RSClient.sharedInstance().configure(with: config)
RSClient.sharedInstance().addDestination(RudderBrazeDestination())
遵循RudderStack iOS SDK存储库中列出的步骤,开始向Braze发送事件。
要将您的推送通知事件发送到Braze,请遵循以下步骤
- 在您的
AppDelegate
文件中,将以下代码放在didFinishLaunchingWithOptions
方法下
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
UNAuthorizationOptions options = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
if (@available(iOS 12.0, *)) {
options = options | UNAuthorizationOptionProvisional;
}
[center requestAuthorizationWithOptions:options
completionHandler:^(BOOL granted, NSError * _Nullable error) {
[[RSClient sharedInstance] pushAuthorizationFromUserNotificationCenter:granted];
}];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionAlert | UNAuthorizationOptionSound)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
} else {
// Handle error or denial
}
}];
}
if #available(iOS 10, *) {
let center = UNUserNotificationCenter.current()
center.delegate = self
var options: UNAuthorizationOptions = [.alert, .sound, .badge]
if #available(iOS 12.0, *) {
options = UNAuthorizationOptions(rawValue: options.rawValue | UNAuthorizationOptions.provisional.rawValue)
}
center.requestAuthorization(options: options) { (granted, error) in
RSClient.sharedInstance().pushAuthorizationFromUserNotificationCenter(granted)
}
UIApplication.shared.registerForRemoteNotifications()
} else {
let types: UIUserNotificationType = [.alert, .badge, .sound]
let setting: UIUserNotificationSettings = UIUserNotificationSettings(types: types, categories: nil)
UIApplication.shared.registerUserNotificationSettings(setting)
UIApplication.shared.registerForRemoteNotifications()
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[RSClient sharedInstance] application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[[RSClient sharedInstance] application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
[[RSClient sharedInstance] userNotificationCenter:center didReceive:response withCompletionHandler:completionHandler];
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
RSClient.sharedInstance().application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
RSClient.sharedInstance().application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
RSClient.sharedInstance().userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
RudderStack是为开发者设计的客户数据平台。有了RudderStack,您可以从每个应用、网站和SaaS平台收集客户数据,然后将数据激活到您的仓库、业务和市场营销工具中。
开始构建一个以仓库为中心的更好的客户数据平台,将完整、统一的数据传达至您的客户数据堆栈的每个部分。今天签约RudderStack Cloud。 |
---|
有关配置或使用该集成的疑问,在我们的Slack社区中开始对话。