gpt4 book ai didi

ios - 通知不会出现在应用程序中

转载 作者:行者123 更新时间:2023-11-28 09:05:27 25 4
gpt4 key购买 nike

我的远程推送通知出现在应用程序外部,但在应用程序中却没有。

这就是我配置我的应用程序委托(delegate)的方式,正如您在 didRecieveRemoteNotification 中看到的那样,我配置了一个警报出现,它在动物园内显示得很好,但我不想要一个警报框,我想要一个像那个一样的顶部横幅在应用程序之外:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var type = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound;
var setting = UIUserNotificationSettings(forTypes: type, categories: nil);
UIApplication.sharedApplication().registerUserNotificationSettings(setting);
UIApplication.sharedApplication().registerForRemoteNotifications();


return true

}


func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

println("Recived: \(userInfo)")
//Parsing userinfo:
var temp : NSDictionary = userInfo
if let info = userInfo["aps"] as? Dictionary<String, AnyObject>
{
var alertMsg = info["alert"] as! String
var alert: UIAlertView!
alert = UIAlertView(title: "", message: alertMsg, delegate: nil, cancelButtonTitle: "OK")
alert.show()

}

}

最佳答案

如果你想在应用程序在前台时显示横幅,你必须自己实现横幅。当应用程序在前台时,不会为本地或远程通知显示横幅。

关于ios - 通知不会出现在应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30960064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com