【问题标题】:User notification are restricted to a limit in iOS app how to send unlimited for alarm app?用户通知被限制在 iOS 应用程序中的限制如何为警报应用程序发送无限量?
【发布时间】:2018-09-09 11:58:01
【问题描述】:

我正在处理alarm app project(Click for GitHub link),此代码运行良好,但问题是通知当时仅限于大约 64 个,因此在用户响应通知之前我无法发送继续通知。我读过一些苹果将本地通知限制为仅 64,但我在苹果商店中看到许多应用程序不断发送通知,这里很少有来自苹果商店的链接。

https://itunes.apple.com/us/app/red-clock-free-edition-the-minimal-alarm-clock/id567374573?mt=8 https://itunes.apple.com/us/app/alarmy-alarm-clock/id1163786766?mt=8

任何人都可以帮助了解此应用程序如何能够连续发送,我尝试这些应用程序正在发送通知,直到用户响应该应用程序(我检查了超过 1 小时)。下面是设置单条通知的代码。

    let comingSunday =  findNext("Sunday", afterDate: fireDate.adding(minutes: item))
    let triggerDate = Calendar.current.dateComponents([ .year, .month, .weekday, .hour, .minute, .second], from: comingSunday!)
    let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDate, repeats: alarm.repeatAlarm)

    let request = UNNotificationRequest(identifier: "\(alarm.uuid)0\(item)", content: notificationContent, trigger: trigger)
    UNUserNotificationCenter.current().add(request) { (error) in
                         if let error = error {
                           print("Unable to add notification request, \(error.localizedDescription)")
                         }
    }

Video of Alarmy app with continuous notification

请从 App Store 安装并运行应用,并在发布答案之前注意通知在上述应用中的工作方式

【问题讨论】:

  • 我不知道这是否正确,但我认为您可以从应用程序中删除本地通知,并在达到最大限制后重新安排...
  • 但要删除和重新安排通知,应用程序必须处于运行模式,应用商店中的所有这些警报应用程序都已从后台删除,并且互联网已禁用,但他们设法无限时间发送通知
  • @VarunNaharia 你得到解决方案了吗?如果您得到解决方案,您可以更新答案。我想实现同样的目标。
  • 不,我没有找到解决方案
  • 你找到解决方法了吗@VarunNaharia

标签: ios swift usernotifications unusernotification


【解决方案1】:

您可以将有关所有通知的信息存储在本地数据库中。

比如你有超过64条通知,你可以通过UNUserNotificationCenter发布64条通知,其他的保存到本地数据库。

如果一个本地通知已完成(已显示),您可以从本地数据库获取有关第一个通知的信息并安排它(您也可以从本地数据库中删除它,或添加指定键(例如 isScheduled)) .

您可以在委托方法中处理此操作:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Swift.Void)

【讨论】:

    【解决方案2】:

    可能是微不足道的,但如果您只需要多次收到通知, 我通常使用:

    UNTimeIntervalNotificationTrigger( 时间间隔:60.0, 重复:真的)

    因此,您可以添加 ONE,它可以与您的其他(真实)通知共存。 一旦用户点击,你就可以杀死它。

    【讨论】:

    • 你看过报警app的视频吗?
    【解决方案3】:
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Swift.Void)
    

    Delegate 仅在应用运行时起作用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-17
      相关资源
      最近更新 更多