ios - 某些具有特定负载的通知的静默推送通知

标签 ios swift xcode notifications

我试图对用户隐藏一些指定的推送通知,这样用户就看不到了。 我在哪里可以写隐藏到达时通知的条件,使其不显示在通知托盘中。 我尝试在 AppDelgate 中执行此操作,但没有成功。我还有其他方法可以做到这一点吗?

func application(applxication: UIApplication, didReceiveLocalNotification notification: UILocalNotification)
    {
        UIApplication.sharedApplication().cancelLocalNotification(<#T##notification: UILocalNotification##UILocalNotification#>)
        //println("Local Notification Received:\(notification)")
    }

如果你能在这里帮助我,那将是非常有帮助的。

最佳答案

我试过这个用于远程通知,而不是本地通知。 因此,根据 Apple WWDC 2013,如果您将在您的有效负载中传递 content-available": 1,那么它将充当静默推送通知。

因此只需在您的有效负载中包含 content-available": 1 即可获得静默通知,如下所示。

同样在 App 的 Info.plist 中应该有 UIBackgroundModes 设置为 remote-notification 更多信息在这里 For Silent push notification

{
    aps = {
        "content-available" : 1,
        sound : ""
    };
}

希望对你有帮助...

快乐编码。

关于ios - 某些具有特定负载的通知的静默推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39826425/

相关文章:

ios - UIWebView ContentSize高度

xcode - OSX 上适用于 Apple Sandbox 的代码签名帮助程序应用程序

ios - MKMapView 位置不会更新

swift - 扩展 ReactiveCocoa

c++ - c++::libc++abi.dylib 中的字符串库出错:以 std::out_of_range 类型的未捕获异常终止:basic_string (lldb)

ios - UIAlertController swift

ios - 如何在彼此不相邻的两个元素之间添加尾部/前导约束

ios - 防止 iOS QuickLook 生成缓存

swift - Apple 的 Swift Sprite Kit : linearDamping, 这个属性在数学上是如何使用的?

swift - 在 map 上将注释固定为 subview