Client SDK - Flutter
Notifly Flutter Plugin은 노티플라이를 Flutter 어플리케이션과 연동하기 위해 사용할 수 있습니다. 다음과 같은 기능들을 지원합니다:
- 기기 정보를 노티플라이에 등록하여 노티플라이를 통해 발송된 앱 푸시를 Flutter 앱에서 수신할 수 있습니다.
- 노티플라이에서 만든 인앱 팝업 캠페인을 Flutter 앱에서 띄울 수 있습니다.
- Android 플랫폼의 경우, 현재 인앱 팝업은 Android 11 (API Level 30) 이상에서만 지원되며, 이외의 Android 디바이스에서는 인앱 팝업이 표시되지 않습니다.
- 이벤트, 유저 정보를 노티플라이와 연동하여 모든 캠페인에서 활용할 수 있습니다.
- 캠페인의 성과를 측정할 수 있도록 이벤트를 로깅합니다.
노티플라이에서는 푸시를 발송하기 위해 Firebase Cloud Messaging을 활용하고 있습니다. 다음 과정을 먼저 진행해주세요:
1. Notifly Plugin 셋업
1-1. Plugin 설치
Plugin을 설치하 기 위해, 다음을 실행해 주세요:
flutter pub add notifly_flutter
cd ios && pod install
앱 패키지의 pubspec.yaml 파일에 다음과 같이 추가됩니다. (현재 최신 버전:
dependencies:
notifly_flutter: ^1.3.5
1.2. iOS 설정
1) Capability 설정
-
Xcode에서 Runner.xcworkspace를 열어주세요.
- Xcode에서 Runner.xcworkspace를 열지 않고 Runner.xcodeproj를 열어서 빌드하면, Notifly Plugin을 사용할 수 없습니다.
- Runner.xcworspace는 Root 디렉토리의 ios 디렉토리에 있습니다.
-
대상 Project의 iOS Deployment Target과 Target의 Minimum Deployments iOS를 13.0 혹은 그 이상으로 설정합니다.
-
Push Notification Capability를 추가합니다.

-
Background Modes Capability를 추가합니다. - Remote notifications과 Background Fetch를 선택합니다.

-
AppDelegate.swift 파일을 열어서 다음 코드를 추가합니다.
- AppDelegate.swift는 ios 디렉토리의 Runner 디렉토리에 있습니다.
notifly_sdk프래임워크를 import 합니다.
import notifly_sdk
- AppDelegate.swift의
FlutterAppDelegate에서 함수들을 override하여 다음 Notifly코드를 추가해 주세요.application(_:didFinishLaunchingWithOptions:)- UNNotificationCenter의 delegate를 self로 설정합니다.
application(_:didRegisterForRemoteNotificationsWithDeviceToken:)- APNs 토큰을 노티플라이에 등록합니다.
application(_:didFailToRegisterForRemoteNotificationsWithError:)- APNs 토큰 등록에 실패한 경우, 노티플라이에 알립니다.
userNotificationCenter(_:willPresent:withCompletionHandler:)- 앱이 실행 중일 때, 앱 푸시 알림 트래픽을 노티플라이로 전달합니다.
userNotificationCenter(_:didReceive:withCompletionHandler:)- 앱 푸시 알림 클릭 이벤트를, 노티플라이로 전달합니다.
- Swift
Example Code of AppDelegate.swift
import Flutter
import notifly_sdk
import UIKit
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
UNUserNotificationCenter.current().delegate = self
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(
_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error
) {
Notifly.application(application,
didFailToRegisterForRemoteNotificationsWithError: error)
super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
}
override func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
Notifly.application(application,
didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
override func userNotificationCenter(_ notificationCenter: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completion: @escaping () -> Void)
{
Notifly.userNotificationCenter(notificationCenter,
didReceive: response)
super.userNotificationCenter(notificationCenter, didReceive: response, withCompletionHandler: completion)
}
override func userNotificationCenter(_ notificationCenter: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completion: @escaping (UNNotificationPresentationOptions) -> Void)
{
Notifly.userNotificationCenter(notificationCenter,
willPresent: notification,
withCompletionHandler: completion)
super.userNotificationCenter(notificationCenter, willPresent: notification, withCompletionHandler: completion)
}
}
1-3. (권장) iOS Push Extension 설정
SDK spec for Rich Push Notification
notifly_flutter: 1.2.2 버전 이상
- Notifly의 안내에 따라, Notification Service Extension을 설정하시면 다음 기능들이 지원되기 때문에, 설정하시길 권장드립니다.
- 푸시 알림에 이미지 및 비디오를 첨부할 수 있습니다.
- 유저의 푸시 수신 여부를 확인할 수 있어, 캠페인 성과를 보다 자세하게 확인하실 수 있습니다.