[英]How to receive in - app push notifications when app is open?
我目前正在使用一個名為“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
}
}
由於一些奇怪的原因,我沒有收到任何推送通知,不知道為什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.