【发布时间】:2021-04-01 00:54:59
【问题描述】:
为了让它发挥作用,我绞尽脑汁想了一天。我收到了通知,但在单击时从未导航到特定选项卡。
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] {
print(tag + "Message ID: \(messageID)")
}
// With swizzling disabled you must let Messaging know about the message, for Analytics
// Messaging.messaging().appDidReceiveMessage(userInfo)
// Print full message.
print(userInfo)
// let myTabBar = self.window?.rootViewController as? UITabBarController
// myTabBar?.selectedIndex = 2
//TabBarController - StoryBoard Id
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let tabController = storyboard.instantiateViewController(withIdentifier: "TabBarController") as? UITabBarController {
tabController.selectedIndex = 2
}
completionHandler()
}
【问题讨论】:
标签: swift push-notification firebase-cloud-messaging appdelegate