iOS библиотека для отправки APNs пуш-сообщений
Этот пакет позволяет интегрировать службу APNs в ваше мобильное приложение используюя iOS библиотеку.
Инструкция по использованию
Выполните следующие шаги, чтобы использовать пакет.
1. Подготовительный этап
В iOS убедитесь, что вы правильно настроили свое приложение для поддержки push-уведомлений:
- добавили возможность push-уведомлений,
- добавили фоновый режим удаленных уведомлений (remote notification background mode).
2. Добавьте зависимости
Добавьте Pushed iOS библиотеку в Pod файл:
pod 'PushedMessagingiOSLibrary',:
git => 'https://github.com/PushedLab/Pushed.Messaging.iOS.Library.git'
3. Обновите зависимости
Используйте команду pod install or pod update.
4. Использование в проекте
Вам нужно изменить AppDelegate, пример использования:
import SwiftUI
import PushedMessagingiOSLibrary
class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Setup library
PushedMessagingiOSLibrary.setup(self)
return true
}
// This function will be called when a push is received
public func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print("Message: \(userInfo)")
completionHandler(.noData)
}
//This function will be called when the Pushed library is successfully initialized
@objc
public func isPushedInited(didRecievePushedClientToken pushedToken: String) {
// To send a message to a specific user, you need to know his Client token.
print("Client token: \(pushedToken)")
}
}