اتصال Pushfa iOS SDK به AppDelegate و SwiftUI
مدیریت APNs token، delegateهای موجود، callback پسزمینه، لینکها و Notification Service Extension.
وقتی Firebase swizzling غیرفعال است
اگر FirebaseAppDelegateProxyEnabled را خاموش کردهاید، APNs token را دستی به SDK تحویل دهید.
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
Pushfa.setAPNSToken(deviceToken)
}
اپ دارای UNUserNotificationCenterDelegate
SDK delegate موجود اپ را جایگزین نمیکند. پاسخ کلیک را از delegate فعلی فوروارد کنید تا گزارش کلیک و Deep Link حفظ شود.
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse
) async {
await Pushfa.handleNotificationResponse(response)
}
اپ دارای Firebase MessagingDelegate
SDK delegate موجود Firebase را جایگزین نمیکند. FCM token جدید را از delegate فعلی اپ فوروارد کنید.
import FirebaseMessaging
func messaging(
_ messaging: Messaging,
didReceiveRegistrationToken fcmToken: String?
) {
if let fcmToken { Pushfa.setFCMToken(fcmToken) }
}
Foreground در اپ دارای delegate
func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification
) async -> UNNotificationPresentationOptions {
Pushfa.handleForegroundNotification(notification)
}
Background callback
func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) {
Pushfa.handleRemoteNotification(
userInfo,
fetchCompletionHandler: completionHandler
)
}
Action Button و Deep Link
iOS عنوان Actionها را هنگام ثبت Notification Category تعیین میکند؛ عنوان دکمه چپ و راست را در PushfaConfig تنظیم کنید. URL اختصاصی هر پیام از payload خوانده میشود. برای مسیر نسبی، deepLinkBaseURL را مقداردهی کنید.
let config = PushfaConfig(
apiPublicKey: "YOUR_PUBLIC_KEY",
deepLinkBaseURL: URL(string: "myapp://"),
leftActionTitle: "مشاهده",
rightActionTitle: "باز کردن"
)
حریم خصوصی و App Store
SDK دارای Privacy Manifest برای UserDefaults است و Tracking انجام نمیدهد. اپ میزبان باید کاربرد واقعی External ID، Alias، Visit و Event را در Privacy Policy و پاسخهای App Store Connect اعلام کند.