인앱 라우팅
Overview
When a Branch link is opened, either your app launches or users are taken to the App/Play store to download it. Deep links improve this process by routing users directly to specific content after your app launches. With Branch, this works even if users have to stop and download the app first (a.k.a., "deferred deep links"). Deep links are an incredibly important part of delivering a high-quality user experience.
아래에서 3가지 설정 옵션을 확인하십시오.
- 옵션 1 : 라우팅 콜백 내에서 커스텀 라우팅 구현하기 - 앱이 실행되면 즉시 라우팅
- 옵션 2: Branch에서 기존 딥링크(Deep Link) 라우팅을 사용하도록 설정
iOS Deferred Deep Linking
With the introduction of iOS 15 and iCloud+ Private Relay, Branch released support for deferred deep linking using NativeLink™
To implement iOS NativeLink™, follow the instructions in our developer documentation.
옵션 1: 라우팅 콜백 내에서 커스텀 라우팅 구현하기
앱이 오픈되면 즉시 라우팅
Inside the deep link handler callback that you register in initSession, you will want to examine the parameters dictionary to determine whether the user opened a Branch link. Below is an example assuming that the links correspond to pictures. Below are some examples from iOS and Android where we're using the pictureId
key to route, but you can see more code snippets for the other platforms here.
iOS
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// initialize the session, setup a deep link handler
[[Branch getInstance] initSessionWithLaunchOptions:launchOptions
andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {
// start setting up the view controller hierarchy
UINavigationController *navC = (UINavigationController *)self.window.rootViewController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *nextVC;
// If the key 'pictureId' is present in the deep link dictionary
// then load the picture screen with the appropriate picture
NSString *pictureId = [params objectForKey:@"pictureId"];
if (pictureId) {
nextVC = [storyboard instantiateViewControllerWithIdentifier:@"PicVC"];
[nextVC setNextPictureId:pictureId];
} else {
nextVC = [storyboard instantiateViewControllerWithIdentifier:@"MainVC"];
}
// navigate!
[navC setViewControllers:@[nextVC] animated:YES];
}];
return YES;
}
Android
@Override
public void onStart() {
super.onStart();
Branch.sessionBuilder(this).withCallback(new BranchReferralInitListener(){
@Override
public void onInitFinished(JSONObject referringParams, Branch.BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked before showing up
// params will be empty if no data found
String pictureID = referringParams.optString(""picture_id"", """");
if (pictureID.equals("""")) {
startActivity(new Intent(this, HomeActivity.class));
}
else {
Intent i = new Intent(this, ViewerActivity.class);
i.putExtra(""picture_id"", pictureID);
startActivity(i);
}
} else {
Log.e(""MyApp"", error.getMessage());
}
}
}).withData(this.getIntent().getData()).init();
}
Branch로 추가된 파라미터
링크 데이터 딕셔너리에 추가된 커스텀 키/값 쌍 외에, Branch에서 매번 세션이 초기화될 때마다 추가로 반환하는 유용한 파라미터도 있습니다. 이러한 파라미터는 유저가 Branch 링크를 클릭하지 않았더라도 세션이 초기화 될 때마다 반환됩니다. 다음은 목록과 각 항목에 대한 설명입니다.
~
분석을 나타냄+
Branch에서 추가한 정보를 나타냅니다.- 이 데이터는 Facebook 또는 기타 셀프 어트리뷰팅 네트워크(SAN)을 통한 딥링크에 사용할 수 없습니다.
- For the curious, $ denotes reserved keywords used for controlling how the Branch service behaves. Read more about control parameters on the Configuring Links page
파라미터 | 의미 |
---|---|
+is_first_session | 이것이 첫번째 세션 (설치)인지 또는 다른 세션 (재설치, 오픈)인지 표시합니다. |
+clicked_branch_link | 유저가 이 세션을 시작하는 Branch 링크를 클릭했는지 여부를 표시합니다. |
+match_guaranteed | 100% 정확도로 매치가 이루어졌는지에 대한 참 또는 거짓입니다. |
+referrer | 링크를 클릭한 경우 링크 클릭에 대한 리퍼러(Referrer) |
+click_timestamp | 클릭이 발생한 시점의 타임스탬프 시점 |
+url | 설치/오픈을 유도한 링크의 전체 URL (예: yourapp.app.link/abcde12345) |
~channel | 링크 생성 시 지정된, 링크가 공유된 채널 |
~feature | Branch Link 에 설정한 feature 값(예.invite,share)이고 링크 생성 때 지정됩니다. |
~tags | 링크 생성시 지정한 모든 태그 |
~campaign | 링크 생성 시간에 지정된, 링크와 연관된 캠페인 |
~creation_source | 링크 생성 장소 ( 'API', 'Dashboard', 'SDK', 'iOS SDK', 'Android SDK' 또는 'Web SDK') |
~id | 설치/열기를 유도한 Branch 링크에 대해 자동으로 생성된 18자리 ID 번호 (동적 및 3P 링크의 경우 0) |
나중에 딥링크(Deep Link) 파라미터에 액세스
아래 방법 중 하나를 호출하여 Branch 싱글톤에서 언제든지 딥링크 (Deep Link) 데이터를 검색할 수 있습니다. 이는 유저가 로그인하도록 프롬프트를 표시한 후 유저를 딥링크 (Deep Link)하려는 경우 사용할 경로입니다. 여기에서 다른 플랫폼의 코드 스니펫을 볼 수 있습니다.
가장 최근 세션의 리퍼링(Referring) 파라미터를 가져오기
이는 클릭한 최신 링크의 최신 딥링크(Deep Link) 데이터 세트를 리턴합니다. 앱을 최소화하고 다시 오픈하면 세션과 이 데이터가 지워집니다.
iOS
NSDictionary *params = [[Branch getInstance] getLatestReferringParams];
Android
JSONObject sessionParams = Branch.getInstance().getLatestReferringParams();
첫 세션의 리퍼링(Referring) 파라미터 가져오기
이는 유저를 리퍼드한 첫 번째 딥링크(Deep Link) 데이터 세트를 리턴합니다. 지정된 유저에 대해 설정되면 다시 업데이트할 수 없습니다. 이것은 리퍼럴 프로그램에 유용합니다.
iOS
NSDictionary *params = [[Branch getInstance] getFirstReferringParams];
Android
JSONObject installParams = Branch.getInstance().getFirstReferringParams();
옵션 2: Branch에서 기존 딥링크(Deep Link) 라우팅을 사용하도록 설정
If your app already supports deep linking using URI paths, you can populate the $deeplink_path
, $ios_deeplink_path
or $android_deeplink_path
link parameters with the URI path of the content to be displayed within the app. When the Branch SDK receives a link containing one of these parameters, it will automatically load the specified URI path.
iOS에서 불완전한 서포트
Universal Links and Spotlight do not support deep linking via URI paths. If you use
$deeplink_path
or$ios_deeplink_path
, you will need to implement some custom logic. Click here for more information.
Branch 링크에 커스텀 딥링크(Deep Link) 경로를 삽입하는 방법
All of the examples below create links that will cause Branch to display myapp://content/1234
after launch. Please do not add the URI scheme on the $deeplink_path
parameters; we automatically append the scheme specified in the Configuration page of the dashboard.
다이나믹하게 링크를 생성할 경우
쿼리 파라미터를 추가하여 링크를 생성하는 경우 제어 파라미터를 URL에 추가하기만 하면 됩니다. 모든 값을 URL 인코딩하시기 바랍니다.
"https://[branchsubdomain]?%24deeplink_path=content%2F1234"
모바일 SDK를 사용하여 링크를 생성하는 경우
iOS
BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
linkProperties.feature = @"sharing";
linkProperties.channel = @"facebook";
[linkProperties addControlParam:@"$deeplink_path" withValue:@"content/1234"];
Android
LinkProperties linkProperties = new LinkProperties()
.setChannel("facebook")
.setFeature("sharing")
.addControlParameter("$deeplink_path", "content/1234");
Branch 대시보드에서 Quick Links를 생성할 때
Deep Link Data (고급) 섹션에 해당 키와 값을 삽입하여 개별 Quick Link에 대한 제어 파라미터를 지정할 수 있습니다.
유니버설 링크(Universal Links) 또는 앱 링크(App Links)로 URI 경로를 처리하는 방법
Because Universal Links, Spotlight and Android App Links do not use URI schemes for deep link routing. If you populate $deeplink_path
, $ios_deeplink_path
or $android_deeplink_path
with a URI path, you will need to a bit of additional work to ensure that Branch links route according to your original schema.
- Branch SDK 세션을 앱 설정 단계에 설명된 것처럼 초기화합니다.
- In the callback function, add some custom code to read the appropriate
$deeplink_path
parameter in theparams
- 이 값을 사용하여 기존 라우팅 로직을 호출하여 유저를 앱에서 올바른 위치로 라우팅합니다.
Now whenever your app launches from a Branch link that has the product_picture
key set in its data dictionary, this Activity will be displayed!
Updated 13 days ago