푸시 알림
개요
The following guide covers the configuration of the iOS SDK for processing incoming push notifications and sending extracted attribution data to AppsFlyer.
연동을 구현하는 방법은 다음 2 가지가 있습니다.
- By utilizing OneLink in the push payload (recommended method). Step 3 is required only if implementing this solution.
- 푸시 페이로드에서 일반 JSON 사용(레거시 방법).
마케터가 푸시 알림을 구성하는 방식에 따라 적합한 방법을 선택하십시오.
iOS 푸시 알림과 앱스플라이어 연동
iOS 푸시 알림과 앱스플라이어 연동은 다음과 같이 구성됩니다.
- 앱스플라이어 SDK 구성.
- Configuring a
UNUserNotificationCenter
delegate.
Prerequisites
계속하기 전에 다음 사항을 확인하십시오.
- 푸시 알림이 활성화된 iOS 앱.
- Integrated the SDK.
- 권장되는 원링크 기반 솔루션을 구현하는 경우 원링크(앱 마케터 제공)가 포함된 푸시 알림 페이로드 내부의 키 이름이 필요합니다.
Steps
-
Configure the app to use the
UNUserNotificationCenter
delegate:if #available(iOS 10.0, *) { // For iOS 10 display notification (sent via APNS) UNUserNotificationCenter.current().delegate = self let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization( options: authOptions, completionHandler: { _, _ in } ) } else { let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) application.registerUserNotificationSettings(settings) } application.registerForRemoteNotifications() }
-
다음 메서드
UNUserNotificationCenter
delegate. In thedidReceive
메서드, 호출handlePushNotification
:@available(iOS 10, *) extension AppDelegate: UNUserNotificationCenterDelegate { func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { let userInfo = response.notification.request.content.userInfo print(userInfo) completionHandler() AppsFlyerLib.shared().handlePushNotification(userInfo) } // Receive displayed notifications for iOS 10 devices. func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { let userInfo = notification.request.content.userInfo print(userInfo) // Change this to your preferred presentation option completionHandler([[.alert, .sound]]) } }
-
This step is required only if you're implementing the recommended OneLink-based solution.
IndidFinishLaunchingWithOptions
, calladdPushNotificationDeepLinkPath
before callingstart
:AppsFlyerLib.shared().addPushNotificationDeepLinkPath(["af_push_link"])
In this example, the SDK is configured to look for the
af_push_link
key in the push notification payload.
When callingaddPushNotificationDeepLinkPath
the SDK verifies that:- 필수 키가 페이로드에 있습니다.
- 이 키는 유효한 원링크 URL을 포함합니다.
참고
addPushNotificationDeepLinkPath
accepts an array of strings too, to allow you to extract the relevant key from nested JSON structures. For more information, seeaddPushNotificationDeepLinkPath
.
최신 데이터 약 1년 전