我正在尝试制作一个使用 APNS 进行 iOS 推送通知的 flutter 应用程序,我不想使用 firebase,因为我在后端使用 AWS SNS 通过 APNS 传递推送通知。我设置了应用程序标识符并从苹果开发者门户生成了密钥。我怎样才能获得 APNS 设备令牌,我被困在这一点上,尝试了多种方法但都没有用?下面是我的 AppDelegate.swfit 代码
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
UIApplication.shared.registerForRemoteNotifications()
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
let hexString = map { deviceToken(format: "%02.2hhx", $0)}.joined()
print(hexString)
}
}