푸시 알림 지원
푸시 알림을 통해 사용자 상호작용을 추적하여 리인게이지먼트 캠페인과 어트리뷰션 전환을 정확하게 측정할 수 있도록 Apple 푸시 알림 서비스(APN)를 Singular SDK와 연동하세요.
아래 구현 가이드라인에 따라 알림 데이터가 적절한 어트리뷰션을 위해 Singular SDK에 올바르게 전달되도록 하세요.
푸시 알림을 추적해야 하는 이유: 푸시 알림은 리인게이지먼트를 유도하지만 추적을 위해서는 올바른 연동이 필요합니다. Singular는 알림과 상호작용하는 사용자의 어트리뷰션을 적절히 추적하여 마케팅 캠페인과 참여 전략을 최적화합니다.
구현 가이드
푸시 알림 등록
사용자에게 푸시 알림 수신을 위한 권한을 요청하고 odedeUNUserNotificationCenter를 사용하여 앱을 APN에 등록합니다.
import UserNotifications
// Set the current instance as the delegate for UNUserNotificationCenter
UNUserNotificationCenter.current().delegate = self
// Define the notification authorization options (alert, badge, sound)
let pushAuthOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
// Request notification authorization from the user
UNUserNotificationCenter.current().requestAuthorization(options: pushAuthOptions) { granted, error in
// If an error occurs during authorization, print the error description
if let error = error {
print("registerForPushNotifications : failure - \(error.localizedDescription)")
}
// If the user granted permission, register for remote notifications
if granted {
// Ensure registration is done on the main thread
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
- (void)registerForPushNotifications:(UIApplication *)application {
// Set delegate to self
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
// Define the push notification options
UNAuthorizationOptions pushAuthOptions = UNAuthorizationOptionAlert |
UNAuthorizationOptionBadge |
UNAuthorizationOptionSound;
// Request push notification authorization
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:pushAuthOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (error) {
NSLog(@"registerForPushNotifications : failure - %@", error.localizedDescription);
}
if (granted) {
dispatch_async(dispatch_get_main_queue(), ^{
[application registerForRemoteNotifications];
});
}
}];
}
모범 사례: 앱 라이프사이클 초기에 사용자에게 가치를 입증한 후 알림 승인을 요청하여 옵트인 비율을 높이는 것이 좋습니다.
알림 응답 처리
사용자가 푸시 알림을 탭할 때 알림 응답을 처리하고 추적을 위해 페이로드 데이터를 Singular로 전달합니다.
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
// Extract the notification payload
let userInfo = response.notification.request.content.userInfo
// Pass the notification data to Singular for tracking
Singular.handlePushNotification(userInfo)
// Call the completion handler to indicate processing is complete
completionHandler()
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
// Extract the push notification payload (user info)
NSDictionary *userInfo = response.notification.request.content.userInfo;
// Log the userInfo dictionary for debugging purposes
NSLog(@"didReceiveNotificationResponse userInfo = %@", userInfo);
// Pass the notification data to Singular for tracking
[Singular handlePushNotification:userInfo];
// Call the completion handler to indicate processing is complete
completionHandler();
}
모범 사례: 항상 즉시 완료 핸들러를 호출하여 시스템이 알림 처리가 완료되었음을 알 수 있도록 하세요. 완료가 지연되면 시스템 중요 또는 스로틀링이 발생할 수 있습니다.
푸시 페이로드를 위한 SDK 구성
푸시 알림 페이로드 선택기를 SDK 구성에 추가하여 알림 데이터 구조에서 Singular 링크의 위치를 지정하세요.
func getConfig() -> SingularConfig? {
guard let config = SingularConfig(apiKey: "SDK_KEY", andSecret: "SDK_SECRET") else {
return nil
}
// Configure push notification link paths
config.pushNotificationLinkPath = [
["sng_link"],
["rootObj", "nestedObj", "anotherNested", "singularLink"]
]
return config
}
// Start the Singular SDK with the configuration
if let config = getConfig() {
Singular.start(config)
}
- (SingularConfig *)getConfig {
SingularConfig *config = [[SingularConfig alloc] initWithApiKey:@"SDK_KEY"
andSecret:@"SDK_SECRET"];
// Configure push notification link paths
config.pushNotificationLinkPath = @[
@[@"sng_link"],
@[@"rootObj", @"nestedObj", @"anotherNested", @"singularLink"]
];
return config;
}
// Start the Singular SDK with the configuration
SingularConfig *config = [self getConfig];
[Singular start:config];
선택기 구성:
-
단순 키: 페이로드의 최상위 키에
["sng_link"]사용 - 중첩 키: 중첩된 JSON 구조를 트래버스하려면 odede["rootObj", "nestedObj", "key"]를 사용합니다.
- 다중 경로: 여러 선택기 배열을 정의하여 Singular 링크에 대해 가능한 여러 위치를 확인합니다.
유효성 검사 가이드
시작 세션에서 페이로드 확인
시작 세션 API 호출을 검사하여 푸시 알림 링크가 Singular에 올바르게 전달되었는지 확인합니다.
Singular SDK는 사용자가 알림을 탭할 때 시작 세션 요청의 singular_link 매개변수 아래에 푸시 알림 페이로드를 포함합니다.
세션 시작 요청 예시:
https://skan.singular.net:443/api/v1/start?
dnt=-1
&update_time=0
&singular_link=https://sl.sng.link/Cclbu/2a7n?_dl=com.singular.app&_smtype=3
&i=com.singular.SwiftScene
&sdk=Singular/12.7.1
&p=iOS
&v=18.2.1
대체 인증: Singular SDK 콘솔을 사용하여 푸시 알림 추적을 확인합니다. 딥링크 URL 필드를 확인하여 추적 링크가 올바르게 캡처되었는지 확인합니다.
고급 구성
ESP 도메인 구성
이메일 서비스 제공업체(ESP) 또는 기타 타사 도메인 내에 Singular 링크를 래핑하는 경우 외부 도메인을 구성합니다.
func getConfig() -> SingularConfig? {
guard let config = SingularConfig(apiKey: "SDK_KEY", andSecret: "SDK_SECRET") else {
return nil
}
// Configure ESP domains for wrapped links
config.espDomains = ["sl.esp.link", "custom.domain.com"]
return config
}
- (SingularConfig *)getConfig {
SingularConfig *config = [[SingularConfig alloc] initWithApiKey:@"SDK_KEY"
andSecret:@"SDK_SECRET"];
// Configure ESP domains for wrapped links
config.espDomains = @[@"sl.esp.link", @"custom.domain.com"];
return config;
}
보안 참고: 기본적으로 Singular 링크 관리 페이지에 미리 정의된 sng.link도메인만 허용됩니다. 래핑된 링크를 사용하는 경우 ESP 도메인을 명시적으로 구성하세요.
동적 딥링크 라우팅
동적 리디렉션 재정의가 있는 하나의 Singular 추적 링크를 구성하여 Singular 알림에서 여러 개의 딥링크 대상을 구현하세요.
사용 사례 예시: 여러 가지 액션 옵션이 포함된 속보 알림
-
최신 뉴스 읽기:
newsapp://article?id=12345 -
인기 토픽:
newsapp://trending -
스포츠:
newsapp://sports
여러 개의 추적 링크를 만드는 대신 하나의 Singular 링크를 사용하고 사용자 선택에 따라 리디렉션을 동적으로 재정의하세요. 구현에 대한 자세한 내용은 Singular 추적 링크에서 리디렉션 재정의하기를 참조하세요.
중요 고려 사항
구현 참고 사항
-
콜백 핸들러 없음:
singularLinksHandler과 달리 푸시 알림 기능은 페이로드 콜백을 제공하지 않습니다. 자체 딥링킹 로직을 구현하여 사용자를 앱 내의 특정 콘텐츠로 라우팅하세요. -
어트리뷰션 흐름: 사용자가 알림을 탭하면 Singular는 페이로드를 검색하여
Singular.start()에 의해 트리거된 시작 세션 이벤트에 포함합니다. 백엔드는 이 데이터를 처리하여 푸시 알림 터치포인트를 어트리뷰션하고 리인게이지먼트 추적을 등록합니다. -
도메인 제한: 링크 관리 페이지의 Singular 링크 도메인(
sng.link)만 기본적으로 허용됩니다.espDomains을 사용하여 래핑된 링크에 대해 명시적으로 ESP 도메인을 구성합니다.
성공: 이 단계를 수행하면 이제 앱이 Singular와 푸시 알림 상호 작용을 추적하여 캠페인 성과 인사이트를 개선하고 정확한 리인게이지먼트 어트리뷰션을 보장할 수 있습니다.