【发布时间】:2020-10-12 16:01:36
【问题描述】:
我有这个代码来推送应用通知。 它运作良好,但我收到此警告: 'MessagingRemoteMessage' 已弃用:FCM 直接通道已弃用,请使用 APNs 进行下游消息处理。 而这个 'appData' 已弃用
我在 Google 上进行了研究,但没有找到任何解决此问题的方法。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
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 })
// For iOS 10 data message (sent via FCM
Messaging.messaging().delegate = self
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
FirebaseApp.configure()
return true
}
// The callback to handle data message received via FCM for devices running iOS 10 or above.
func applicationReceivedRemoteMessage(_ remoteMessage: MessagingRemoteMessage) {
print(remoteMessage.appData)
}
【问题讨论】:
-
@Rob 我已经看到了这个答案,但不知道它对我有什么帮助
标签: ios swift firebase firebase-cloud-messaging appdelegate