Skip to content

고급 푸시 알림 예시

다음 가이드에서는 Braze SDK의 몇 가지 고급 푸시 알림 예제를 다룹니다.

Prerequisites

이 기능을 사용하려면 먼저 Android Braze SDK를 통합해야 합니다. 푸시 알림도 설정해야 합니다.

커스텀 알림 레이아웃

Braze 알림은 데이터 메시지로 전송되므로 앱이 백그라운드에 있을 때 시스템에서 자동으로 처리할 수 있는 알림 메시지와 달리 백그라운드에서도 항상 응답하고 그에 따른 동작을 수행할 수 있습니다(앱이 백그라운드에 있을 때 알림 메시지와 달리). 이와 같이 애플리케이션은 예를 들어 알림 트레이에 전달된 알림 내에서 개인화된 UI 요소를 표시하여 경험을 사용자 지정할 수 있습니다. 이 방식으로 푸시를 구현하는 것이 일부에게는 낯설 수 있지만, Braze의 잘 알려진 기능 중 하나인 푸시 스토리는 커스텀 뷰 컴포넌트를 사용하여 몰입감 있는 경험을 만드는 좋은 예입니다!

개인화된 푸시 알림

푸시 알림은 사용자 지정 보기 계층 구조 내에 사용자별 정보를 표시할 수 있습니다. 다음 예에서는 API 트리거를 사용하여 앱에서 특정 작업을 완료한 후 현재 진행 상황을 추적할 수 있도록 사용자에게 개인화된 푸시 알림을 보냅니다.

개인화된 푸시 대시보드 예시

대시보드에서 개인화된 푸시를 설정하려면 표시하려는 특정 카테고리를 등록한 다음 Liquid를 사용하여 표시하려는 관련 사용자 속성을 설정합니다.

개인화된 푸시 대시보드 예시

Prerequisites

이 기능을 사용하려면 먼저 Swift Braze SDK를 통합해야 합니다. You’ll also need to set up push notifications.

Notification content app extensions

Two push messages shown side-by side. The message on the left shows what a push looks like with the default UI. The message on the right shows a coffee punch card push made by implementing a custom push UI.

Notification content app extensions provide you a great option for push notification customization. Notification content app extensions display a custom interface for your app’s notifications when a push notification is expanded.

Push notifications can be expanded in three different ways:

  • A long press on the push banner
  • Swiping down on the push banner
  • Swiping the banner to the left and selecting “View”

These custom views offer smart ways to engage customers by displaying distinct types of content, including interactive notifications, notifications populated with user data, and even push messages that can capture information like phone numbers and email. One of our well-known features at Braze, Push Stories, are a prime example of what a push notification content app extension can look like!

Requirements

  • Push notifications successfully integrated in your app
  • The following files generated by Xcode based on your coding language:

Swift

  • NotificationViewController.swift
  • MainInterface.storyboard

Objective-C

  • NotificationViewController.h
  • NotificationViewController.m
  • MainInterface.storyboard

Interactive push notification

Push notifications can respond to user actions inside a content app extension. For users running iOS 12 or later, this means you can turn your push notifications into fully interactive messages! This provides an exciting option to introduce interactivity to your promotions and applications. For example, your push notification can include a game for users to play, a spin-to-win wheel for discounts, or a “like” button to save a listing or song.

The following example shows a push notification where users are able to play a match game inside the expanded notification.

A diagram of what the phases of a interactive push notification could look like. A sequence shows a user pressing into a push notification that displays an interactive matching game.

Dashboard configuration

To create an interactive push notification, you must set a custom view in your dashboard.

  1. From the Campaigns page, click Create Campaign to start a new push notification campaign.
  2. On the Compose tab, toggle on Notification Buttons.
  3. Enter a custom iOS category in the iOS Notification Category field.
  4. In the .plist of your Notification Content Extension Target, set the UNNotificationExtensionCategory attribute to your custom iOS category. The value given here must match what is set in the Braze dashboard under iOS Notification Category.
  5. Set the UNNotificationExtensionInteractionEnabled key to true to enable user interactions in a push notification.

The notification button options found in the push message composer settings.

Personalized push notifications

Two iPhones displayed side-by-side. The first iPhone shows the unexpanded view of the push message. The second iPhone shows the expanded version of the push message displaying a "progress" shot of how far they are through a course, the name of the next session, and when the next session must be completed.

Push notifications can display user-specific information inside a content extension. This allows you to create user-focused push content, such as adding the option to share your progress across different platforms, show unlocked achievements, or display onboarding checklists. This example shows a push notification displayed to a user after they have completed a specific task in the Braze Learning course. By expanding the notification, the user can see their progress through their learning path. The information provided here is user-specific and can be fired off as a session is completed or a specific user action is taken by leveraging an API trigger.

Dashboard configuration

To create a personalized push notification, you must set a custom view in your dashboard.

  1. From the Campaigns page, click Create Campaign to start a new push notification campaign.
  2. On the Compose tab, toggle on Notification Buttons.
  3. Enter a custom iOS category in the iOS Notification Category field.
  4. In the Settings tab, create key-value pairs using standard Liquid. Set the appropriate user attributes you want the message to show. These views can be personalized based on specific user attributes of a specific user profile.
  5. In the .plist of your Notification Content Extension Target, set the UNNotificationExtensionCategory attribute to your custom iOS category. The value given here must match what is set in the Braze dashboard under iOS Notification Category.

Four sets of key-value pairs, where "next_session_name" and "next_session_complete_date" are set as an API trigger property using Liquid, and "completed_session count" and "total_session_count" are set as a custom user attribute using Liquid.

Handling key-value pairs

The method didReceive is called when the notification content app extension has received a notification. This method can be found within the NotificationViewController. The key-value pairs provided in the dashboard are represented in the code through the use of a userInfo dictionary.

Parsing Key-Value Pairs from Push Notifications

1
2
3
4
5
6
7
8
9
func didReceive(_ notification: UNNotification) {
  let userInfo = notification.request.content.userInfo
     
  guard let value = userInfo["YOUR-KEY-VALUE-PAIR"] as? String,
        let otherValue = userInfo["YOUR-OTHER-KEY-VALUE-PAIR"] as? String,
  else { fatalError("Key-Value Pairs are incorrect.")}
 
  ...
}
1
2
3
4
5
6
7
8
9
10
11
- (void)didReceiveNotification:(nonnull UNNotification *)notification {
  NSDictionary *userInfo = notification.request.content.userInfo;
   
  if (userInfo[@"YOUR-KEY-VALUE-PAIR"] && userInfo[@"YOUR-OTHER-KEY-VALUE-PAIR"]) {
 
  ...
 
  } else {
    [NSException raise:NSGenericException format:@"Key-Value Pairs are incorrect"];
  }
}

Information capture push notification

Push notifications can capture user information inside a content app extension, pushing the limits of what is possible with a push. Requesting user input through push notifications allows you to not only request basic information like name or email, but also prompt users to submit feedback or complete an unfinished user profile.

In the following flow, the custom view is able to respond to state changes. Those state change components are represented in each image.

  1. User receives a push notification.
  2. Push is opened. After expanded, the push prompts the user for information. In this example, the user’s email address is requested, but you could request any sort of information.
  3. Information is provided, and if in the expected format, the registration button is shown.
  4. Confirmation view is displayed, and push gets dismissed.

Dashboard configuration

To create an information capture push notification, you must set a custom view in your dashboard.

  1. From the Campaigns page, click Create Campaign to start a new push notification campaign.
  2. On the Compose tab, toggle on Notification Buttons.
  3. Enter a custom iOS category in the iOS Notification Category field.
  4. In the Settings tab, create key-value pairs using standard Liquid. Set the appropriate user attributes you want the message to show.
  5. In the .plist of your Notification Content Extension Target, set the UNNotificationExtensionCategory attribute to your custom iOS category. The value given here must match what is set in the Braze dashboard under iOS Notification Category.

As seen in the example, you may also include an image in your push notification. To do this, you must integrate rich notifications, set the notification style in your campaign to Rich Notification, and include a rich push image.

A push message with three sets of key-value pairs. 1. "Braze_id" set as a Liquid call to retrieve Braze ID. 2. "cert_title" set as "Braze Marketer Certification". 3. "Cert_description" set as "Certified Braze marketers drive...".

Handling button actions

Each action button is uniquely identified. The code checks if your response identifier is equal to the actionIndentifier, and if so, knows that the user clicked the action button.

Handling Push Notification Action Button Responses

1
2
3
4
5
6
7
func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
  if response.actionIdentifier == "YOUR-REGISTER-IDENTIFIER" {
    // do something
  } else {
    // do something else
  }
}
1
2
3
4
5
6
7
- (void)didReceiveNotificationResponse:(UNNotificationResponse *)response completionHandler:(void (^)(UNNotificationContentExtensionResponseOption))completion {
  if ([response.actionIdentifier isEqualToString:@"YOUR-REGISTER-IDENTIFIER"]) {
    completion(UNNotificationContentExtensionResponseOptionDismiss);
  } else {
    completion(UNNotificationContentExtensionResponseOptionDoNotDismiss);
  }
}

Dismissing pushes

Push notifications can be automatically dismissed from an action button press. There are three pre-built push dismissal options that we recommend:

  1. completion(.dismiss) - Dismisses the notification
  2. completion(.doNotDismiss) - Notification stays open
  3. completion(.dismissAndForward) - Push dismisses and the user gets forwarded into the application
이 페이지가 얼마나 도움이 되었나요?
New Stuff!