通知不会出现在应用中

时间:2015-06-21 00:08:49

标签: ios swift apple-push-notifications

我的远程推送通知显示在应用外部,但不在应用内。

这就是我配置我的应用程序委托的方式,正如你在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()

    }

}

1 个答案:

答案 0 :(得分:0)

如果您想在应用程序位于前台时显示横幅广告,则必须自行实施横幅广告。当应用程序位于前台时,不会显示本地或远程通知的横幅。

相关问题