我真的很想知道收到的推送通知的FCM(Firebase云消息传递)“主题”。如何知道Swift上收到的推送通知的“主题”信息?
现在,我发送主题为“全部”的FCM通知。而且我收到了推送消息。但是我不知道关于推送主题。 我将{notification:{{title:〜,body:〜}}之类的消息发送给:“全部”}} 我在FCM文档上找不到有关Swift上此问题的信息。 我想知道这个“全部”“主题”
与下面的Android代码相同。
Android代码
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("Message!!", String.valueOf(remoteMessage.getFrom()));
}
我也尝试在下面的Swift代码上登录AppDelegate.swift。 我可以找到类似的日志
[UserNotificationCenter] applicationState:活动的willPresentNotification: [UNNotification:0x28244c480;日期:2019年1月22日03:23:43 +0000,请求:[UNNotificationRequest:0x282a5cd80;标识符:~~~,内容:[UNNotificationContent:0x28112dc80;标题:(null),字幕:(null),正文:tt,summaryArgument:,summaryArgumentCount:0,categoryIdentifier:,launchImageName:,threadIdentifier:,附件:( ),徽章:(null),声音:(null),触发器:[UNPushNotificationTrigger:0x2826285a0; contentAvailable:否,可变内容:NO]]
但是没有主题信息。
交换代码
@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
// iOS10+, called when presenting notification in foreground
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
//let userInfo = notification.request.content.userInfo
NSLog("[UserNotificationCenter] applicationState: \(applicationStateString) willPresentNotification: \(notification)")
//TODO: Handle foreground notification
completionHandler([.alert])
}
// iOS10+, called when received response (default open, dismiss or custom action) for a notifi cation
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
NSLog("[UserNotificationCenter] applicationState: \(applicationStateString) didReceiveResponse: \(userInfo)")
//TODO: Handle background notification
completionHandler()
}
}
是否有任何方法在收到的推送通知中知道fcm主题?