iOS 是否会限制预定的本地推送通知?

问题描述 投票:0回答:2

我的应用程序通过 FCM 接收无声的

推送通知
,正如我在日志中看到的那样,这些通知已被接收和处理。然后我的应用程序所做的是决定是否向用户显示通知的某种逻辑。这有时有效,有时无效。在我看来好像是先工作然后突然停止工作,所以我猜测可能是节流问题?

我确实安排了 5 个通知,间隔 30 秒 - 这样用户就不会错过通知:

    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
            ...
        }
    }

这个循环可能是问题所在吗?

ios swift push-notification
2个回答
1
投票

尝试使用dispatch_async,一些不阻塞主线程的代码可能会被调用,但有时不会被调用。

第二个问题是iOS可能有阻止应用程序向手机发送垃圾邮件的逻辑。你有没有看到 Instagram 通知从数百个到只有几个通知。

谢谢


0
投票

https://developer.apple.com/documentation/usernotifications/pushing-background-updates-to-your-app#overview

系统将后台通知视为低优先级:您可以使用它们来刷新应用程序的内容,但系统不保证它们的传递。此外,如果总数过多,系统可能会限制后台通知的传送。系统允许的后台通知数量取决于当前情况,但不要尝试每小时发送超过两到三个。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.