Braze SDK 통합
Braze SDK를 모바일 앱에 통합하는 방법을 알아보세요. 각 SDK는 자체 공개 GitHub 리포지토리에서 호스팅되며, 여기에는 Braze 기능을 테스트하거나 자체 애플리케이션과 함께 구현하는 데 사용할 수 있는 완전히 빌드 가능한 샘플 앱이 포함되어 있습니다. 자세히 알아보려면 참조, 리포지토리 및 샘플 앱을 참조하세요. SDK에 대한 자세한 내용은 시작하기를 참조하세요: 통합 개요.
Integrating the Android SDK
Step 1: Update your build.gradle
In your build.gradle
, add mavenCentral()
to your list of repositories.
1
2
3
repositories {
mavenCentral()
}
Next, add Braze to your dependencies.
If you don’t plan on using Braze UI components, add the following code to your build.gradle
. Replace SDK_VERSION
with the current version of your Android Braze SDK. For the full list of versions, see Changelogs.
1
2
3
4
dependencies {
implementation 'com.braze:android-sdk-base:SDK_VERSION' // (Required) Adds dependencies for the base Braze SDK.
implementation 'com.braze:android-sdk-location:SDK_VERSION' // (Optional) Adds dependencies for Braze location services.
}
If you plan on using Braze UI components later, add the following code to your build.gradle
. Replace SDK_VERSION
with the current version of your Android Braze SDK. For the full list of versions, see Changelogs.
1
2
3
4
dependencies {
implementation 'com.braze:android-sdk-ui:SDK_VERSION' // (Required) Adds dependencies for the Braze SDK and Braze UI components.
implementation 'com.braze:android-sdk-location:SDK_VERSION' // (Optional) Adds dependencies for Braze location services.
}
Step 2: Configure your braze.xml
As of December 2019, custom endpoints are no longer given out, if you have a pre-existing custom endpoint, you may continue to use it. For more details, refer to our list of available endpoints.
Create a braze.xml
file in your project’s res/values
folder. If you are on a specific data cluster or have a pre-existing custom endpoint, you need to specify the endpoint in your braze.xml
file as well.
The contents of that file should resemble the following code snippet. Make sure to substitute YOUR_APP_IDENTIFIER_API_KEY
with the identifier found in the Manage Settings page of the Braze dashboard. Log in at dashboard.braze.com to find your cluster address.
1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="com_braze_api_key">YOUR_APP_IDENTIFIER_API_KEY</string>
<string translatable="false" name="com_braze_custom_endpoint">YOUR_CUSTOM_ENDPOINT_OR_CLUSTER</string>
</resources>
Step 3: Add permissions to AndroidManifest.xml
Next, add the following permissions to your AndroidManifest.xml
:
1
2
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
With the release of Android M, Android switched from an install-time to a runtime permissions model. However, both of these permissions are normal permissions and are granted automatically if listed in the app manifest. For more information, visit Android’s permission documentation.
Step 4: Enable user session tracking
When you enable user session tracking, calls to openSession()
, closeSession()
,ensureSubscribedToInAppMessageEvents()
, and InAppMessageManager
registration can be handled automatically.
To register activity lifecycle callbacks, add the following code to the onCreate()
method of your Application
class.
1
2
3
4
5
6
7
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
registerActivityLifecycleCallbacks(new BrazeActivityLifecycleCallbackListener());
}
}
1
2
3
4
5
6
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
registerActivityLifecycleCallbacks(BrazeActivityLifecycleCallbackListener())
}
}
For the list of available parameters, see BrazeActivityLifecycleCallbackListener
.
Testing session tracking
You can also use the SDK Debugger to diagnose SDK issues.
If you experience issues while testing, enable verbose logging, then use logcat to detect missing openSession
and closeSession
calls in your activities.
- In Braze, go to Overview, select your app, then in the Display Data For dropdown choose Today.
- Open your app, then refresh the Braze dashboard. Verify that your metrics have increased by 1.
- Navigate through your app and verify that only one session has been logged to Braze.
- Send the app to the background for at least 10 seconds, then bring it to the foreground. Verify that a new session was logged.
Optional configurations
Runtime configuration
To set your Braze options in code rather than your braze.xml
file, use runtime configuration. If a value exists in both places, the runtime value will be used instead. After all required settings are supplied at runtime, you can delete your braze.xml
file.
In the following example, a builder object is created and then passed to Braze.configure()
. Note that only some of the available runtime options are shown—refer to our KDoc for the full list.
1
2
3
4
5
6
7
8
BrazeConfig brazeConfig = new BrazeConfig.Builder()
.setApiKey("api-key-here")
.setCustomEndpoint("YOUR_CUSTOM_ENDPOINT_OR_CLUSTER")
.setSessionTimeout(60)
.setHandlePushDeepLinksAutomatically(true)
.setGreatNetworkDataFlushInterval(10)
.build();
Braze.configure(this, brazeConfig);
1
2
3
4
5
6
7
8
val brazeConfig = BrazeConfig.Builder()
.setApiKey("api-key-here")
.setCustomEndpoint("YOUR_CUSTOM_ENDPOINT_OR_CLUSTER")
.setSessionTimeout(60)
.setHandlePushDeepLinksAutomatically(true)
.setGreatNetworkDataFlushInterval(10)
.build()
Braze.configure(this, brazeConfig)
Looking for another example? Check out our Hello Braze sample app.
Google Advertising ID
The Google Advertising ID (GAID) is an optional user-specific, anonymous, unique, and resettable ID for advertising, provided by Google Play services. GAID gives users the power to reset their identifier, opt-out of interest-based ads within Google Play apps, and provides developers with a simple, standard system to continue to monetize their apps.
The Google Advertising ID is not automatically collected by the Braze SDK and must be set manually via the Braze.setGoogleAdvertisingId()
method.
1
2
3
4
5
6
7
8
9
10
11
new Thread(new Runnable() {
@Override
public void run() {
try {
AdvertisingIdClient.Info idInfo = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());
Braze.getInstance(getApplicationContext()).setGoogleAdvertisingId(idInfo.getId(), idInfo.isLimitAdTrackingEnabled());
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
suspend fun fetchAndSetAdvertisingId(
context: Context,
scope: CoroutineScope = GlobalScope
) {
scope.launch(Dispatchers.IO) {
try {
val idInfo = AdvertisingIdClient.getAdvertisingIdInfo(context)
Braze.getInstance(context).setGoogleAdvertisingId(
idInfo.id,
idInfo.isLimitAdTrackingEnabled
)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Google requires the Advertising ID to be collected on a non-UI thread.
Location tracking
To enable Braze location collection, set com_braze_enable_location_collection
to true
in your braze.xml
file:
1
<bool name="com_braze_enable_location_collection">true</bool>
Starting with Braze Android SDK version 3.6.0, Braze location collection is disabled by default.
Logging
By default, the Braze Android SDK log level is set to INFO
. You can suppress these logs or set a different log level, such as VERBOSE
, DEBUG
, or WARN
.
Enabling logs
To help troubleshoot issues in your app, or reduce turnaround times with Braze Support, you’ll want to enable verbose logs for the SDK. When you send verbose logs to Braze Support, ensure they begin as soon as you launch your application and end far after your issue occurs.
Keep in mind, verbose logs are only intended for your development environment, so you’ll want to disable them before releasing your app.
Enable verbose logs before any other calls in Application.onCreate()
to ensure your logs are as complete as possible.
To enable logs directly in your app, add the following to your application’s onCreate()
method before any other methods.
1
BrazeLogger.setLogLevel(Log.MIN_LOG_LEVEL);
1
BrazeLogger.logLevel = Log.MIN_LOG_LEVEL
Replace MIN_LOG_LEVEL
with the Constant of the log level you’d like to set as your minimum log level. Any logs at a level >=
to your set MIN_LOG_LEVEL
will be forwarded to Android’s default Log
method. Any logs <
your set MIN_LOG_LEVEL
will be discarded.
Constant | Value | Description |
---|---|---|
VERBOSE |
2 | Logs the most detailed messages for debugging and development. |
DEBUG |
3 | Logs descriptive messages for debugging and development. |
INFO |
4 | Logs informational messages for general highlights. |
WARN |
5 | Logs warning messages for identifying potentially harmful situations. |
ERROR |
6 | Logs error messages for indicating application failure or serious issues. |
ASSERT |
7 | Logs assertion messages when conditions are false during development. |
For example, the following code will forward log levels 2
, 3
, 4
, 5
, 6
, and 7
to the Log
method.
1
BrazeLogger.setLogLevel(Log.VERBOSE);
1
BrazeLogger.logLevel = Log.VERBOSE
To enable logs in the braze.xml
, add the following to your file:
1
<integer name="com_braze_logger_initial_log_level">MIN_LOG_LEVEL</integer>
Replace MIN_LOG_LEVEL
with the Value of the log level you’d like to set as your minimum log level. Any logs at a level >=
to your set MIN_LOG_LEVEL
will be forwarded to Android’s default Log
method. Any logs <
your set MIN_LOG_LEVEL
will be discarded.
Constant | Value | Description |
---|---|---|
VERBOSE |
2 | Logs the most detailed messages for debugging and development. |
DEBUG |
3 | Logs descriptive messages for debugging and development. |
INFO |
4 | Logs informational messages for general highlights. |
WARN |
5 | Logs warning messages for identifying potentially harmful situations. |
ERROR |
6 | Logs error messages for indicating application failure or serious issues. |
ASSERT |
7 | Logs assertion messages when conditions are false during development. |
For example, the following code will forward log levels 2
, 3
, 4
, 5
, 6
, and 7
to the Log
method.
1
<integer name="com_braze_logger_initial_log_level">2</integer>
Verifying verbose logs
To verify that your logs are set to VERBOSE
, check if V/Braze
occurs somewhere in your logs. If it does, then verbose logs have been successfully enabled. For example:
1
2077-11-19 16:22:49.591 ? V/Braze v9.0.01 .bo.app.d3: Request started
Suppressing logs
To suppress all logs for the Braze Android SDK, set the log level to BrazeLogger.SUPPRESS
in your application’s onCreate()
method before any other methods.
1
BrazeLogger.setLogLevel(BrazeLogger.SUPPRESS);
1
BrazeLogger.setLogLevel(BrazeLogger.SUPPRESS)
Multiple API keys
The most common use case for multiple API keys is separating API keys for debug and release build variants.
To easily switch between multiple API keys in your builds, we recommend creating a separate braze.xml
file for each relevant build variant. A build variant is a combination of build type and product flavor. By default, new Android projects are configured with debug
and release
build types and no product flavors.
For each relevant build variant, create a new braze.xml
in the src/<build variant name>/res/values/
directory. When the build variant is compiled, it will use the new API key.
1
2
3
4
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="com_braze_api_key">REPLACE_WITH_YOUR_BUILD_VARIANT_API_KEY</string>
</resources>
To learn how to set up the API key in your code, see Runtime configuration.
Exclusive in-app message TalkBack
In adherence to the Android accessibility guidelines, the Braze Android SDK offers Android Talkback by default. To ensure that only the contents of in-app messages are read out loud—without including other screen elements like the app title bar or navigation—you can enable exclusive mode for TalkBack.
To enable exclusive mode for in-app messages:
1
<bool name="com_braze_device_in_app_message_accessibility_exclusive_mode_enabled">true</bool>
1
2
3
val brazeConfigBuilder = BrazeConfig.Builder()
brazeConfigBuilder.setIsInAppMessageAccessibilityExclusiveModeEnabled(true)
Braze.configure(this, brazeConfigBuilder.build())
1
2
3
BrazeConfig.Builder brazeConfigBuilder = new BrazeConfig.Builder()
brazeConfigBuilder.setIsInAppMessageAccessibilityExclusiveModeEnabled(true);
Braze.configure(this, brazeConfigBuilder.build());
R8 and ProGuard
Code shrinking configuration is automatically included with your Braze integration.
Client apps that obfuscate Braze code must store release mapping files for Braze to interpret stack traces. If you want to continue to keep all Braze code, add the following to your ProGuard file:
1
2
-keep class bo.app.** { *; }
-keep class com.braze.** { *; }
Integrating the Swift SDK
You can integrate and customize the Braze Swift SDK using the Swift Package Manager (SPM), CocoaPods, or manual integration methods. For more information about the various SDK symbols, see Braze Swift reference documentation.
Prerequisites
Before you start, verify your environment is supported by the latest Braze Swift SDK version.
Step 1: Install the Braze Swift SDK
We recommend using the Swift Package Manager (SwiftPM) or CocoaPods to install the Braze Swift SDK. Alternatively, you can install the SDK manually.
Step 1.1: Import SDK version
Open your project and navigate to your project’s settings. Select the Swift Packages tab and click on the add button below the packages list.
Starting in version 7.4.0, the Braze Swift SDK has additional distribution channels as static XCFrameworks and dynamic XCFrameworks. If you’d like to use either of these formats instead, follow the installation instructions from its respective repository.
Enter the URL of our iOS Swift SDK repository https://github.com/braze-inc/braze-swift-sdk
in the text field. Under the Dependency Rule section, select the SDK version. Finally, click Add Package.
Step 1.2: Select your packages
The Braze Swift SDK separates features into standalone libraries to provide developers with more control over which features to import into their projects.
Package | Details |
---|---|
BrazeKit |
Main SDK library providing support for analytics and push notifications. |
BrazeLocation |
Location library providing support for location analytics and geofence monitoring. |
BrazeUI |
Braze-provided user interface library for in-app messages, Content Cards, and Banners. Import this library if you intend to use the default UI components. |
About Extension libraries
BrazeNotificationService and BrazePushStory are extension modules that provide additional functionality and should not be added directly to your main application target. Instead follow the linked guides to integrate them separately into their respective target extensions.
Package | Details |
---|---|
BrazeNotificationService |
Notification service extension library providing support for rich push notifications. |
BrazePushStory |
Notification content extension library providing support for Push Stories. |
Select the package that best suits your needs and click Add Package. Make sure you select BrazeKit
at a minimum.
Step 1.1: Install CocoaPods
For a full walkthrough, see CocoaPods’ Getting Started Guide. Otherwise, you can run the following command to get started quickly:
1
$ sudo gem install cocoapods
If you get stuck, checkout CocoaPods’ Troubleshooting Guide.
Step 1.2: Constructing the Podfile
Next, create a file in your Xcode project directory named Podfile
.
Starting in version 7.4.0, the Braze Swift SDK has additional distribution channels as static XCFrameworks and dynamic XCFrameworks. If you’d like to use either of these formats instead, follow the installation instructions from its respective repository.
Add the following line to your Podfile:
1
2
3
target 'YourAppTarget' do
pod 'BrazeKit'
end
BrazeKit
contains the main SDK library, providing support for analytics and push notifications.
We suggest you version Braze so pod updates automatically grab anything smaller than a minor version update. This looks like pod 'BrazeKit' ~> Major.Minor.Build
. If you want to automatically integrate the latest Braze SDK version, even with major changes, you can use pod 'BrazeKit'
in your Podfile.
About additional libraries
The Braze Swift SDK separates features into standalone libraries to provide developers with more control over which features to import into their projects. In addition to BrazeKit
, you may add the following libraries to your Podfile:
Library | Details |
---|---|
pod 'BrazeLocation' |
Location library providing support for location analytics and geofence monitoring. |
pod 'BrazeUI' |
Braze-provided user interface library for in-app messages, Content Cards, and Banners. Import this library if you intend to use the default UI components. |
Extension libraries
BrazeNotificationService and BrazePushStory are extension modules that provide additional functionality and should not be added directly to your main application target. Instead, you will need to create separate extension targets for each of these modules and import the Braze modules into their corresponding targets.
Library | Details |
---|---|
pod 'BrazeNotificationService' |
Notification service extension library providing support for rich push notifications. |
pod 'BrazePushStory' |
Notification content extension library providing support for Push Stories. |
Step 1.3: Install the SDK
To install the Braze SDK CocoaPod, navigate to the directory of your Xcode app project within your terminal and run the following command:
1
pod install
At this point, you should be able to open the new Xcode project workspace created by CocoaPods. Make sure to use this Xcode workspace instead of your Xcode project.
Updating the SDK using CocoaPods
To update a CocoaPod, simply run the following command within your project directory:
1
pod update
Step 1.1: Download the Braze SDK
Go to the Braze SDK release page on GitHub, then download braze-swift-sdk-prebuilt.zip
.
Step 1.2: Choose your frameworks
The Braze Swift SDK contains a variety of standalone XCFrameworks, which gives you the freedom to integrate the features you want—without needing to integrate them all. Reference the following table to choose your XCFrameworks:
Package | Required? | Description |
---|---|---|
BrazeKit |
Yes | Main SDK library that provides support for analytics and push notifications. |
BrazeLocation |
No | Location library that provides support for location analytics and geofence monitoring. |
BrazeUI |
No | Braze-provided user interface library for in-app messages, Content Cards, and Banners. Import this library if you intend to use the default UI components. |
BrazeNotificationService |
No | Notification service extension library that provides support for rich push notifications. Do not add this library directly to your main application target, instead add the BrazeNotificationService library separately. |
BrazePushStory |
No | Notification content extension library that provides support for Push Stories. Do not add this library directly to your main application target, instead add the BrazePushStory library separately. |
BrazeKitCompat |
No | Compatibility library containing all the Appboy and ABK* classes and methods that were available in the Appboy-iOS-SDK version 4.X.X. For usage details, refer to the minimal migration scenario in the migration guide. |
BrazeUICompat |
No | Compatibility library containing all the ABK* classes and methods that were available in the AppboyUI library from Appboy-iOS-SDK version 4.X.X. For usage details, refer to the minimal migration scenario in the migration guide. |
SDWebImage |
No | Dependency used only by BrazeUICompat in the minimal migration scenario. |
Step 1.3: Prepare your files
Decide whether you want to use Static or Dynamic XCFrameworks, then prepare your files:
- Create a temporary directory for your XCFrameworks.
- In
braze-swift-sdk-prebuilt
, open thedynamic
directory and moveBrazeKit.xcframework
into your directory. Your directory should be similar to the following:1 2
temp_dir └── BrazeKit.xcframework
- Move each of your chosen XCFrameworks into your temporary directory. Your directory should be similar to the following:
1 2 3 4 5
temp_dir ├── BrazeKit.xcframework ├── BrazeKitCompat.xcframework ├── BrazeLocation.xcframework └── SDWebImage.xcframework
Step 1.4: Integrate your frameworks
Next, integrate the Dynamic or Static XCFrameworks you prepared previously:
In your Xcode project, select your build target, then General. Under Frameworks, Libraries, and Embedded Content, drag and drop the files you prepared previously.
Starting with the Swift SDK 12.0.0, you should always select Embed & Sign for the Braze XCFrameworks for both the static and dynamic variants. This ensures that the frameworks resources are properly embedded in your app bundle.
To enable GIF support, add SDWebImage.xcframework
, located in either braze-swift-sdk-prebuilt/static
or braze-swift-sdk-prebuilt/dynamic
.
Common errors for Objective-C projects
If your Xcode project only contains Objective-C files, you may get “missing symbol” errors when you try to build your project. To fix these errors, open your project and add an empty Swift file to your file tree. This will force your build toolchain to embed Swift Runtime and link to the appropriate frameworks during build time.
1
FILE_NAME.swift
Replace FILE_NAME
with any non-spaced string. Your file should look similar to the following:
1
empty_swift_file.swift
Step 2: Set up delayed initialization (optional)
You can choose to delay when the Braze Swift SDK is initialized, which is useful if your app needs to load config or wait for user consent before starting the SDK. Delayed initialization ensures Braze push notifications are queued until the SDK is ready.
To enable this, call Braze.prepareForDelayedInitialization()
as early as possible—ideally inside or before your application(_:didFinishLaunchingWithOptions:)
.
This only applies to push notifications from Braze. Other push notifications are handled normally by system delegates.
1
2
3
4
5
6
7
8
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Prepare the SDK for delayed initialization
Braze.prepareForDelayedInitialization()
// ... Additional non-Braze setup code
return true
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@main
struct MyApp: App {
@UIApplicationDelegateAdaptor var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Prepare the SDK for delayed initialization
Braze.prepareForDelayedInitialization()
// ... Additional non-Braze setup code
return true
}
}
1
2
3
4
5
6
7
8
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Prepare the SDK for delayed initialization
[Braze prepareForDelayedInitialization];
// ... Additional non-Braze setup code
return YES;
}
Braze.prepareForDelayedInitialization(pushAutomation:)
accepts an optional pushAutomation
parameter. If set to nil
, all push automation features are enabled, except requesting push authorization at launch.
Step 3: Update your app delegate
The following assumes you’ve already added an AppDelegate
to your project (which are not generated by default). If you don’t plan on using one, be sure to initialize the Braze SDK as early as possible, like during the app’s launch.
Add the following line of code to your AppDelegate.swift
file to import the features included in the Braze Swift SDK:
1
import BrazeKit
Next, add a static property to your AppDelegate
class to keep a strong reference to the Braze instance throughout your application’s lifetime:
1
2
3
class AppDelegate: UIResponder, UIApplicationDelegate {
static var braze: Braze? = nil
}
Finally, in AppDelegate.swift
, add the following snippet to your application:didFinishLaunchingWithOptions:
method:
1
2
3
4
5
6
let configuration = Braze.Configuration(
apiKey: "YOUR-APP-IDENTIFIER-API-KEY",
endpoint: "YOUR-BRAZE-ENDPOINT"
)
let braze = Braze(configuration: configuration)
AppDelegate.braze = braze
Update YOUR-APP-IDENTIFIER-API-KEY
and YOUR-BRAZE-ENDPOINT
with the correct value from your App Settings page. Check out our API identifier types for more information on where to find your app identifier API key.
Add the following line of code to your AppDelegate.m
file:
1
@import BrazeKit;
Next, add a static variable to your AppDelegate.m
file to keep a reference to the Braze instance throughout your application’s lifetime:
1
2
3
4
5
6
7
8
9
10
11
static Braze *_braze;
@implementation AppDelegate
+ (Braze *)braze {
return _braze;
}
+ (void)setBraze:(Braze *)braze {
_braze = braze;
}
@end
Finally, within your AppDelegate.m
file, add the following snippet within your application:didFinishLaunchingWithOptions:
method:
1
2
3
4
BRZConfiguration *configuration = [[BRZConfiguration alloc] initWithApiKey:"YOUR-APP-IDENTIFIER-API-KEY"
endpoint:"YOUR-BRAZE-ENDPOINT"];
Braze *braze = [[Braze alloc] initWithConfiguration:configuration];
AppDelegate.braze = braze;
Update YOUR-APP-IDENTIFIER-API-KEY
and YOUR-BRAZE-ENDPOINT
with the correct value from your Manage Settings page. Check out our API documentation for more information on where to find your app identifier API key.
Optional configurations
Logging
Log levels
The default log level for the Braze Swift SDK is .error
—it’s also the minimum supported level when logs are enabled. These are the full list of log levels:
Swift | Objective-C | Description |
---|---|---|
.debug |
BRZLoggerLevelDebug |
(Default) Log debugging information + .info + .error . |
.info |
BRZLoggerLevelInfo |
Log general SDK information (user changes, etc.) + .error . |
.error |
BRZLoggerLevelError |
Log errors. |
.disabled |
BRZLoggerLevelDisabled |
No logging occurs. |
Setting the log level
You can assign the log level at runtime in your Braze.Configuration
object. For complete usage details, see Braze.Configuration.Logger
.
1
2
3
4
5
6
7
let configuration = Braze.Configuration(
apiKey: "<BRAZE_API_KEY>",
endpoint: "<BRAZE_ENDPOINT>"
)
// Enable logging of general SDK information (such as user changes, etc.)
configuration.logger.level = .info
let braze = Braze(configuration: configuration)
1
2
3
4
5
BRZConfiguration *configuration = [[BRZConfiguration alloc] initWithApiKey:self.APIKey
endpoint:self.apiEndpoint];
// Enable logging of general SDK information (such as user changes, etc.)
[configuration.logger setLevel:BRZLoggerLevelInfo];
Braze *braze = [[Braze alloc] initWithConfiguration:configuration];
웹브레이즈 SDK 정보
웹브레이즈 SDK를 사용하면 분석을 수집하고 풍부한 인앱 메시지, 푸시 및 콘텐츠 카드 메시지를 웹 사용자에게 표시할 수 있습니다. 자세한 내용은 Braze 자바스크립트 참조 참조하세요.
이 가이드는 Braze Web SDK 4.0.0+의 코드 샘플을 사용합니다. 최신 웹 SDK 버전으로 업그레이드하려면 SDK 업그레이드 가이드를 참조하세요.
웹 SDK 통합
표준 통합 방법이 적합한지 잘 모르시겠어요? 계속하기 전에 다른 연동 방법을 확인하세요.
1단계: Braze 라이브러리 설치
다음 방법 중 하나를 사용하여 Braze 라이브러리를 설치할 수 있습니다. 웹사이트에서 Content-Security-Policy
를 사용하는 경우 라이브러리를 설치하기 전에 콘텐츠 보안 정책 헤더 가이드를 참조하세요.
대부분의 광고 차단기는 Braze 웹 SDK를 차단하지 않지만, 일부 제한적인 광고 차단기는 문제를 일으키는 것으로 알려져 있습니다.
사이트에서 NPM 또는 Yarn 패키지 관리자를 사용하는 경우 Braze NPM 패키지를 종속성으로 추가할 수 있습니다.
이제 v3.0.0부터 Typescript 정의가 포함됩니다. 2.x에서 3.x로 업그레이드할 때 참고할 사항은 체인지로그를 참조하세요.
1
2
3
npm install --save @braze/web-sdk
# or, using yarn:
# yarn add @braze/web-sdk
설치가 완료되면 일반적인 방법으로 라이브러리의 import
또는 require
작업을 수행할 수 있습니다.
1
2
3
import * as braze from "@braze/web-sdk";
// or, using `require`
const braze = require("@braze/web-sdk");
Braze 웹 SDK는 Google Tag Manager 템플릿 라이브러리에서 설치할 수 있습니다. 두 가지 태그가 지원됩니다:
- 초기화 태그: 웹사이트에 웹 SDK를 로드하고 선택적으로 외부 사용자 ID를 설정합니다.
- 작업 태그: 커스텀 이벤트, 구매, 사용자 ID 변경 또는 SDK 추적 토글을 트리거하는 데 사용됩니다.
자세한 내용은 Google Tag Manager 통합 가이드를 참조하세요.
라이브러리를 비동기적으로 로드하는 CDN 호스팅 스크립트를 참조하여 Braze 웹 SDK를 HTML에 직접 추가합니다.
2단계: SDK 초기화(선택 사항)
Tag Manager에서 Braze 초기화 옵션을 구성한 경우 이 단계를 건너뛸 수 있습니다.
그렇지 않은 경우, Braze 웹 SDK가 웹사이트에 추가된 후 Braze 대시보드 내 설정 > 앱 설정에 있는 API 키와 SDK 엔드포인트 URL로 라이브러리를 초기화합니다. braze.initialize()
에 대한 전체 옵션 목록과 다른 자바스크립트 메서드에 대한 자세한 내용은 Braze 자바스크립트 문서를 참조하세요.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// initialize the SDK
braze.initialize('YOUR-API-KEY-HERE', {
baseUrl: "YOUR-SDK-ENDPOINT-HERE"
});
// optionally show all in-app messages without custom handling
braze.automaticallyShowInAppMessages();
// if you use Content Cards
braze.subscribeToContentCardsUpdates(function(cards){
// cards have been updated
});
// optionally set the current user's external ID before starting a new session
// you can also call `changeUser` later in the session after the user logs in
if (isLoggedIn){
braze.changeUser(userIdentifier);
}
// `openSession` should be called last - after `changeUser` and `automaticallyShowInAppMessages`
braze.openSession();
모바일 또는 웹 디바이스의 익명 사용자도 MAU에 포함될 수 있습니다. 따라서 조건부로 SDK를 로드하거나 초기화하여 이러한 사용자를 MAU 수에서 제외할 수 있습니다.
선택적 구성
로깅
로깅을 빠르게 활성화하려면 웹사이트 URL에 ?brazeLogging=true
를 매개변수로 추가하면 됩니다. 또는 기본 또는 사용자 지정 로깅을 사용 설정할 수 있습니다.
기본 로깅
SDK가 초기화되기 전에 enableLogging
을 사용하여 기본 디버깅 메시지를 JavaScript 콘솔에 기록하세요.
1
enableLogging: true
방법은 다음과 유사해야 합니다:
1
2
3
4
5
braze.initialize('API-KEY', {
baseUrl: 'API-ENDPOINT',
enableLogging: true
});
braze.openSession();
SDK가 초기화된 후 기본 디버깅 메시지를 JavaScript 콘솔에 기록하려면 braze.toggleLogging()
을 사용하세요. 방법은 다음과 유사해야 합니다:
1
2
3
4
5
6
braze.initialize('API-KEY', {
baseUrl: 'API-ENDPOINT',
});
braze.openSession();
...
braze.toggleLogging();
기본 로그는 모든 사용자에게 표시되므로 코드를 프로덕션에 출시하기 전에 비활성화하거나 setLogger
로 전환합니다.
사용자 지정 로깅
setLogger
을 사용하여 사용자 지정 디버깅 메시지를 JavaScript 콘솔에 기록합니다. 기본 로그와 달리 이러한 로그는 사용자에게 표시되지 않습니다.
1
setLogger(loggerFunction: (message: STRING) => void): void
STRING
를 단일 문자열 매개변수로 메시지로 바꿉니다. 방법은 다음과 유사해야 합니다:
1
2
3
4
5
braze.initialize('API-KEY');
braze.setLogger(function(message) {
console.log("Braze Custom Logger: " + message);
});
braze.openSession();
SDK 업그레이드하기
이 가이드는 Braze Web SDK 4.0.0+의 코드 샘플을 사용합니다. 최신 웹 SDK 버전으로 업그레이드하려면 SDK 업그레이드 가이드를 참조하세요.
기본 통합 지침에서 권장하는 대로 콘텐츠 전송 네트워크(예: https://js.appboycdn.com/web-sdk/a.a/braze.min.js
)에서 Braze 웹 SDK를 참조하면 사용자가 사이트를 새로 고칠 때 자동으로 사소한 업데이트(위 예제에서 버그 수정 및 역호환 가능한 기능, a.a.a
~a.a.z
버전)를 수신합니다.
그러나 주요 변경 사항을 출시할 때는 주요 변경 사항이 통합 기능에 영향을 주지 않도록 하기 위해 Braze 웹 SDK를 수동으로 업그레이드해야 합니다. 또한 SDK를 다운로드하여 직접 호스팅하는 경우 버전 업데이트를 자동으로 수신하지 않으므로 최신 기능 및 버그 수정을 수신하려면 수동으로 업그레이드해야 합니다.
RSS 리더 또는 원하는 서비스를 사용하여 릴리스 피드를 따라 최신 릴리스를 최신 상태로 유지할 수 있습니다. 웹 SDK 릴리스 내역에 대한 전체 설명은 체인지로그를 참조하세요. Braze 웹 SDK를 업그레이드하려면:
https://js.appboycdn.com/web-sdk/[OLD VERSION NUMBER]/braze.min.js
의 버전 번호를 변경하거나 패키지 매니저의 종속성에서 Braze 라이브러리 버전을 업데이트합니다.- 웹 푸시가 통합된 경우 사이트의 서비스 종사자 파일을 업데이트합니다. 기본적으로 사이트의 루트 디렉토리 내
/service-worker.js
에 있지만 일부 통합에서는 위치를 사용자 지정할 수 있습니다. 서비스 워커 파일을 호스팅하려면 루트 디렉터리에 액세스해야 합니다.
이 두 파일은 적절한 기능을 위해 서로 조정하여 업데이트해야 합니다.
Google 태그 관리자
Google 태그 관리자(GTM)를 사용하면 프로덕션 코드 릴리스나 엔지니어링 리소스 없이도 웹사이트에 원격으로 태그를 추가, 제거, 편집할 수 있습니다. Braze는 다음과 같은 GTM 템플릿을 제공합니다:
태그 유형 | 사용 사례 |
---|---|
초기화 태그: | 초기화 태그는 웹브레이즈 SDK를 초기화하는 데 사용할 수 있습니다. |
작업 태그: | 액션 태그는 콘텐츠 카드 관리 및 분석 로깅에 사용할 수 있습니다. |
두 태그 모두 Google의 커뮤니티 갤러리에서 또는 커뮤니티 템플릿에서 새 태그를 추가할 때 Braze를 검색하여 작업 공간에 추가할 수 있습니다.
Google의 업데이트된 EU 사용자 동의 정책
Google은 2024년 3월 6일부터 시행되는 디지털 시장법(DMA) 개정 사항에 따라 EU 사용자 동의 정책을 업데이트하고 있습니다. 이 새로운 변경 사항에 따라 광고주는 EEA 및 영국 최종 사용자에게 특정 정보를 공개하고 해당 사용자로부터 필요한 동의를 얻어야 합니다. 자세한 내용은 다음 문서를 참조하세요.
Google의 EU 사용자 동의 정책의 일환으로 다음 부울 커스텀 속성을 고객 프로필에 기록해야 합니다.
$google_ad_user_data
$google_ad_personalization
GTM 통합을 통해 설정하는 경우 커스텀 속성을 사용하려면 커스텀 HTML 태그를 생성해야 합니다. 다음은 이러한 값을 문자열이 아닌 부울 데이터 유형으로 기록하는 방법의 예시입니다:
1
2
3
<script>
window.braze.getUser().setCustomUserAttribute("$google_ad_personalization", true);
</script>
자세한 내용은 Google에 오디언스 동기화를 참조하세요.
기타 통합 방법
AMP(가속 모바일 페이지)
자세히 보기
1단계: AMP 웹 푸시 스크립트 포함
다음 비동기 스크립트 태그를 기억합니다.
1
<script async custom-element="amp-web-push" src="https://cdn.ampproject.org/v0/amp-web-push-0.1.js"></script>
2단계: 구독 위젯 추가
사용자가 푸시를 구독 및 수신 취소할 수 있는 위젯을 HTML 본문에 추가하세요.
1
2
3
4
5
6
7
8
9
<!-- A subscription widget -->
<amp-web-push-widget visibility="unsubscribed" layout="fixed" width="250" height="80">
<button on="tap:amp-web-push.subscribe">Subscribe to Notifications</button>
</amp-web-push-widget>
<!-- An unsubscription widget -->
<amp-web-push-widget visibility="subscribed" layout="fixed" width="250" height="80">
<button on="tap:amp-web-push.unsubscribe">Unsubscribe from Notifications</button>
</amp-web-push-widget>
3단계: helper-iframe
및 permission-dialog
AMP 웹 푸시 컴포넌트는 푸시 구독을 처리하는 팝업을 생성하므로 이 기능을 사용하려면 프로젝트에 다음 헬퍼 파일을 추가해야 합니다:
4단계: 서비스 워커 파일 만들기
웹사이트의 루트 디렉터리에 service-worker.js
파일을 만들고 다음 코드 조각을 추가합니다:
5단계: AMP 웹 푸시 HTML 요소 구성
HTML 본문에 다음 amp-web-push
HTML 요소를 추가합니다. apiKey
및 baseUrl
을 service-worker-URL
에 쿼리 매개 변수로 추가해야 한다는 점을 기억하세요.
1
2
3
4
5
6
7
<amp-web-push
layout="nodisplay"
id="amp-web-push"
helper-iframe-url="FILE_PATH_TO_YOUR_HELPER_IFRAME"
permission-dialog-url="FILE_PATH_TO_YOUR_PERMISSION_DIALOG"
service-worker-url="FILE_PATH_TO_YOUR_SERVICE_WORKER?apiKey={YOUR_API_KEY}&baseUrl={YOUR_BASE_URL}"
>
AMD: 지원 비활성화하기
사이트에서 RequireJS 또는 다른 AMD 모듈 로더를 사용하지만 이 목록의 다른 옵션 중 하나를 통해 Braze Web SDK를 로드하는 것을 선호하는 경우 AMD 지원이 포함되지 않은 라이브러리 버전을 로드할 수 있습니다. 이 라이브러리 버전은 다음 CDN 위치에서 로드할 수 있습니다:
AMD: 모듈 로더
RequireJS 또는 기타 AMD module-loaders를 사용하는 경우 라이브러리 사본을 자체 호스팅하고 다른 리소스와 마찬가지로 참조하는 것이 좋습니다.
1
2
3
4
5
require(['path/to/braze.min.js'], function(braze) {
braze.initialize('YOUR-API-KEY-HERE', { baseUrl: 'YOUR-SDK-ENDPOINT' });
braze.automaticallyShowInAppMessages();
braze.openSession();
});
전자
Electron은 웹 푸시 알림을 공식적으로 지원하지 않습니다(이 GitHub 이슈 참조). Braze에서 테스트하지 않은 다른 오픈 소스 해결 방법을 시도해 볼 수 있습니다.
재스트 프레임워크
Jest를 사용할 때 SyntaxError: Unexpected token 'export'
와 유사한 오류가 표시될 수 있습니다. 이 문제를 해결하려면 Braze SDK를 무시하도록 package.json
에서 구성을 조정합니다.
1
2
3
4
5
"jest": {
"transformIgnorePatterns": [
"/node_modules/(?!@braze)"
]
}
SSR 프레임워크
Next.js 와 같은 서버 측 렌더링(SSR) 프레임워크를 사용하는 경우 SDK가 브라우저 환경에서 실행되도록 되어 있기 때문에 오류가 발생할 수 있습니다. SDK를 동적으로 가져오면 이러한 문제를 해결할 수 있습니다.
SDK에서 필요한 부분을 별도의 파일로 내보낸 다음, 해당 파일을 구성요소에 동적으로 가져오는 방식으로 트리 셰이킹의 이점을 유지할 수 있습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// MyComponent/braze-exports.js
// export the parts of the SDK you need here
export { initialize, openSession } from "@braze/web-sdk";
// MyComponent/MyComponent.js
// import the functions you need from the braze exports file
useEffect(() => {
import("./braze-exports.js").then(({ initialize, openSession }) => {
initialize("YOUR-API-KEY-HERE", {
baseUrl: "YOUR-SDK-ENDPOINT",
enableLogging: true,
});
openSession();
});
}, []);
또는 웹팩을 사용하여 앱을 번들링하는 경우 매직 코멘트를 활용하여 SDK의 필요한 부분만 동적으로 가져올 수 있습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
// MyComponent.js
useEffect(() => {
import(
/* webpackExports: ["initialize", "openSession"] */
"@braze/web-sdk"
).then(({ initialize, openSession }) => {
initialize("YOUR-API-KEY-HERE", {
baseUrl: "YOUR-SDK-ENDPOINT",
enableLogging: true,
});
openSession();
});
}, []);
Tealium iQ
Tealium iQ는 기본적인 턴키 방식의 Braze 통합을 제공합니다. 통합을 구성하려면 Tealium 태그 관리 인터페이스에서 Braze를 검색하고 대시보드에서 웹 SDK API 키를 제공합니다.
자세한 내용이나 심층적인 Tealium 구성 지원은 통합 설명서를 확인하거나 Tealium 계정 관리자에게 문의하세요.
Vite
Vite를 사용할 때 순환 종속성 또는 Uncaught TypeError: Class extends value undefined is not a constructor or null
에 대한 경고가 표시되는 경우 Braze SDK를 종속성 검색에서 제외해야 할 수 있습니다.
1
2
3
optimizeDeps: {
exclude: ['@braze/web-sdk']
},
기타 태그 관리자
Braze는 사용자 지정 HTML 태그 내의 통합 지침에 따라 다른 태그 관리 솔루션과도 호환될 수 있습니다. 이러한 솔루션을 평가하는 데 도움이 필요하면 Braze 담당자에게 문의하세요.
Integrating the Cordova SDK
Prerequisites
Before you start, verify your environment is supported by the latest Braze Cordova SDK version.
Step 1: Add the SDK to your project
Only add the Braze Cordova SDK using the methods below. Do not attempt to install using other methods as it could lead to a security breach.
If you’re on Cordova 6 or later, you can add the SDK directly from GitHub. Alternatively, you can download a ZIP of the GitHub repository and add the SDK manually.
If you don’t plan on using location collection and geofences, use the master
branch from GitHub.
1
cordova plugin add https://github.com/braze-inc/braze-cordova-sdk#master
If you plan on using location collection and geofences, use the geofence-branch
from GitHub.
1
cordova plugin add https://github.com/braze-inc/braze-cordova-sdk#geofence-branch
You can switch between master
and geofence-branch
at anytime by repeating this step.
Step 2: Configure your project
Next, adding the following preferences to the platform
element in your project’s config.xml
file.
1
2
<preference name="com.braze.ios_api_key" value="BRAZE_API_KEY" />
<preference name="com.braze.ios_api_endpoint" value="CUSTOM_API_ENDPOINT" />
1
2
<preference name="com.braze.android_api_key" value="BRAZE_API_KEY" />
<preference name="com.braze.android_api_endpoint" value="CUSTOM_API_ENDPOINT" />
Replace the following:
Value | Description |
---|---|
BRAZE_API_KEY |
Your Braze REST API key. |
CUSTOM_API_ENDPOINT |
A custom API endpoint. This endpoint is used to route your Braze instance data to the correct App Group in your Braze dashboard. |
The platform
element in your config.xml
file should be similar to the following:
1
2
3
4
<platform name="ios">
<preference name="com.braze.ios_api_key" value="BRAZE_API_KEY" />
<preference name="com.braze.ios_api_endpoint" value="sdk.fra-01.braze.eu" />
</platform>
1
2
3
4
<platform name="android">
<preference name="com.braze.android_api_key" value="BRAZE_API_KEY" />
<preference name="com.braze.android_api_endpoint" value="sdk.fra-01.braze.eu" />
</platform>
Platform-specific syntax
The following section covers the platform-specific syntax when using Cordova with iOS or Android.
Integers
Integer preferences are read as string representations, like in the following example:
1
2
3
4
<platform name="ios">
<preference name="com.braze.ios_flush_interval_seconds" value="10" />
<preference name="com.braze.ios_session_timeout" value="5" />
</platform>
Due to how the Cordova 8.0.0+ framework handles preferences, integer-only preferences (such as sender IDs) must be set to strings prepended with str_
, like in the following example:
1
2
3
4
<platform name="android">
<preference name="com.braze.android_fcm_sender_id" value="str_64422926741" />
<preference name="com.braze.android_default_session_timeout" value="str_10" />
</platform>
Booleans
Boolean preferences are read by the SDK using YES
and NO
keywords as a string representation, like in the following example:
1
2
3
4
<platform name="ios">
<preference name="com.braze.should_opt_in_when_push_authorized" value="YES" />
<preference name="com.braze.ios_disable_automatic_push_handling" value="NO" />
</platform>
Boolean preferences are read by the SDK using true
and false
keywords as a string representation, like in the following example:
1
2
3
4
<platform name="android">
<preference name="com.braze.should_opt_in_when_push_authorized" value="true" />
<preference name="com.braze.is_session_start_based_timeout_enabled" value="false" />
</platform>
Optional configurations
You can add any of the following preferences to the platform
element in your project’s config.xml
file:
Method | Description |
---|---|
ios_api_key |
Sets the API key for your application. |
ios_api_endpoint |
Sets the SDK endpoint for your application. |
ios_disable_automatic_push_registration |
Sets whether automatic push registration should be disabled. |
ios_disable_automatic_push_handling |
Sets whether automatic push handling should be disabled. |
ios_enable_idfa_automatic_collection |
Sets whether the Braze SDK should automatically collect the IDFA information. For more information, see the Braze IDFA method documentation. |
enable_location_collection |
Sets whether the automatic location collection is enabled (if the user permits). The geofence-branch |
geofences_enabled |
Sets whether geofences are enabled. |
ios_session_timeout |
Sets the Braze session timeout for your application in seconds. Defaults to 10 seconds. |
sdk_authentication_enabled |
Sets whether to enable the SDK Authentication feature. |
display_foreground_push_notifications |
Sets whether push notifications should be displayed while the application is in the foreground. |
ios_disable_un_authorization_option_provisional |
Sets whether UNAuthorizationOptionProvisional should be disabled. |
trigger_action_minimum_time_interval_seconds |
Sets the minimum time interval in seconds between triggers. Defaults to 30 seconds. |
ios_push_app_group |
Sets the app group ID for iOS push extensions. |
ios_forward_universal_links |
Sets if the SDK should automatically recognize and forward universal links to the system methods. |
ios_log_level |
Sets the minimum logging level for Braze.Configuration.Logger . |
ios_use_uuid_as_device_id |
Sets if a randomly generated UUID should be used as the device ID. |
ios_flush_interval_seconds |
Sets the interval in seconds between automatic data flushes. Defaults to 10 seconds. |
ios_use_automatic_request_policy |
Sets whether the request policy for Braze.Configuration.Api should be automatic or manual. |
should_opt_in_when_push_authorized |
Sets if a user’s notification subscription state should automatically be set to optedIn when push permissions are authorized. |
For more detailed information, see GitHub: Braze iOS Cordova plugin.
Method | Description |
---|---|
android_api_key |
Sets the API key for your application. |
android_api_endpoint |
Sets the SDK endpoint for your application. |
android_small_notification_icon |
Sets the notification small icon. |
android_large_notification_icon |
Sets the notification large icon. |
android_notification_accent_color |
Sets the notification accent color using a hexadecimal representation. |
android_default_session_timeout |
Sets the Braze session timeout for your application in seconds. Defaults to 10 seconds. |
android_handle_push_deep_links_automatically |
Sets whether the Braze SDK should automatically handle push deep links. |
android_log_level |
Sets the log level for your application. The default log level is 4 and will minimally log info. To enable verbose logging for debugging, use log level 2. |
firebase_cloud_messaging_registration_enabled |
Sets whether to use Firebase Cloud Messaging for push notifications. |
android_fcm_sender_id |
Sets the Firebase Cloud Messaging sender ID. |
enable_location_collection |
Sets whether the automatic location collection is enabled (if the user permits). |
geofences_enabled |
Sets whether geofences are enabled. |
android_disable_auto_session_tracking |
Disable the Android Cordova plugin from automatically tracking sessions. For more information, see Disabling automatic session tracking |
sdk_authentication_enabled |
Sets whether to enable the SDK Authentication feature. |
trigger_action_minimum_time_interval_seconds |
Sets the minimum time interval in seconds between triggers. Defaults to 30 seconds. |
is_session_start_based_timeout_enabled |
Sets whether the session timeout behavior to be based either on session start or session end events. |
default_notification_channel_name |
Sets the user-facing name as seen via NotificationChannel.getName for the Braze default NotificationChannel . |
default_notification_channel_description |
Sets the user-facing description as seen via NotificationChannel.getDescription for the Braze default NotificationChannel . |
does_push_story_dismiss_on_click |
Sets whether a Push Story is automatically dismissed when clicked. |
is_fallback_firebase_messaging_service_enabled |
Sets whether the use of a fallback Firebase Cloud Messaging Service is enabled. |
fallback_firebase_messaging_service_classpath |
Sets the classpath for the fallback Firebase Cloud Messaging Service. |
is_content_cards_unread_visual_indicator_enabled |
Sets whether the Content Cards unread visual indication bar is enabled. |
is_firebase_messaging_service_on_new_token_registration_enabled |
Sets whether the Braze SDK will automatically register tokens in com.google.firebase.messaging.FirebaseMessagingService.onNewToken . |
is_push_deep_link_back_stack_activity_enabled |
Sets whether Braze will add an activity to the back stack when automatically following deep links for push. |
push_deep_link_back_stack_activity_class_name |
Sets the activity that Braze will add to the back stack when automatically following deep links for push. |
should_opt_in_when_push_authorized |
Sets if Braze should automatically opt-in the user when push is authorized. |
For more detailed information, see GitHub: Braze Android Cordova plugin.
The following is an example config.xml
file with additional configurations:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<platform name="ios">
<preference name="com.braze.ios_disable_automatic_push_registration" value="NO"/"YES" />
<preference name="com.braze.ios_disable_automatic_push_handling" value="NO"/"YES" />
<preference name="com.braze.ios_enable_idfa_automatic_collection" value="YES"/"NO" />
<preference name="com.braze.enable_location_collection" value="NO"/"YES" />
<preference name="com.braze.geofences_enabled" value="NO"/"YES" />
<preference name="com.braze.ios_session_timeout" value="5" />
<preference name="com.braze.sdk_authentication_enabled" value="YES"/"NO" />
<preference name="com.braze.display_foreground_push_notifications" value="YES"/"NO" />
<preference name="com.braze.ios_disable_un_authorization_option_provisional" value="NO"/"YES" />
<preference name="com.braze.trigger_action_minimum_time_interval_seconds" value="30" />
<preference name="com.braze.ios_push_app_group" value="PUSH_APP_GROUP_ID" />
<preference name="com.braze.ios_forward_universal_links" value="YES"/"NO" />
<preference name="com.braze.ios_log_level" value="2" />
<preference name="com.braze.ios_use_uuid_as_device_id" value="YES"/"NO" />
<preference name="com.braze.ios_flush_interval_seconds" value="10" />
<preference name="com.braze.ios_use_automatic_request_policy" value="YES"/"NO" />
<preference name="com.braze.should_opt_in_when_push_authorized" value="YES"/"NO" />
</platform>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<platform name="android">
<preference name="com.braze.android_small_notification_icon" value="RESOURCE_ENTRY_NAME_FOR_ICON_DRAWABLE" />
<preference name="com.braze.android_large_notification_icon" value="RESOURCE_ENTRY_NAME_FOR_ICON_DRAWABLE" />
<preference name="com.braze.android_notification_accent_color" value="str_ACCENT_COLOR_INTEGER" />
<preference name="com.braze.android_default_session_timeout" value="str_SESSION_TIMEOUT_INTEGER" />
<preference name="com.braze.android_handle_push_deep_links_automatically" value="true"/"false" />
<preference name="com.braze.android_log_level" value="str_LOG_LEVEL_INTEGER" />
<preference name="com.braze.firebase_cloud_messaging_registration_enabled" value="true"/"false" />
<preference name="com.braze.android_fcm_sender_id" value="str_YOUR_FCM_SENDER_ID" />
<preference name="com.braze.enable_location_collection" value="true"/"false" />
<preference name="com.braze.geofences_enabled" value="true"/"false" />
<preference name="com.braze.android_disable_auto_session_tracking" value="true"/"false" />
<preference name="com.braze.sdk_authentication_enabled" value="true"/"false" />
<preference name="com.braze.trigger_action_minimum_time_interval_seconds" value="str_MINIMUM_INTERVAL_INTEGER" />
<preference name="com.braze.is_session_start_based_timeout_enabled" value="false"/"true" />
<preference name="com.braze.default_notification_channel_name" value="DEFAULT_NAME" />
<preference name="com.braze.default_notification_channel_description" value="DEFAULT_DESCRIPTION" />
<preference name="com.braze.does_push_story_dismiss_on_click" value="true"/"false" />
<preference name="com.braze.is_fallback_firebase_messaging_service_enabled" value="true"/"false" />
<preference name="com.braze.fallback_firebase_messaging_service_classpath" value="FALLBACK_FIREBASE_MESSAGING_CLASSPATH" />
<preference name="com.braze.is_content_cards_unread_visual_indicator_enabled" value="true"/"false" />
<preference name="com.braze.is_firebase_messaging_service_on_new_token_registration_enabled" value="true"/"false" />
<preference name="com.braze.is_push_deep_link_back_stack_activity_enabled" value="true"/"false" />
<preference name="com.braze.push_deep_link_back_stack_activity_class_name" value="DEEPLINK_BACKSTACK_ACTIVITY_CLASS_NAME" />
<preference name="com.braze.should_opt_in_when_push_authorized" value="true"/"false" />
</platform>
Disabling automatic session tracking (Android only)
By default, the Android Cordova plugin automatically tracks sessions. To disable automatic session tracking, add the following preference to the platform
element in your project’s config.xml
file:
1
2
3
<platform name="android">
<preference name="com.braze.android_disable_auto_session_tracking" value="true" />
</platform>
To start tracking sessions again, call BrazePlugin.startSessionTracking()
. Keep in mind, only sessions started after the next Activity.onStart()
will be tracked.
Flutter Braze SDK 정보
Android 및 iOS에서 Braze Flutter SDK를 통합한 후에는 Dart로 작성된 Flutter 앱 내에서 Braze API를 사용할 수 있습니다. 이 플러그인은 기본적인 분석 기능을 제공하며, 이를 통해 단일 코드베이스에서 iOS 및 Android용 인앱 메시지와 콘텐츠 카드를 통합할 수 있습니다.
Flutter SDK 통합
Prerequisites
Braze Flutter SDK를 통합하기 전에 다음을 완료해야 합니다:
필수 조건 | 설명 |
---|---|
Braze API 앱 식별자 | 앱의 식별자를 찾으려면 설정 > API 및 식별자 > 앱 식별자로 이동합니다. 자세한 내용은 API 식별자 유형을 참조하세요. |
Braze REST 엔드포인트 | REST 엔드포인트 URL. 엔드포인트는 인스턴스의 Braze URL에 따라 달라집니다. |
Flutter SDK | 공식 Flutter SDK를 설치하고 Braze Flutter SDK의 최소 지원 버전을 충족하는지 확인합니다. |
1단계: Braze 라이브러리 통합
명령줄에서 Braze Flutter SDK 패키지를 추가합니다. 그러면 pubspec.yaml
에 적절한 줄이 추가됩니다.
1
flutter pub add braze_plugin
2단계: 완벽한 네이티브 SDK 설정
Braze 서버에 연결하려면 프로젝트의 android/res/values
폴더에서 braze.xml
파일을 생성합니다. 다음 코드를 붙여넣고 API 식별자 키와 엔드포인트를 사용자 값으로 바꿉니다.
1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="com_braze_api_key">YOUR_APP_IDENTIFIER_API_KEY</string>
<string translatable="false" name="com_braze_custom_endpoint">YOUR_CUSTOM_ENDPOINT_OR_CLUSTER</string>
</resources>
AndroidManifest.xml
파일에 필요한 권한을 추가합니다:
1
2
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
AppDelegate.swift
파일 상단에 Braze SDK 가져오기를 추가합니다:
1
2
import BrazeKit
import braze_plugin
같은 파일의 application(_:didFinishLaunchingWithOptions:)
메서드에서 Braze 구성 오브젝트를 생성하고 API 키와 엔드포인트를 앱의 값으로 바꿉니다. 그런 다음 구성을 사용하여 Braze 인스턴스를 생성하고 AppDelegate
에 정적 속성을 생성하여 쉽게 액세스할 수 있도록 합니다:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
static var braze: Braze? = nil
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
// Setup Braze
let configuration = Braze.Configuration(
apiKey: "<BRAZE_API_KEY>",
endpoint: "<BRAZE_ENDPOINT>"
)
// - Enable logging or customize configuration here
configuration.logger.level = .info
let braze = BrazePlugin.initBraze(configuration)
AppDelegate.braze = braze
return true
}
AppDelegate.m
파일 상단에 있는 BrazeKit
를 가져옵니다.
1
@import BrazeKit;
같은 파일의 application:didFinishLaunchingWithOptions:
메서드에서 Braze 구성 오브젝트를 생성하고 API 키와 엔드포인트를 앱의 값으로 바꿉니다. 그런 다음 구성을 사용하여 Braze 인스턴스를 생성하고 AppDelegate
에 정적 속성을 생성하여 쉽게 액세스할 수 있도록 합니다:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Setup Braze
BRZConfiguration *configuration =
[[BRZConfiguration alloc] initWithApiKey:@"<BRAZE_API_KEY>"
endpoint:@"<BRAZE_ENDPOINT>"];
// - Enable logging or customize configuration here
configuration.logger.level = BRZLoggerLevelInfo;
Braze *braze = [BrazePlugin initBraze:configuration];
AppDelegate.braze = braze;
[self.window makeKeyAndVisible];
return YES;
}
#pragma mark - AppDelegate.braze
static Braze *_braze = nil;
+ (Braze *)braze {
return _braze;
}
+ (void)setBraze:(Braze *)braze {
_braze = braze;
}
3단계: 플러그인 설정
플러그인을 Dart 코드로 가져오려면 다음을 사용하세요:
1
import 'package:braze_plugin/braze_plugin.dart';
그런 다음, 샘플 앱에서와 같이 new BrazePlugin()
을 호출하여 Braze 플러그인 인스턴스를 초기화합니다.
정의되지 않은 동작을 방지하려면 Dart 코드에 BrazePlugin
인스턴스 하나만 할당하여 사용하세요.
통합 테스트
대시보드에서 세션 통계를 확인하여 SDK가 통합되었는지 확인할 수 있습니다. 어느 플랫폼에서든 애플리케이션을 실행하면 대시보드( 개요 섹션)에 새 세션이 표시됩니다.
앱에서 다음 코드를 호출하여 특정 사용자에 대한 세션을 엽니다.
1
2
BrazePlugin braze = BrazePlugin();
braze.changeUser("{some-user-id}");
대시보드의 오디언스 > 사용자 검색에서 {some-user-id}
으로 사용자를 검색합니다. 여기에서 세션 및 디바이스 데이터가 기록되었는지 확인할 수 있습니다.
리액트 네이티브 브라즈 SDK 정보
리액트 네이티브 브라즈 SDK를 통합하면 기본적인 분석 기능이 제공되며, 하나의 코드베이스로 iOS와 안드로이드용 인앱 메시지와 콘텐츠 카드를 통합할 수 있습니다.
새로운 아키텍처 호환성
다음 최소 SDK 버전은 React Native의 새 아키텍처를 사용하는 모든 앱과 호환됩니다:
SDK 버전 6.0.0부터 Braze는 새로운 아키텍처와 레거시 브리지 아키텍처 모두와 호환되는 React Native Turbo 모듈을 사용하므로 추가 설정이 필요하지 않습니다.
iOS 앱이 RCTAppDelegate
을 준수하고 이전 AppDelegate
설정을 따르는 경우, 터보 모듈에서 이벤트를 구독할 때 발생하는 충돌을 방지하기 위해 기본 설정 완료에 있는 샘플을 검토하세요.
React Native SDK 통합
Prerequisites
SDK를 통합하려면 React Native 버전 0.71 이상이 필요합니다. 지원되는 버전의 전체 목록은 React Native SDK GitHub 리포지토리를 참조하세요.
1단계: Braze 라이브러리 통합
1
npm install @braze/react-native-sdk
1
yarn add @braze/react-native-sdk
2단계: 설정 옵션 선택
Braze Expo 플러그인을 사용하거나 기본 레이어 중 하나를 통해 Braze SDK를 관리할 수 있습니다. 엑스포 플러그인을 사용하면 네이티브 레이어에서 코드를 작성하지 않고도 특정 SDK 기능을 구성할 수 있습니다. 앱의 요구 사항에 가장 적합한 옵션을 선택하세요.
2.1 단계: Braze Expo 플러그인을 설치하십시오
Braze React Native SDK 버전이 1.37.0 이상인지 확인합니다. 지원되는 전체 버전 목록은 Braze React Native 리포지토리에서 확인하세요.
Braze Expo 플러그인을 설치하려면 다음 명령을 실행합니다:
1
expo install @braze/expo-plugin
2.2 단계: 플러그인을 app.json에 추가하세요
귀하의 app.json
에 Braze Expo 플러그인을 추가하십시오. 다음 구성 옵션을 제공할 수 있습니다:
방법 | 유형 | 설명 |
---|---|---|
androidApiKey |
문자열 | 필수. 귀하의 Android 애플리케이션에 대한 API 키는 Braze 대시보드의 설정 관리 아래에 있습니다. |
iosApiKey |
문자열 | 필수. iOS 애플리케이션의 API 키는 Braze 대시보드의 설정 관리 아래에 있습니다. |
baseUrl |
문자열 | 필수. 귀하의 애플리케이션에 대한 SDK 엔드포인트는 설정 관리 아래 Braze 대시보드에 위치해 있습니다. |
enableBrazeIosPush |
불리언 | iOS만 해당. iOS에서 푸시 알림을 처리하기 위해 Braze를 사용할지 여부. React Native SDK v1.38.0 및 Expo 플러그인 v0.4.0에 도입되었습니다. |
enableFirebaseCloudMessaging |
불리언 | Android만 해당. 푸시 알림에 Firebase 클라우드 메시징을 사용할지 여부. React Native SDK v1.38.0 및 Expo 플러그인 v0.4.0에 도입되었습니다. |
firebaseCloudMessagingSenderId |
문자열 | Android만 해당. Firebase 클라우드 메시징 발신자 ID. React Native SDK v1.38.0 및 Expo 플러그인 v0.4.0에 도입되었습니다. |
sessionTimeout |
정수 | 애플리케이션의 Braze 세션 제한 시간(초). |
enableSdkAuthentication |
불리언 | SDK 인증 기능을 활성화할지 여부. |
logLevel |
정수 | 애플리케이션의 로그 레벨. 기본 로그 수준은 8이며, 최소한의 정보를 기록합니다. 디버깅을 위해 상세 로깅을 활성화하려면 로그 수준 0을 사용합니다. |
minimumTriggerIntervalInSeconds |
정수 | 트리거 사이의 최소 시간 간격(초) 기본값은 30초입니다. |
enableAutomaticLocationCollection |
불리언 | 자동 위치 수집이 활성화되어 있는지 여부(사용자가 허용하는 경우). |
enableGeofence |
불리언 | 지오펜스가 활성화되어 있는지 여부. |
enableAutomaticGeofenceRequests |
불리언 | 지오펜스 요청이 자동으로 이루어져야 하는지 여부. |
dismissModalOnOutsideTap |
불리언 | iOS만 해당. 사용자가 인앱 메시지 외부를 클릭할 때 Modal 인앱 메시지의 해제 여부. |
androidHandlePushDeepLinksAutomatically |
불리언 | Android만 해당. Braze SDK가 푸시 딥링크를 자동으로 처리해야 하는지 여부. |
androidPushNotificationHtmlRenderingEnabled |
불리언 | Android만 해당. 푸시 알림에서 텍스트 콘텐츠를 android.text.Html.fromHtml 을 사용하여 HTML로 해석하고 렌더링할지 여부를 설정합니다. |
androidNotificationAccentColor |
문자열 | Android만 해당. Android 알림 강조 색상을 설정합니다. |
androidNotificationLargeIcon |
문자열 | Android만 해당. Android 알림 큰 아이콘을 설정합니다. |
androidNotificationSmallIcon |
문자열 | Android만 해당. Android 알림 작은 아이콘을 설정합니다. |
iosRequestPushPermissionsAutomatically |
불리언 | iOS만 해당. 앱 실행 시 푸시 권한에 대한 프롬프트를 사용자에게 표시해야 하는지 여부. |
enableBrazeIosRichPush |
불리언 | iOS만 해당. iOS에 리치 푸시 기능을 활성화할지 여부. |
enableBrazeIosPushStories |
불리언 | iOS만 해당. iOS용 Braze 푸시 스토리를 활성화할지 여부. |
iosPushStoryAppGroup |
문자열 | iOS만 해당. iOS 푸시 스토리에 사용되는 앱 그룹. |
예시 구성:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"expo": {
"plugins": [
[
"@braze/expo-plugin",
{
"androidApiKey": "YOUR-ANDROID-API-KEY",
"iosApiKey": "YOUR-IOS-API-KEY",
"baseUrl": "YOUR-SDK-ENDPOINT",
"sessionTimeout": 60,
"enableGeofence": false,
"enableBrazeIosPush": false,
"enableFirebaseCloudMessaging": false,
"firebaseCloudMessagingSenderId": "YOUR-FCM-SENDER-ID",
"androidHandlePushDeepLinksAutomatically": true,
"enableSdkAuthentication": false,
"logLevel": 0,
"minimumTriggerIntervalInSeconds": 0,
"enableAutomaticLocationCollection": false,
"enableAutomaticGeofenceRequests": false,
"dismissModalOnOutsideTap": true,
"androidPushNotificationHtmlRenderingEnabled": true,
"androidNotificationAccentColor": "#ff3344",
"androidNotificationLargeIcon": "@drawable/custom_app_large_icon",
"androidNotificationSmallIcon": "@drawable/custom_app_small_icon",
"iosRequestPushPermissionsAutomatically": false,
"enableBrazeIosPushStories": true,
"iosPushStoryAppGroup": "group.com.example.myapp.PushStories"
}
],
]
}
}
2.3 단계: 애플리케이션 빌드 및 실행
애플리케이션을 미리 빌드하면 Braze Expo 플러그인이 작동하는 데 필요한 네이티브 파일이 생성됩니다.
1
expo prebuild
Expo 문서에 지정된 대로, 애플리케이션을 실행합니다. 구성 옵션을 변경하는 경우 애플리케이션을 다시 사전 빌드하고 실행해야 한다는 점에 유의하세요.
2.1 단계: 리포지토리 추가
상위 수준 프로젝트 build.gradle
에서 buildscript
> dependencies
아래에 다음을 추가합니다.
1
2
3
4
5
6
7
buildscript {
dependencies {
...
// Choose your Kotlin version
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
}
}
그러면 프로젝트에 Kotlin이 추가됩니다.
2.2 단계: Braze SDK 구성
Braze 서버에 연결하려면 프로젝트의 res/values
폴더에서 braze.xml
파일을 생성합니다. 다음 코드를 붙여넣고 API 키 및 엔드포인트를 값으로 바꾸세요:
1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="com_braze_api_key">YOU_APP_IDENTIFIER_API_KEY</string>
<string translatable="false" name="com_braze_custom_endpoint">YOUR_CUSTOM_ENDPOINT_OR_CLUSTER</string>
</resources>
AndroidManifest.xml
파일에 필요한 권한을 추가합니다:
1
2
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Braze SDK 버전 12.2.0 이상에서는 gradle.properties
파일에 importBrazeLocationLibrary=true
을 설정하여 android-sdk-location 라이브러리를 자동으로 가져올 수 있습니다.
2.3단계: 사용자 세션 추적 구현
openSession()
및 closeSession()
에 대한 호출은 자동으로 처리됩니다.
onCreate()
메서드에 다음 코드를 추가하십시오: MainApplication
클래스:
1
2
3
4
5
6
7
8
import com.braze.BrazeActivityLifecycleCallbackListener;
@Override
public void onCreate() {
super.onCreate();
...
registerActivityLifecycleCallbacks(new BrazeActivityLifecycleCallbackListener());
}
1
2
3
4
5
6
7
import com.braze.BrazeActivityLifecycleCallbackListener
override fun onCreate() {
super.onCreate()
...
registerActivityLifecycleCallbacks(BrazeActivityLifecycleCallbackListener())
}
2.4 단계: 의도 업데이트 처리
MainActivity에서 android:launchMode
가 singleTask
로 설정된 경우, MainActivity
클래스에 다음 코드를 추가합니다.
1
2
3
4
5
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
1
2
3
4
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
}
2.1 단계: (선택 사항) 동적 XCFrameworks용 Podfile 구성
특정 Braze 라이브러리(예: BrazeUI)를 Objective-C++ 파일에 가져오려면 #import
구문을 사용해야 합니다. Braze Swift SDK의 버전 7.4.0부터 바이너리는 이 구문과 호환되는 동적 XCFrameworks로 선택적 배포 채널을 사용합니다.
이 배포 채널을 사용하려면 Podfile에서 CocoaPods 소스 위치를 수동으로 재정의합니다. 샘플을 참조하고 {your-version}
을 가져오려는 관련 버전으로 바꿉니다.
1
2
3
pod 'BrazeKit', :podspec => 'https://raw.githubusercontent.com/braze-inc/braze-swift-sdk-prebuilt-dynamic/{your-version}/BrazeKit.podspec'
pod 'BrazeUI', :podspec => 'https://raw.githubusercontent.com/braze-inc/braze-swift-sdk-prebuilt-dynamic/{your-version}/BrazeUI.podspec'
pod 'BrazeLocation', :podspec => 'https://raw.githubusercontent.com/braze-inc/braze-swift-sdk-prebuilt-dynamic/{your-version}/BrazeLocation.podspec'
2.2 단계: 포드 설치
React Native는 라이브러리를 기본 플랫폼에 자동으로 연결하므로 CocoaPods를 사용하여 SDK를 설치할 수 있습니다.
프로젝트의 루트 폴더에서:
1
2
3
4
5
# To install using the React Native New Architecture
cd ios && RCT_NEW_ARCH_ENABLED=1 pod install
# To install using the React Native legacy architecture
cd ios && pod install
2.3 단계: Braze SDK 구성
AppDelegate.swift
파일 맨 위에서 Braze SDK를 가져옵니다.
1
import BrazeKit
application(_:didFinishLaunchingWithOptions:)
메서드에서 API 키 및 엔드포인트를 앱의 값으로 바꾸십시오. 그런 다음 구성을 사용하여 Braze 인스턴스를 생성하고 AppDelegate
에 정적 속성을 생성하여 쉽게 액세스할 수 있도록 합니다:
우리의 예제는 React Native 설정에서 여러 추상화를 제공하는 RCTAppDelegate의 구현을 가정합니다. 앱에 다른 설정을 사용하는 경우 필요에 따라 구현을 조정하십시오.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
// Setup Braze
let configuration = Braze.Configuration(
apiKey: "{BRAZE_API_KEY}",
endpoint: "{BRAZE_ENDPOINT}")
// Enable logging and customize the configuration here.
configuration.logger.level = .info
let braze = BrazeReactBridge.perform(
#selector(BrazeReactBridge.initBraze(_:)),
with: configuration
).takeUnretainedValue() as! Braze
AppDelegate.braze = braze
/* Other configuration */
return true
}
// MARK: - AppDelegate.braze
static var braze: Braze? = nil
AppDelegate.m
파일 맨 위에서 Braze SDK를 가져옵니다.
1
2
#import <BrazeKit/BrazeKit-Swift.h>
#import "BrazeReactBridge.h"
application:didFinishLaunchingWithOptions:
메서드에서 API 키 및 엔드포인트를 앱의 값으로 바꾸십시오. 그런 다음 구성을 사용하여 Braze 인스턴스를 생성하고 AppDelegate
에 정적 속성을 생성하여 쉽게 액세스할 수 있도록 합니다:
우리의 예제는 React Native 설정에서 여러 추상화를 제공하는 RCTAppDelegate의 구현을 가정합니다. 앱에 다른 설정을 사용하는 경우 필요에 따라 구현을 조정하십시오.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Setup Braze
BRZConfiguration *configuration = [[BRZConfiguration alloc] initWithApiKey:@"{BRAZE_API_KEY}"
endpoint:@"{BRAZE_ENDPOINT}"];
// Enable logging and customize the configuration here.
configuration.logger.level = BRZLoggerLevelInfo;
Braze *braze = [BrazeReactBridge initBraze:configuration];
AppDelegate.braze = braze;
/* Other configuration */
return YES;
}
#pragma mark - AppDelegate.braze
static Braze *_braze = nil;
+ (Braze *)braze {
return _braze;
}
+ (void)setBraze:(Braze *)braze {
_braze = braze;
}
3단계: 라이브러리 가져오기
그런 다음, import
리액트 네이티브 코드에 라이브러리를 추가합니다. 자세한 내용은 샘플 프로젝트를 확인하세요.
1
import Braze from "@braze/react-native-sdk";
4단계: 통합 테스트(선택 사항)
SDK 연동을 테스트하려면 앱에서 다음 코드를 호출하여 두 플랫폼에서 사용자에 대한 새 세션을 시작하세요.
1
Braze.changeUser("userId");
예를 들어, 앱 시작 시 사용자 ID를 할당할 수 있습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
import React, { useEffect } from "react";
import Braze from "@braze/react-native-sdk";
const App = () => {
useEffect(() => {
Braze.changeUser("some-user-id");
}, []);
return (
<div>
...
</div>
)
Braze 대시보드에서 사용자 검색으로 이동하여 some-user-id
과 일치하는 ID를 가진 사용자를 찾습니다. 여기에서 세션 및 디바이스 데이터가 기록되었는지 확인할 수 있습니다.
Roku SDK 통합
1단계: 파일 추가
Braze SDK 파일은 Braze Roku SDK 리포지토리의 sdk_files
디렉토리에서 찾을 수 있습니다.
source
디렉토리의 앱에BrazeSDK.brs
를 추가합니다.components
디렉토리의 앱에BrazeTask.brs
및BrazeTask.xml
을 추가합니다.
2단계: 참조 추가
다음 script
요소를 사용하여 기본 장면에서 BrazeSDK.brs
에 대한 참조를 추가합니다.
1
<script type="text/brightscript" uri="pkg:/source/BrazeSDK.brs"/>
3단계: 구성
main.brs
에서 글로벌 노드에서 Braze 구성을 설정합니다:
1
2
3
4
5
6
7
8
globalNode = screen.getGlobalNode()
config = {}
config_fields = BrazeConstants().BRAZE_CONFIG_FIELDS
config[config_fields.API_KEY] = {YOUR_API_KEY}
' example endpoint: "https://sdk.iad-01.braze.com/"
config[config_fields.ENDPOINT] = {YOUR_ENDPOINT}
config[config_fields.HEARTBEAT_FREQ_IN_SECONDS] = 5
globalNode.addFields({brazeConfig: config})
Braze 대시보드에서 SDK 엔드포인트와 API 키를 찾을 수 있습니다.
4단계: Braze 초기화
Braze 인스턴스를 초기화합니다:
1
2
m.BrazeTask = createObject("roSGNode", "BrazeTask")
m.Braze = getBrazeInstance(m.BrazeTask)
선택적 구성
로깅
Braze 통합을 디버깅하려면 Roku 디버그 콘솔에서 Braze 로그를 확인할 수 있습니다. 자세한 내용은 Roku 개발자의 코드 디버깅을 참조하세요.
유니티 브레이즈 SDK 소개
유형, 함수, 변수 등의 전체 목록은 Unity 선언 파일을 참조하세요. 또한 이미 iOS용 Unity를 수동으로 통합한 경우 자동 통합으로 전환할 수 있습니다.
Unity SDK 통합
Prerequisites
시작하기 전에 사용 중인 환경이 최신 Braze Unity SDK 버전에서 지원되는지 확인하세요.
1단계: Braze Unity 패키지 선택
Braze .unitypackage
는 C# 인터페이스와 함께 Android 및 iOS 플랫폼용 기본 바인딩을 번들로 제공합니다.
Braze Unity 릴리즈 페이지에서 여러 Braze Unity 패키지를 다운로드할 수 있습니다.
Appboy.unitypackage
- 이 패키지는 Braze 인앱 메시징 및 iOS의 콘텐츠 카드 기능이 제대로 작동하는 데 필요한 Braze Android 및 iOS SDK와 iOS SDK에 대한 SDWebImage 종속성을 번들로 제공합니다. SDWebImage 프레임워크는 GIF를 포함한 이미지를 다운로드하고 표시하는 데 사용됩니다. Braze의 모든 기능을 활용하려면 이 패키지를 다운로드하여 가져오세요.
Appboy-nodeps.unitypackage
- 이 패키지는 SDWebImage 프레임워크가 없다는 점을 제외하면
Appboy.unitypackage
과 유사합니다. 이 패키지는 iOS 앱에 SDWebImage 프레임워크가 표시되지 않도록 하려는 경우에 유용합니다.
- 이 패키지는 SDWebImage 프레임워크가 없다는 점을 제외하면
Unity 2.6.0부터 번들로 제공되는 Braze Android SDK 아티팩트에는 AndroidX 종속성이 필요합니다. 이전에 jetified unitypackage
를 사용했다면 해당되는 unitypackage
로 안전하게 전환할 수 있습니다.
Braze .unitypackage
는 C# 인터페이스와 함께 Android 및 iOS 플랫폼용 기본 바인딩을 번들로 제공합니다.
Braze Unity 패키지는 다음과 같은 두 가지 통합 옵션을 사용해 Braze Unity 릴리즈 페이지에서 다운로드할 수 있습니다.
Appboy.unitypackage
만- 이 패키지는 추가 종속성 없이 Braze Android 및 iOS SDK를 번들로 제공합니다. 이 통합 방법을 사용하는 경우 iOS에서 Braze 인앱 메시징 및 콘텐츠 카드 기능이 제대로 작동하지 않습니다. 커스텀 코드 없이 전체 Braze 기능을 활용하려는 경우 대신 아래 옵션을 사용합니다.
- 이 통합 옵션을 사용하려면 Unity UI의 ‘Braze 구성’ 아래에서
Import SDWebImage dependency
옆의 확인란이 선택 해제되었는지 확인합니다.
Appboy.unitypackage
(SDWebImage
포함)- 이 통합 옵션은 Braze 인앱 메시징 및 iOS의 콘텐츠 카드 기능이 제대로 작동하는 데 필요한 Braze Android 및 iOS SDK와 iOS SDK에 대한 SDWebImage 종속성을 번들로 제공합니다.
SDWebImage
프레임워크는 GIF를 포함한 이미지를 다운로드하고 표시하는 데 사용됩니다. Braze의 모든 기능을 활용하려면 이 패키지를 다운로드하여 가져오세요. SDWebImage
를 자동으로 가져오려면 Unity UI의 ‘Braze 구성’ 아래Import SDWebImage dependency
옆의 확인란을 선택해야 합니다.
- 이 통합 옵션은 Braze 인앱 메시징 및 iOS의 콘텐츠 카드 기능이 제대로 작동하는 데 필요한 Braze Android 및 iOS SDK와 iOS SDK에 대한 SDWebImage 종속성을 번들로 제공합니다.
iOS 프로젝트에 SDWebImage 종속성이 필요한지 확인하려면 iOS 인앱 메시지 문서.
2단계: 패키지 가져오기
Unity 편집기에서 자산 > 패키지 가져오기 > 커스텀 패키지로 이동하여 패키지를 Unity 프로젝트로 가져옵니다 다음으로, 가져오기를 클릭합니다.
또는 커스텀 Unity 패키지 가져오기에 대한 자세한 가이드는 Unity 자산 패키지 가져오기 지침을 따릅니다.
iOS 또는 Android 플러그인만 가져오려면 Braze .unitypackage
를 가져올 때 Plugins/Android
또는 Plugins/iOS
하위 디렉토리를 선택 해제합니다.
Unity 편집기에서 자산 > 패키지 가져오기 > 커스텀 패키지로 이동하여 패키지를 Unity 프로젝트로 가져옵니다 다음으로, 가져오기를 클릭합니다.
또는 커스텀 Unity 패키지 가져오기에 대한 자세한 가이드는 Unity 자산 패키지 가져오기 지침을 따릅니다.
iOS 또는 Android 플러그인만 가져오려면 Braze .unitypackage
를 가져올 때 Plugins/Android
또는 Plugins/iOS
하위 디렉토리를 선택 해제합니다.
3단계: SDK 구성
3.1 단계: 구성 AndroidManifest.xml
풀로 AndroidManifest.xml
가 작동합니다. 앱에 AndroidManifest.xml
이 없는 경우 다음을 템플릿으로 사용할 수 있습니다. 그렇지 않으면 이미 AndroidManifest.xml
이 있는 경우 기존 AndroidManifest.xml
에 다음 중 누락된 섹션이 추가되었는지 확인합니다.
Assets/Plugins/Android/
디렉토리로 이동하여AndroidManifest.xml
파일을 엽니다. Unity 에디터의 기본 위치입니다.AndroidManifest.xml
에서 다음 템플릿의 필수 권한 및 활동을 추가합니다.- 완료되면
AndroidManifest.xml
에는"android.intent.category.LAUNCHER"
이 있는 하나의 활동만 포함되어 있어야 합니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="REPLACE_WITH_YOUR_PACKAGE_NAME">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/app_icon"
android:label="@string/app_name">
<!-- Calls the necessary Braze methods to ensure that analytics are collected and that push notifications are properly forwarded to the Unity application. -->
<activity android:name="com.braze.unity.BrazeUnityPlayerActivity"
android:theme="@style/UnityThemeSelector"
android:label="@string/app_name"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:screenOrientation="sensor">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- A Braze specific FirebaseMessagingService used to handle push notifications. -->
<service android:name="com.braze.push.BrazeFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
AndroidManifest.xml
파일에 등록된 모든 액티비티 클래스는 Braze 안드로이드 SDK와 완전히 통합되어야 하며, 그렇지 않으면 분석이 수집되지 않습니다. 자체 활동 클래스를 추가하는 경우, 이를 방지할 수 있도록 Braze Unity 플레이어를 확장해야 합니다.
3.2 단계: 패키지 이름으로 AndroidManifest.xml
업데이트
패키지 이름을 찾으려면 파일 > 빌드 설정 > 플레이어 설정 > Android 탭을 클릭합니다.
AndroidManifest.xml
에서 REPLACE_WITH_YOUR_PACKAGE_NAME
의 모든 인스턴스는 이전 단계의 Package Name
으로 바뀌어야 합니다.
3.3 단계: 그레이들 종속성 추가
Unity 프로젝트에 그래들 종속성을 추가하려면 먼저 퍼블리싱 설정에서 ‘커스텀 메인 그래들 템플릿’ 을 활성화합니다. 그러면 프로젝트에서 사용할 템플릿 gradle 파일이 생성됩니다. gradle 파일은 설정 종속성 및 기타 빌드 시점 프로젝트 설정을 처리합니다. 자세한 내용은 Braze Unity 샘플 앱의 mainTemplate.gradle.
다음 종속성이 필요합니다:
1
2
3
4
5
6
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.6.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1"
implementation 'androidx.core:core:1.6.0'
외부 종속성 매니저를 사용하여 이러한 종속성을 설정할 수도 있습니다.
3.4 단계: Unity Android 통합 자동화
Braze는 Unity Android 통합을 자동화하기 위한 기본 Unity 솔루션을 제공합니다.
- Unity 편집기에서 Braze > Braze 구성으로 이동하여 Braze 구성 설정을 엽니다.
- Unity Android 통합 자동화 확인란을 선택합니다.
- Braze API 키 필드에 Braze 대시보드의 설정 관리에서 찾은 애플리케이션의 API 키를 입력합니다.
이 자동 통합은 프로젝트 빌드 중에 구성 값이 충돌할 수 있으므로 수동으로 생성한 braze.xml
파일과 함께 사용해서는 안 됩니다. 수동 braze.xml
이 필요한 경우 자동 통합을 비활성화합니다.
3.1 단계: API 키 설정
Braze는 Unity iOS 통합을 자동화하기 위한 기본 Unity 솔루션을 제공합니다. 이 솔루션은 Unity의 PostProcessBuildAttribute
를 사용하여 빌드된 Xcode 프로젝트를 수정하고 IMPL_APP_CONTROLLER_SUBCLASS
매크로를 사용하여 UnityAppController
를 서브클래스로 구성합니다.
- Unity 편집기에서 Braze > Braze 구성으로 이동하여 Braze 구성 설정을 엽니다.
- Unity iOS 통합 자동화 확인란을 선택합니다.
- Braze API 키 필드에 설정 관리에서 찾은 애플리케이션의 API 키를 입력합니다.
애플리케이션에서 이미 다른 UnityAppController
서브클래스를 사용하고 있는 경우, 서브클래스 구현을 AppboyAppDelegate.mm
과 병합해야 합니다.
Unity 패키지 커스터마이징
1단계: 리포지토리 복제
터미널에서 Braze Unity SDK GitHub 리포지토리를 복제하고 해당 폴더로 이동합니다:
1
2
git clone [email protected]:braze-inc/braze-unity-sdk.git
cd ~/PATH/TO/DIRECTORY/braze-unity-sdk
1
2
git clone git@github.com:braze-inc/braze-unity-sdk.git
cd C:\PATH\TO\DIRECTORY\braze-unity-sdk
2단계: 리포지토리에서 패키지 내보내기
먼저 Unity를 실행하고 백그라운드에서 계속 실행합니다. 그런 다음 리포지토리 루트에서 다음 명령을 실행하여 패키지를 braze-unity-sdk/unity-package/
으로 내보냅니다.
1
/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -projectPath "$(pwd)" -executeMethod Appboy.Editor.Build.ExportAllPackages -quit
1
"%UNITY_PATH%" -batchmode -nographics -projectPath "%PROJECT_ROOT%" -executeMethod Appboy.Editor.Build.ExportAllPackages -quit
이러한 명령을 실행한 후 문제가 발생하면 Unity를 참조하세요: 명령줄 인수.
3단계: Unity로 패키지 임포트
- Unity에서 에셋 > 패키지 임포트 > 커스텀 패키지로 이동하여 원하는 패키지를 Unity 프로젝트로 임포트합니다.
- 가져오지 않으려는 파일이 있다면 지금 바로 선택을 취소하세요.
Assets/Editor/Build.cs
에 있는 익스포트된 Unity 패키지를 커스터마이즈합니다.
자동 통합으로 전환(Swift만 해당)
Braze Unity SDK에서 제공하는 자동화된 iOS 통합 기능을 활용하려면 수동 통합에서 자동 통합으로 전환하는 다음 단계를 따르세요.
- Xcode 프로젝트의
UnityAppController
서브클래스에서 모든 Braze 관련 코드를 제거합니다. - Unity 또는 Xcode 프로젝트에서 Braze iOS 라이브러리를 제거합니다(예:
Appboy_iOS_SDK.framework
및SDWebImage.framework
). - Braze Unity 패키지를 프로젝트에 다시 임포트합니다. 전체 안내는 2단계를 참조하세요: 패키지를 가져오기.
- API 키를 다시 설정하세요. 전체 안내는 3.1단계를 참조하세요: API 키 설정.
선택적 구성
상세 로깅
Unity 편집기에서 상세 로깅을 활성화하려면 다음을 수행합니다.
- Braze > Braze 구성으로 이동하여 Braze 구성 설정을 엽니다.
- Braze Android 설정 표시 드롭다운을 클릭합니다.
- SDK 로그 수준 필드에 ‘0’ 값을 입력합니다.
Prime 31 호환성
Prime31 플러그인과 함께 Braze Unity 플러그인을 사용하려면 프로젝트의 AndroidManifest.xml
을 편집하여 Prime31 호환 활동 클래스를 사용합니다. 의 모든 참조를 변경합니다.
com.braze.unity.BrazeUnityPlayerActivity
부터 com.braze.unity.prime31compatible.BrazeUnityPlayerActivity
까지
Amazon 디바이스 메시징(ADM)
Braze는 Unity 앱에 ADM 푸시 통합을 지원합니다. ADM 푸시를 통합하려면 ADM API 키가 포함된 api_key.txt
파일을 만들어 Plugins/Android/assets/
폴더에 넣습니다. ADM과 Braze를 통합하는 방법에 대한 자세한 내용은 ADM 푸시 통합 지침을 참조하세요.
Braze Unity 플레이어 확장(Android 전용)
제공된 예제 AndroidManifest.xml
파일에는 하나의 활동 클래스(BrazeUnityPlayerActivity
)가 등록되어 있습니다. 이 클래스는 Braze SDK와 통합되어 있으며 세션 처리, 인앱 메시지 등록, 푸시 알림 분석 로깅 등을 통해 UnityPlayerActivity
를 확장합니다. UnityPlayerActivity
클래스 확장에 대한 자세한 내용은 Unity를 참조하세요.
라이브러리 또는 플러그인 프로젝트에서 커스텀 UnityPlayerActivity
를 만드는 경우, 커스텀 기능을 Braze와 통합하려면 BrazeUnityPlayerActivity
를 확장해야 합니다. BrazeUnityPlayerActivity
확장 작업을 시작하기 전에, Unity 프로젝트에 Braze를 통합하기 위한 지침을 따르세요.
- Braze Android SDK 통합 지침에서 설명한 대로 라이브러리 또는 플러그인 프로젝트에 Braze Android SDK를 종속성으로 추가합니다.
- Unity 전용 기능이 포함된 Unity
.aar
을 Unity용으로 빌드 중인 Android 라이브러리 프로젝트에 통합합니다.appboy-unity.aar
은 공개 리포지토리에서 사용할 수 있습니다. Unity 라이브러리가 성공적으로 통합되면BrazeUnityPlayerActivity
를 확장하도록UnityPlayerActivity
를 수정합니다. - 라이브러리 또는 플러그인 프로젝트를 내보내고 평소처럼
/<your-project>/Assets/Plugins/Android
에 끌어다 놓습니다. Braze 소스 코드는 이미/<your-project>/Assets/Plugins/Android
에 있으므로 라이브러리나 플러그인에 포함하지 마세요. /<your-project>/Assets/Plugins/Android/AndroidManifest.xml
을 수정하여BrazeUnityPlayerActivity
하위 클래스를 기본 활동으로 지정합니다.
이제 Braze와 완전히 통합되고 커스텀 UnityPlayerActivity
기능이 포함된 .apk
패키지를 Unity IDE에서 생성할 수 있습니다.
문제 해결
오류: “파일을 읽을 수 없습니다”
다음과 유사한 오류는 안전하게 무시해도 됩니다. Apple 소프트웨어는 Unity가 인식하지 못하는 CgBI라는 독점 PNG 확장을 사용합니다. 이러한 오류는 iOS 빌드나 Braze 번들에서 관련 이미지의 올바른 표시에는 영향을 미치지 않습니다.
1
Could not create texture from Assets/Plugins/iOS/AppboyKit/Appboy.bundle/...png: File could not be read
언리얼 엔진 브레이즈 SDK 소개
Braze 언리얼 SDK 플러그인을 사용하면 가능합니다:
- 앱 또는 게임 내 세션 평가 및 추적
- 인앱 구매 및 맞춤 이벤트 추적
- 표준 및 사용자 지정 속성으로 사용자 프로필 업데이트하기
- 푸시 알림 보내기
- 언리얼 앱을 더 큰 캔버스 여정에 통합
- 인앱 행동을 기반으로 이메일 또는 SMS와 같은 크로스채널 메시징 발송
언리얼 엔진 SDK 통합
1단계: Braze 플러그인 추가
터미널에서 언리얼 엔진 브레이즈 SDK GitHub 리포지토리를 복제합니다.
1
git clone [email protected]:braze-inc/braze-unreal-sdk.git
그런 다음 BrazeSample/Plugins/Braze
디렉토리를 복사하여 앱의 플러그인 폴더에 추가합니다.
2단계: 플러그인 활성화
C++ 또는 블루프린트 프로젝트에 플러그인을 활성화합니다.
C++ 프로젝트의 경우 Braze 모듈을 참조하도록 모듈을 구성하세요. \*.Build.cs file
에서 "Braze"
을 PublicDependencyModuleNames
에 추가합니다.
1
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Braze" });
블루프린트 프로젝트의 경우 설정 > 플러그인으로 이동한 다음 Braze 옆의 Enabled에 체크합니다.
3단계: API 키와 엔드포인트 설정
프로젝트의 DefaultEngine.ini
에서 API 키와 엔드포인트를 설정하세요.
1
2
3
4
5
[/Script/Braze.BrazeConfig]
bAutoInitialize=True ; true by default, initialize when the project starts
AndroidApiKey= ; your API key
IOSApiKey= ; your API key
CustomEndpoint= ; your endpoint
Android SDK 31+ 대상 프로젝트의 경우 언리얼은 Android 12+ 디바이스에서 설치 도중 INSTALL_PARSE_FAILED_MANIFEST_MALFORMED 오류와 함께 실패하는 빌드를 생성합니다. 이 문제를 해결하려면 이 저장소의 루트에서 UE4_Engine_AndroidSDK_31_Build_Fix.patch
git 패치 파일을 찾아 언리얼 소스 빌드에 적용하세요.
선택적 구성
로깅
런타임에 C++를 사용하거나 블루프린트 노드에서 로그 레벨을 설정할 수 있습니다.
런타임에 로그 수준을 설정하려면 UBrazeSubsystem::AndroidSetLogLevel
으로 전화하세요.
1
2
3
UBrazeSubsystem* const BrazeSubsystem = GEngine->GetEngineSubsystem<UBrazeSubsystem>();
BrazeSubsystem->AndroidSetLogLevel(EBrazeLogLevel::Verbose);
UBraze* const BrazeInstance = BrazeSubsystem->InitializeBraze();
블루프린트에서 안드로이드 세트 로그 레벨 노드를 사용할 수 있습니다:
Braze SDK 초기화를 호출할 때 로깅이 설정되도록 하려면 InitializeBraze
전에 이 함수를 호출하는 것이 좋습니다.
info.plist
에서 로그 수준을 활성화하려면 설정 > 프로젝트 설정으로 이동한 다음 플랫폼에서 iOS를 선택합니다. 추가 목록 데이터에서 추가 목록 데이터를 찾은 다음 로그 레벨을 입력합니다:
1
2
3
4
5
<key>Appboy</key>
<dict>
<key>LogLevel</key>
<string>0</string>
</dict>
기본 로그 수준은 최소 로깅 수준인 8입니다. 로그 수준에 대해 자세히 알아보세요: 기타 SDK 사용자 지정
Integrating the Xamarin SDK
Integrating the Braze Xamarin SDK will provide you with basic analytics functionality as well as working in-app messages with which you can engage your users.
Prerequisites
Before you can integrate the Xamarin Braze SDK, be sure you meet the following requirements:
- Starting in
version 3.0.0
, this SDK requires using .NET 6+ and removes support for projects using the Xamarin framework. - Starting in
version 4.0.0
, this SDK dropped support for Xamarin & Xamarin.Forms and added support for .NET MAUI. See Microsoft’s policy around the end of support for Xamarin.
Step 1: Get the Xamarin binding
A Xamarin binding is a way to use native libraries in Xamarin apps. The implementation of a binding consists of building a C# interface to the library, and then using that interface in your application. See the Xamarin documentation. There are two ways to include the Braze SDK binding: using NuGet or compiling from source.
The simplest integration method involves getting the Braze SDK from the NuGet.org central repository. In the Visual Studio sidebar, right click Packages
folder and click Add Packages...
. Search for ‘Braze’ and install the BrazePlatform.BrazeAndroidBinding
package into your project.
The second integration method is to include the binding source. Under appboy-component/src/androidnet6
you will find our binding source code; adding a project reference to the BrazeAndroidBinding.csproj
in your Xamarin application will cause the binding to be built with your project and provide you access to the Braze Android SDK.
The iOS bindings for Xamarin SDK version 4.0.0 and later use the Braze Swift SDK, while previous versions use the legacy AppboyKit SDK.
A Xamarin binding is a way to use native libraries in Xamarin apps. The implementation of a binding consists of building a C# interface to the library and then using that interface in your application. There are two ways to include the Braze SDK binding: using NuGet or compiling from source.
The simplest integration method involves getting the Braze SDK from the NuGet.org central repository. In the Visual Studio sidebar, right-click Packages
folder and click Add Packages...
. Search for ‘Braze’ and install the latest Xamarin iOS NuGet packages: Braze.iOS.BrazeKit, Braze.iOS.BrazeUI, and Braze.iOS.BrazeLocation into your project.
We also provide the compatibility libraries packages: Braze.iOS.BrazeKitCompat and Braze.iOS.BrazeUICompat, to help make your migration to .NET MAUI easier.
The second integration method is to include the binding source. Under appboy-component/src/iosnet6
you will find our binding source code; adding a project reference to the BrazeiOSBinding.csproj
in your Xamarin application will cause the binding to be built with your project and provide you access to the Braze iOS SDK. Make sure BrazeiOSBinding.csproj
is showing in your project’s “Reference” folder.
Step 2: Configure your Braze instance
Step 2.1: Configure the Braze SDK in Braze.xml
Now that the libraries have been integrated, you have to create an Braze.xml
file in your project’s Resources/values
folder. The contents of that file should resemble the following code snippet:
Be sure to substitute YOUR_API_KEY
with the API key located at Settings > API Keys in the Braze dashboard.
If you are using the older navigation, you can find API keys at Developer Console > API Settings..
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string translatable="false" name="com_braze_api_key">YOUR_API_KEY</string>
<string translatable="false" name="com_braze_custom_endpoint">YOUR_CUSTOM_ENDPOINT_OR_CLUSTER</string>
<string-array name="com_braze_internal_sdk_metadata">
<item>XAMARIN</item>
<item>NUGET</item>
</string-array>
</resources>
If you are including the binding source manually, remove <item>NUGET</item>
from your code.
To see an example Braze.xml
, check out our Android MAUI sample app.
Step 2.2: Add required permissions to Android manifest
Now that you’ve added your API key, you need to add the following permissions to your AndroidManifest.xml
file:
1
<uses-permission android:name="android.permission.INTERNET" />
For an example of your AndroidManifest.xml
, see the Android MAUI sample application.
Step 2.3: Track user sessions and registering for in-app messages
To enable user session tracking and register your app for in-app messages, add the following call to the OnCreate()
lifecycle method of the Application
class in your app:
1
RegisterActivityLifecycleCallbacks(new BrazeActivityLifecycleCallbackListener());
When setting up your Braze instance, add the following snippet to configure your instance:
Be sure to substitute YOUR_API_KEY
with the API key located at Settings > API Keys in the Braze dashboard.
If you are using the older navigation, you can find API keys at Developer Console > API Settings..
1
2
3
var configuration = new BRZConfiguration("YOUR_API_KEY", "YOUR_ENDPOINT");
configuration.Api.AddSDKMetadata(new[] { BRZSDKMetadata.Xamarin });
braze = new Braze(configuration);
See the App.xaml.cs
file in the iOS MAUI sample application.
Step 3: Test the integration
Now you can launch your application and see sessions being logged to the Braze dashboard (along with device information and other analytics). For a more in-depth discussion of best practices for the basic SDK integration, consult the Android integration instructions.
Now you can launch your application and see sessions being logged to the Braze dashboard. For a more in-depth discussion of best practices for the basic SDK integration, consult the iOS integration instructions.
Our current public Xamarin binding for the iOS SDK does not connect to the iOS Facebook SDK (linking social data) and does not include sending the IDFA to Braze.
SDK 통합에 대한 QA를 수행하는 동안 SDK 디버거를 사용하면 앱에 대한 자세한 로깅을 켜지 않고도 문제를 해결할 수 있습니다.