콘텐츠 카드의 딥링킹
Braze SDK를 사용하여 콘텐츠 카드 내에서 딥링크하는 방법을 알아보세요. 딥링크에 대해 더 알아보려면 딥링킹이란?을 확인하세요.
Prerequisites
이 기능을 사용하려면 먼저 Android Braze SDK를 통합해야 합니다.
범용 대리인 만들기
Android SDK는 콘텐츠 카드, 인앱 메시지, 푸시 알림에서 Braze가 여는 모든 딥링크를 사용자 지정 처리하도록 단일 위임 오브젝트를 설정할 수 있는 기능을 제공합니다.
위임 오브젝트는 IBrazeDeeplinkHandler
인터페이스를 구현하고 BrazeDeeplinkHandler.setBrazeDeeplinkHandler()
를 사용하여 설정해야 합니다. 대부분의 경우 위임은 앱의 Application.onCreate()
에서 설정해야 합니다.
다음은 YouTube URL의 커스텀 동작 및 커스텀 의도 플래그로 기본 UriAction
동작을 재정의하는 예제입니다.
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
34
35
36
37
38
public class CustomDeeplinkHandler implements IBrazeDeeplinkHandler {
private static final String TAG = BrazeLogger.getBrazeLogTag(CustomDeeplinkHandler.class);
@Override
public void gotoNewsFeed(Context context, NewsfeedAction newsfeedAction) {
newsfeedAction.execute(context);
}
@Override
public void gotoUri(Context context, UriAction uriAction) {
String uri = uriAction.getUri().toString();
// Open YouTube URLs in the YouTube app and not our app
if (!StringUtils.isNullOrBlank(uri) && uri.contains("youtube.com")) {
uriAction.setUseWebView(false);
}
CustomUriAction customUriAction = new CustomUriAction(uriAction);
customUriAction.execute(context);
}
public static class CustomUriAction extends UriAction {
public CustomUriAction(@NonNull UriAction uriAction) {
super(uriAction);
}
@Override
protected void openUriWithActionView(Context context, Uri uri, Bundle extras) {
Intent intent = getActionViewIntent(context, uri, extras);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent);
} else {
BrazeLogger.w(TAG, "Could not find appropriate activity to open for deep link " + uri + ".");
}
}
}
}
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
34
class CustomDeeplinkHandler : IBrazeDeeplinkHandler {
override fun gotoNewsFeed(context: Context, newsfeedAction: NewsfeedAction) {
newsfeedAction.execute(context)
}
override fun gotoUri(context: Context, uriAction: UriAction) {
val uri = uriAction.uri.toString()
// Open YouTube URLs in the YouTube app and not our app
if (!StringUtils.isNullOrBlank(uri) && uri.contains("youtube.com")) {
uriAction.useWebView = false
}
val customUriAction = CustomUriAction(uriAction)
customUriAction.execute(context)
}
class CustomUriAction(uriAction: UriAction) : UriAction(uriAction) {
override fun openUriWithActionView(context: Context, uri: Uri, extras: Bundle) {
val intent = getActionViewIntent(context, uri, extras)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
if (intent.resolveActivity(context.packageManager) != null) {
context.startActivity(intent)
} else {
BrazeLogger.w(TAG, "Could not find appropriate activity to open for deep link $uri.")
}
}
}
companion object {
private val TAG = BrazeLogger.getBrazeLogTag(CustomDeeplinkHandler::class.java)
}
}
앱 설정에 대한 딥링킹
딥링크에서 앱 설정을 바로 열 수 있도록 하려면 커스텀 BrazeDeeplinkHandler
가 필요합니다. 다음 예제에서는 open_notification_page
라는 커스텀 키-값 페어를 통해 딥링크에서 앱 설정 페이지를 엽니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
BrazeDeeplinkHandler.setBrazeDeeplinkHandler(new IBrazeDeeplinkHandler() {
@Override
public void gotoUri(Context context, UriAction uriAction) {
final Bundle extras = uriAction.getExtras();
if (extras.containsKey("open_notification_page")) {
Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//for Android 5-7
intent.putExtra("app_package", context.getPackageName());
intent.putExtra("app_uid", context.getApplicationInfo().uid);
// for Android 8 and later
intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName());
context.startActivity(intent);
}
}
@Override
public void gotoNewsFeed(Context context, NewsfeedAction newsfeedAction) {}
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
BrazeDeeplinkHandler.setBrazeDeeplinkHandler(object : IBrazeDeeplinkHandler {
override fun gotoUri(context: Context, uriAction: UriAction) {
val extras = uriAction.extras
if (extras.containsKey("open_notification_page")) {
val intent = Intent()
intent.action = "android.settings.APP_NOTIFICATION_SETTINGS"
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
//for Android 5-7
intent.putExtra("app_package", context.packageName)
intent.putExtra("app_uid", context.applicationInfo.uid)
// for Android 8 and later
intent.putExtra("android.provider.extra.APP_PACKAGE", context.packageName)
context.startActivity(intent)
}
}
override fun gotoNewsFeed(context: Context, newsfeedAction: NewsfeedAction) {}
})
뉴스피드에 대한 딥링킹
News Feed is being deprecated. We recommend migrating to our Content Cards messaging channel instead—it’s more flexible, customizable, and reliable. To get started, check out Migrating from News Feed.
푸시 알림에서 Braze 뉴스피드에 딥링크를 연결하려면 뉴스피드 활동에 대한 사용자 지정 딥링크를 생성하세요.
그런 다음, 대시보드 또는 API를 통해 푸시 알림 캠페인을 설정할 때 알림이 뉴스피드 딥링크로 이동하도록 구성합니다.
WebView 활동 사용자 지정
기본적으로, 웹사이트 딥링크가 Braze에 의해 앱 내부에서 열리면 BrazeWebViewActivity
에 의해 처리됩니다. 이를 변경하려면:
com.braze.Constants.BRAZE_WEBVIEW_URL_EXTRA
키를 사용하여Intent.getExtras()
에서 대상 URL을 처리하는 새 활동을 생성합니다. 예를 보려면BrazeWebViewActivity.java
.- 해당 활동을
AndroidManifest.xml
에 추가하고exported
를false
로 설정합니다.1 2 3
<activity android:name=".MyCustomWebViewActivity" android:exported="false" />
BrazeConfig
빌더 객체에서 사용자 지정 활동을 설정합니다. 빌더를 빌드하여Braze.configure()
에 전달하고Application.onCreate()
.
1
2
3
4
5
BrazeConfig brazeConfig = new BrazeConfig.Builder()
.setCustomWebViewActivityClass(MyCustomWebViewActivity::class)
...
.build();
Braze.configure(this, brazeConfig);
1
2
3
4
5
val brazeConfig = BrazeConfig.Builder()
.setCustomWebViewActivityClass(MyCustomWebViewActivity::class.java)
...
.build()
Braze.configure(this, brazeConfig)
제트팩 컴포지트 사용
NavHost와 함께 젯팩 컴포즈를 사용할 때 딥링크를 처리합니다:
- 디링크를 처리하는 활동이 Android 매니페스트에 등록되어 있는지 확인하세요.
1 2 3 4 5 6 7 8 9 10 11
<activity ... <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="articles" android:scheme="myapp" /> </intent-filter> </activity>
- NavHost에서 처리할 딥링크를 지정합니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
composableWithCompositionLocal( route = "YOUR_ROUTE_HERE", deepLinks = listOf(navDeepLink { uriPattern = "myapp://articles/{${MainDestinations.ARTICLE_ID_KEY}}" }), arguments = listOf( navArgument(MainDestinations.ARTICLE_ID_KEY) { type = NavType.LongType } ), ) { backStackEntry -> val arguments = requireNotNull(backStackEntry.arguments) val articleId = arguments.getLong(MainDestinations.ARTICLE_ID_KEY) ArticleDetail( articleId ) }
- 앱 아키텍처에 따라 현재 활동으로 전송되는 새 인텐트도 처리해야 할 수 있습니다.
1 2 3 4 5 6 7
DisposableEffect(Unit) { val listener = Consumer<Intent> { navHostController.handleDeepLink(it) } addOnNewIntentListener(listener) onDispose { removeOnNewIntentListener(listener) } }
guide/swift/deep_linking.md developer_ %}
현재 콘텐츠 카드 딥링크는 웹 Braze SDK에서 지원되지 않습니다.