RudderBraze 1.1.0

RudderBraze 1.1.0

RudderStack维护。



 
依赖项
Rudder~> 2.2.4
Appboy-iOS-SDK~> 4.7.0
 

  • RudderStack

开发者的客户数据平台

网站 · 文档 · 社区Slack


RudderStack iOS SDK与Braze集成

该存储库包含集成RudderStack iOS SDKBraze所需的资源和资产。

有关如何在RudderStack中配置Braze作为目标及其支持的事件的映射的更多信息,请参阅Braze文档

重要:此设备模式集成支持Braze v4.7.0及以上版本。

步骤1:将SDK与Braze集成

  1. RudderStack仪表板中将 Braze添加为目标。
  2. RudderBraze通过 CocoaPods提供。要安装它,请将以下行添加到您的Podfile中,然后运行pod install,如下所示
pod 'RudderBraze', '~> 1.1.0'
  1. 运行pod install命令。

步骤2:导入SDK

Swift

import RudderBraze

Objective C

@import RudderBraze;

步骤3:初始化RudderStack客户端(RSClient

在您的AppDelegate文件中,将以下代码放在didFinishLaunchingWithOptions方法下

Objective C

RSConfig *config = [[RSConfig alloc] initWithWriteKey:WRITE_KEY];
[config dataPlaneURL:DATA_PLANE_URL];
[[RSClient sharedInstance] configureWith:config];
[[RSClient sharedInstance] addDestination:[[RudderBrazeDestination alloc] init]];

Swift

let config: RSConfig = RSConfig(writeKey: WRITE_KEY)
            .dataPlaneURL(DATA_PLANE_URL)
RSClient.sharedInstance().configure(with: config)
RSClient.sharedInstance().addDestination(RudderBrazeDestination())

步骤4:发送事件

遵循RudderStack iOS SDK存储库中列出的步骤,开始向Braze发送事件。

发送推送通知事件

要将您的推送通知事件发送到Braze,请遵循以下步骤

  1. 在您的AppDelegate文件中,将以下代码放在didFinishLaunchingWithOptions方法下

Objective C

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
            }
        }];
}

Swift

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()
}
  1. 提供.p8文件(推荐)或.p12证书推送通知文件或来自Apple的证书。有关详细信息,请参阅Braze文档。实现以下推送通知方法

Objective C

- (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];
}

Swift

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是为开发者设计的客户数据平台。有了RudderStack,您可以从每个应用、网站和SaaS平台收集客户数据,然后将数据激活到您的仓库、业务和市场营销工具中。

开始构建一个以仓库为中心的更好的客户数据平台,将完整、统一的数据传达至您的客户数据堆栈的每个部分。今天签约RudderStack Cloud

联系我们

有关配置或使用该集成的疑问,在我们的Slack社区中开始对话。