푸시 알림 지원

문서

푸시 알림을 이용한 리인게이지먼트 추적 지원

Singular는 리인게이지먼트 측정을 향상시키기 위해 푸시 알림 추적을 지원합니다. Firebase 클라우드 메시징(FCM)을 Singular SDK와 연동하면 푸시 알림과 상호 작용하는 사용자를 추적하고 그에 따라 어트리뷰션할 수 있습니다.

정확한 추적을 위해 아래의 구현 가이드라인을 따르고 알림 데이터가 Singular SDK에 올바르게 전달되었는지 확인하세요.

푸시 알림 추적이 중요한 이유는 무엇인가요?

푸시 알림은 핵심적인 리인게이지먼트 도구이지만, 이를 추적하려면 올바른 연동이 필요합니다. Singular는 알림과 상호작용하는 사용자의 어트리뷰션이 제대로 이루어지도록 보장하여 마케팅 캠페인과 참여 전략을 최적화하는 데 도움을 줍니다.


구현 가이드

1단계: Firebase 클라우드 메시징(FCM) 알림 처리하기

앱이 Firebase로부터 푸시 알림을 받으면 onMessageReceived() 메서드가 트리거됩니다. Singular에서 알림을 추적하려면 이 메서드를 업데이트하여 알림 데이터를 처리합니다.

예시:

JavaKotlin
@Override
public void onMessageReceived(@NonNull RemoteMessage message) {
    super.onMessageReceived(message);
    String title = "";
    String body = "";

    if (message.getNotification() != null) {
        Log.d("===singular-app", message.getNotification().toString());
        title = message.getNotification().getTitle();
        body = message.getNotification().getBody();
    }

    Map<String, String> data = message.getData(); // Fixed the incorrect Map generic type

    if (!data.isEmpty()) {
        Log.d("===singular-app", data.toString());
    }
    // Implement processNotification method to forward payload data to intent

    processNotification(title, body, data);
}

이렇게 하면 모든 관련 푸시 데이터가 캡처되어 처리를 위해 전달됩니다.


2단계: 푸시 알림 처리 및 Singular로 데이터 전달하기

알림이 수신되면 Singular가 초기화되는 주요 활동을 시작하는 인텐트로 데이터를 전달하는 것이 중요합니다.

예시:

JavaKotlin
private void processNotification(String title, String body, Map<String, String> data) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

    // Attach notification data to the intent

    for (Map.Entry<String, String> entry : data.entrySet()) {
        intent.putExtra(entry.getKey(), entry.getValue());
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(
            this, 
            0, 
            intent, 
            PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE // Added FLAG_IMMUTABLE for API 31+

    );

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "your_channel_id")
            .setSmallIcon(R.drawable.info_btn)
            .setContentTitle(title)
            .setContentText(body)
            .setPriority(NotificationCompat.PRIORITY_HIGH) // Optional: Set priority for better visibility

            .setAutoCancel(true)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    if (notificationManager != null) {
        notificationManager.notify(0, notificationBuilder.build());
    }
}

이렇게 하면 사용자가 알림을 탭할 때 올바른 추적 데이터가 포함된 적절한 활동으로 연결됩니다.


3단계: 푸시 알림 페이로드를 Singular SDK와 연동하기

마지막으로, 푸시 알림 페이로드가 올바르게 전달되고 처리되도록 Singular SDK 구성을 업데이트합니다.

예시:

JavaKotlin
String[][] pushSelectors = {
        {"sng_link"},
        {"rootObj", "nestedObj", "anotherNested", "singularLink"}
};

config.withPushNotificationPayload(intent, pushSelectors);

Singular.init(context, config);

이 단계에서는 어트리뷰션 목적으로 푸시 알림 참여를 올바르게 추적할 수 있습니다.


유효성 검사 가이드

4단계: 세션 시작 호출에서 푸시 알림 수신 유효성 검사/확인하기

Singular SDK API 호출은 푸시 알림 페이로드 링크가 시작 세션 호출의 singular_link 예약 매개변수 아래에 올바르게 전달되었는지 확인합니다.

예시:

https://sdk-api-v1.singular.net/api/v1/start?a=<SDK-Key>&ab=arm64-v8a&aifa=180f63a1-0955-47b4-896a-d75ae3d35955&apc=Marchv7&apg=1&aps=Intex&asid_scope=1&asid_timeinterval=0.112&av=20.0&br=samsung&c=wifi&current_device_time=1740905574088&de=m15x&device_type=phone&device_user_agent=Dalvik/2.1.0 (Linux; U; Android 14; SM-E156B Build/UP1A.231005.007)&dnt=0&event_index=3&fi=e5bRZuVddO8:APA91bHXI3OmFZv3-r8f03zyji2kvKWbIngwf8KBDHk4Rj5q5MEeEm6EtzC-if1vpJRmuYLyGdAcSz9-nc49eIjD86xwj-n9J4jKucqMVt9mP8ICifP0arA&i=net.singular.singularsampleapp&install_time=1740905507036&is=false&k=SDID&lag=0.067&lc=en_IN&ma=samsung&mo=SM-E156B&n=Singular-TestApp-Debug&p=Android&pr=m15xnndins&pu=1&rt=json&s=1740905574084&sdk=Singular/v12.6.2&singular_install_id=2dc5dfc2-a2a8-484a-aad1-fed6cb7a3023&singular_link=https://singularassist2.sng.link/C4nw9/r1m0?_dl=singular://test&_smtype=3&src=com.android.shell&u=75f7b911-5a77-597d-8892-56f5e0e210ff&update_time=1740905507036&v=14&h=1e723fd90344d5d037059f110611ed1d84fbba88


또는 아래 예시처럼 Singular SDK 콘솔을 사용하여 딥링크 URL 아래의 푸시 알림 추적 링크를 확인할 수 있습니다.

이를 확인하면 푸시 알림 인게이지먼트가 Singular SDK 내에서 올바르게 추적되는지 확인할 수 있습니다.

참고:

  • withSingularLink 핸들러 코드와 달리 Singular SDK는 이 기능에 대한 푸시 페이로드 콜백을 제공하지 않는다는 점에 유의하세요. 푸시 알림 데이터를 읽고 딥링킹 로직을 구현하여 사용자를 앱 내의 특정 제품 페이지로 리디렉션하는 것은 앱 개발자의 책임입니다. 이 솔루션에서 Singular는 사용자가 알림을 탭할 때 푸시 알림 페이로드를 검색하고 Singular.init() 에 의해 트리거되는 SDK 시작 세션 이벤트에 이 페이로드를 포함합니다. 그런 다음 이 데이터는 Singular 백엔드에서 처리되어 푸시 알림 터치포인트/클릭에 어트리뷰션을 부여하고 리인게이지먼트 추적을 위해 등록됩니다.
  • 푸시 알림 페이로드에 전달된 사용자 지정 키 값 쌍의 Singular 링크 도메인만 허용하는 안전 메커니즘이 마련되어 있습니다. 구체적으로, Singular 링크 관리 페이지에서 미리 정의된 sng.link 도메인만 허용됩니다.

    예를 들어
    https://prod_test.sng.link/B0s2a/51oi?_dl=singular%3A%2F%2Fmain

    다른 도메인(예: 이메일 서비스 제공업체의 ESP 도메인 ) 내에서 Singular 링크를 래핑하려는 경우 설정에서 다음 옵션을 추가하여 도메인을 명시적으로 구성해야 합니다: 이렇게 하면 외부 도메인이 Singular 프레임워크 내에서 인식되고 허용됩니다. 아래 구성 예시를 참조하세요. config.withESPDomains(Arrays.asList("sl.esp.link")) ;

  • 하나의 푸시 알림에서 사용자 행동에 따라 다른 딥링크를 트리거해야 하는 경우, Singular Singular 추적 링크를 사용하여 리디렉션을 동적으로 수정할 수 있습니다.

    예시:

    속보에 대한 푸시 알림에 여러 개의 딥링크 옵션을 제공할 수 있습니다! 여러 개의 트래킹 링크를 만드는 대신 하나의 Singular 트래킹 링크를 구성하고 사용자 선택에 따라 리디렉션을 동적으로 조정하세요.

    최신 뉴스 읽기
    newsapp://article?id=12345
    인기 토픽
    newsapp://trending
    스포츠
    newsapp://sports


    Singular 추적 링크에서 리디렉션 재정의에 대해 자세히 알아보세요.

성공!

이 단계를 수행하면 이제 앱이 Singular를 사용하여 푸시 알림 상호 작용을 추적하도록 설정되었습니다. 이를 통해 캠페인 성과 인사이트를 개선하고 정확한 리인게이지먼트 어트리뷰션을 보장할 수 있습니다.