简体   繁体   English

iOS是否会限制计划的本地推送通知?

[英]Does iOS throttle scheduled local push notifications?

My app receives silent push notifications via FCM , as I see in the logging the are received and handled. 我的应用程序通过FCM接收静默推送通知 ,正如我在日志记录中看到的那样,已接收并处理了通知 What my app then does is decide to some logic if a notification is shown to the user or not. 然后,我的应用程序所做的就是确定是否向用户显示通知的某种逻辑。 This sometimes works, sometimes doesn't. 这有时有效,有时却无效。 It seems to me as if it works first and then suddenly stops working, so I'm guessing if it may be a throttling problem? 在我看来,它好像先工作然后突然停止工作,所以我猜测是否可能是一个节流的问题?

I do schedule 5 notifications 30 seconds apart - so the user does not miss the notification: 我确实安排了30秒间隔5条通知-因此用户不会错过通知:

    for i in 0...5 {
        let notification = UNMutableNotificationContent()
        notification.title = NSLocalizedString("bed_wet", comment: "")
        notification.subtitle = device.lookAfterPatientString
        notification.sound = UNNotificationSound(named: "alarm.mp3")
        notification.categoryIdentifier = Notification.Category.alarm
        notification.userInfo = ["identifier": device.id]

        let timeInterval = max(1, delaySeconds) + i * 30
        let notificationTrigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(timeInterval), repeats: false)
        let request = UNNotificationRequest(identifier: UUID.init().uuidString, content: notification, trigger: notificationTrigger)

        UNUserNotificationCenter.current().add(request) { error in
            ...
        }
    }

can this loop be the problem? 这个循环会是问题吗?

Try it with dispatch_async, Several code that not blocking main thread maybe called and some times not called. 尝试使用dispatch_async进行尝试,可能会调用一些不会阻塞主线程的代码,有时还会不调用。

The second problem is maybe iOS have logic that prevent an app to spam the phone. 第二个问题可能是iOS的逻辑阻止了应用向手机发送垃圾邮件。 Have u seen instagram notification limited from maybe hundred to only several notification. 您是否看到过instagram通知从几百个通知限制到只有几个通知。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM