我使用firebase向我的应用发送推送通知。我使用警报视图来显示从firebase收到的消息,它工作正常,但在后台,通知横幅不会出现在通知中,但正确调用didreceiveremotenotifications
方法。无法找出问题所在。请建议
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject])
{
if isBackground == false
{
let notifiAlert = UIAlertView()
let NotificationMessage : AnyObject? = userInfo["alert"]
notifiAlert.title = userInfo["title"] as! String
notifiAlert.message = NotificationMessage as? String
notifiAlert.addButtonWithTitle("OK")
notifiAlert.show()
}
else
{
print(userInfo)
NSNotificationCenter.defaultCenter().postNotificationName("pushReceived", object: userInfo)
}
}
在上面的背景中,用户信息打印如下
[title: Check your billing details, notification:
{
body = test;
e = 1;
title = "test notification";
}, collapse_key: com.softence.viabill,
url: http://softence.com/devTest/viabill-sample-app/main.html?,
message: Please check the latest generated bill, from: 314848715780]