我目前正在使用名为“whisper”的图书馆,该图书馆应该有助于展示应用内推送通知Whisper Link
在我的“didReceiveRemoteNotification”中,我将其设置如下:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
if application.applicationState == .Active {
let navigationController = self.window!.rootViewController as! UINavigationController
if let aps = userInfo["aps"] as? NSDictionary {
if let alert = aps["alert"] as? NSDictionary {
if let title = alert["title"] as? NSString {
if let body = alert["body"] as? NSString {
let announcement = Announcement(title: title as! String, subtitle: body as! String, image: UIImage(named: "HolyGrailLogo-58"))
Shout(announcement, to: navigationController)
}
}
}
}
// Show and hide a message after delay
}
}
由于一些奇怪的原因,我没有收到任何推送通知,不知道为什么。
答案 0 :(得分:0)