Flutter SDK
1. 사전 준비
Section titled “1. 사전 준비”- 플레어레인 관리자 에서 회원가입 후 프로젝트 생성
2. 인증 값 설정
Section titled “2. 인증 값 설정”아래 가이드를 참고하여 플레어레인에 푸시 발송에 필요한 인증 값을 입력합니다.
3. SDK 설치
Section titled “3. SDK 설치”터미널에서 프로젝트 루트 디렉토리로 이동한 뒤, 다음 명령어를 입력합니다
$ flutter pub add flarelane_flutter:1.9.24. Android 13 지원
Section titled “4. Android 13 지원”유저로부터 푸시 알림 구독을 원활히 받아낼 수 있도록 compileSdkVersion을 최소 33으로 지정해주세요.
// ...android { compileSdkVersion 33 // ...}// ...5. iOS 프로젝트 설정
Section titled “5. iOS 프로젝트 설정”5-1. Capability 설정
Section titled “5-1. Capability 설정”Target 의 Signing & Capabilites으로 들어와 좌상단의 + Capability > Push Notifications 를 선택하여 추가합니다.
또한 Background Modes 를 선택한 뒤 Remote notifications 를 추가합니다.

5-2. Service Extension 설정
Section titled “5-2. Service Extension 설정”iOS에서는 이미지 등 미디어 첨부를 위해 Notification Service Extension 생성이 필요합니다.
Xcode 에서 File > New > Target 에서 Notification Service Extension 을 선택합니다.

Product Name에 적절한 이름을 입력합니다. 본 가이드에서는 FlareLaneNotificationServiceExtension 으로 정의하겠습니다.

Cancel을 클릭하여 별도의 Scheme은 활성화하지 않도록 합니다.

이후 이번에 만든 Notification Service Extension Target의 Minimum Deployments 버전을 현재 사용 중인 메인 앱 Target의 버전과 동일하게 설정합니다.

5-3. App Group 설정
Section titled “5-3. App Group 설정”본 앱과 Extension 간 데이터 동기화를 위해서는 App Group 설정이 필요합니다.
Target 의 Signing & Capabilites으로 들어와 좌상단의 + Capability > App Groups 를 선택하여 추가합니다.
group.번들ID.flarelane이라는 이름의 그룹을 추가합니다. 여기서 번들ID는 본 앱의 Bundle Identifier와 일치해야 합니다.

정상적으로 추가 후 해당 App Group을 활성화합니다.

마찬가지로 이전에 만든 Extension 에서도 동일한 이름의 App Group을 추가하고 활성화합니다.

다음으로ios 디렉토리 내 Podfile을 열고 다음과 같이 추가합니다.
// 파일 최하단의 아래 줄 추가// 앞서 입력한 Extension의 Product Name을 target 이름으로 설정합니다.target 'FlareLaneNotificationServiceExtension' do pod 'FlareLane', '1.9.2'endpod install 를 실행하여 SDK 설치를 완료합니다.
5-4. AppDelegate 메소드 추가
Section titled “5-4. AppDelegate 메소드 추가”application(:didRegisterForRemoteNotificationsWithDeviceToken:)대응 메소드 추가
import FlareLane
class AppDelegate: FlutterAppDelegate { override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { // 2 FlareLaneAppDelegate.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) }}@import FlareLane;
@implementation AppDelegate- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { // 2 [[FlareLaneAppDelegate shared] application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];}5-5. UNUserNotificationCenterDelegate 메소드 추가
Section titled “5-5. UNUserNotificationCenterDelegate 메소드 추가”- AppDelegate에 UNUserNotificationCenterDelegate 지정
userNotificationCenter(:willPresent:withCompletionHandler:)대응 메소드 추가- 대응 메소드 추가
import FlareLane
@main@objc class AppDelegate: FlutterAppDelegate { override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // 1 UNUserNotificationCenter.current().delegate = self }
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { // 2 FlareLaneNotificationCenter.shared.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler) }
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { // 3 FlareLaneNotificationCenter.shared.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler) }}#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : UIResponder <..., UNUserNotificationCenterDelegate>@end
// AppDelegate.m@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // 1 [[UNUserNotificationCenter currentNotificationCenter] setDelegate: self];}
// 2- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{ [[FlareLaneNotificationCenter shared] userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];}// 3- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{ [[FlareLaneNotificationCenter shared] userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];}@end5-6. UNNotificationServiceExtension 메소드 추가
Section titled “5-6. UNNotificationServiceExtension 메소드 추가”didReceive(:withContentHandler:)대응 메소드 추가serviceExtensionTimeWillExpire()대응 메소드 추가
import UserNotificationsimport FlareLane
class NotificationService: UNNotificationServiceExtension { override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { // 1 // 플레어레인에서 발송한 푸시는 플레어레인의 메소드만 동작하도록 분기 처리합니다. if FlareLaneNotificationServiceExtensionHelper.shared.isFlareLaneNotification(request) { FlareLaneNotificationServiceExtensionHelper.shared.didReceive(request, withContentHandler: contentHandler) } else { // ... } }
override func serviceExtensionTimeWillExpire() { // 2 FlareLaneNotificationServiceExtensionHelper.shared.serviceExtensionTimeWillExpire() }}@import FlareLane;
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { // 1 // 플레어레인에서 발송한 푸시는 플레어레인의 메소드만 동작하도록 분기 처리합니다. if ([[FlareLaneNotificationServiceExtensionHelper shared] isFlareLaneNotification:request]) { [[FlareLaneNotificationServiceExtensionHelper shared] didReceive:request withContentHandler:contentHandler]; } else { // ... }}
- (void)serviceExtensionTimeWillExpire { // 2 [[FlareLaneNotificationServiceExtensionHelper shared] serviceExtensionTimeWillExpire];}6. 초기화 코드 작성
Section titled “6. 초기화 코드 작성”main.dart 파일에서 다음 초기화 코드를 입력합니다. 프로젝트 ID는 콘솔의 [프로젝트] 페이지에서 확인할 수 있습니다.
import 'package:flarelane_flutter/flarelane_flutter.dart';
void main() { // ensureInitialized() 이후 초기화 코드가 실행되도록 합니다 WidgetsFlutterBinding.ensureInitialized();
// 다음 초기화 코드 입력 // 알림 권한 팝업 타이밍을 제어하려면 2번째 파라미터를 false로 설정 후 적절한 시점에 .subscribe() 함수 실행 FlareLane.shared.initialize("PROJECT_ID", requestPermissionOnLaunch: true);
runApp(...);}7. 유저ID 연동
Section titled “7. 유저ID 연동”앱 설치 시 플레어레인에 생성된 기기는 '익명의 기기'이며 고객사가 별도로 관리하는 고유한 유저 ID를 연동함으로써 플레어레인의 기기와 고객사의 유저ID를 매칭할 수 있습니다.
유저ID가 연동되어있으면 많은 이점이 있습니다. 회원과 비회원을 구분할 수 있고, 고객사는 언제든지 유저ID를 기준으로 푸시 알림 발송이 가능하기 때문에 초기 연동시 권장드리고 있습니다.
보통 유저가 회원가입이나 로그인 성공 시, setUserId 함수를 통해 유저ID를 연동합니다.
FlareLane.shared.setUserId("USER_ID");8. 추가 연동 가이드
Section titled “8. 추가 연동 가이드”자동 URL 처리
Section titled “자동 URL 처리”- 플레어레인은 기본적으로 푸시 알림 클릭 시 https, 딥링크 등 URL에 대해 자동 처리를 지원하고 있습니다. 만약 별도의 클릭 핸들러 구현이 필요한 경우 URL 자동 처리 비활성화를 참고하세요.
인앱메시지(팝업) 노출
Section titled “인앱메시지(팝업) 노출”- 인앱메시지(팝업) 를 참고하여 개발자가 직접 팝업이 노출될 타이밍에 코드 1줄(displayInApp)을 추가합니다.
Android
Section titled “Android”알림 색상 설정
Section titled “알림 색상 설정”<resources> <!-- 알림 색상 변경 --> <string name="flarelane_notification_accent_color">#BC0000</string></resources>알림 채널 설정
Section titled “알림 채널 설정”- Android: 알림 채널 설정 을 참고하여 우리 서비스에 적합한 안드로이드 알림 채널 설정을 합니다.
알림 아이콘 설정
Section titled “알림 아이콘 설정”- Android: 알림 아이콘 설정 을 참고하여 아이콘 애셋 세팅을 합니다.
기타 리소스
Section titled “기타 리소스”| 가이드 |
|---|
| Mobile SDK Reference |
| Flutter SDK Release Notes |