Настройка iOS приложения
Настройка приложения для получения и отображения push-уведомлений
Пример AppDelegate после выполнения вышеуказанных действий
@main
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
if let error = error {
print("Failed to request notification center authorization: \\(error)")
}
}
application.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let stringToken = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
self.sendDeviceTokenToBackend(token: stringToken)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Failed to register for remote notifications: \\(error)")
// Try again later.
}
// MARK: - UNUserNotificationCenterDelegate
// The method will be called on the delegate only if the application is in the foreground.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound, .badge])
}
}Отслеживание статусов доставки
Как добавить расширение Notification Service Extension?


Пример реализации расширения
Отправка уведомлений
Как создать ключ p8?


Как передать созданный p8 ключ в i-Digital?
p8 ключ в i-Digital?Последнее обновление