I am trying to schedule push notifications using Parse in iOS. I only have a free account (meaning that I cannot schedule notifications in the web backend), so I came up with a solution for scheduling the notification through Parse:
我正在尝试使用iOS中的Parse安排推送通知。我只有一个免费帐户(这意味着我无法在Web后端安排通知),所以我想出了一个通过Parse安排通知的解决方案:
Within the app, when you press send notification you set the text and a date to send the notification (using the code to just send a standard PFPush code). Then I just use NSDate and every day check the date to see if it matches the date for the scheduled notification. If it does, it sends the notification; thus sending the notification on the scheduled day, if it is not the matching day, nothing happens (no notification is sent, and the app rechecks in another 24hrs). This works, but the app has to be open in the foreground at the time that the notification is scheduled for sending (i.e the date is not checked and notification not sent if the app is in the background). So my actual question is how I can run all of this in the background, so the app can just be in the background on my iPad, and it will still check the date and be able to post the PFPush (push notification).
在应用程序中,当您按下发送通知时,您可以设置文本和发送通知的日期(使用代码发送标准PFPush代码)。然后我只使用NSDate并每天检查日期以查看它是否与预定通知的日期相匹配。如果是,则发送通知;因此,在预定的一天发送通知,如果不是匹配日,则不会发生任何事情(不发送通知,并且应用程序会在另外24小时内重新检查)。这是有效的,但是应用程序必须在通知被安排发送时在前台打开(即,如果应用程序在后台,则不检查日期并且不发送通知)。所以我的实际问题是如何在后台运行所有这些,所以应用程序可以只在我的iPad背景中,它仍然会检查日期并能够发布PFPush(推送通知)。
Any help or code would be much appreciated.
任何帮助或代码将不胜感激。
Thanks so much in advance, and let me know if you need more information!
非常感谢,如果您需要更多信息,请告诉我们!
1 个解决方案
#1
0
In this case
在这种情况下
setMinimumBackgroundFetchInterval means that it is not called in an interval which is smaller than the value you specified. But there's no setMaximumBackgroundFetchInterval. So if iOS decides to call your app just once a day or even just once a week than it won't be called more often regardless your minimumBackgroundFetchInterval. AFAIK iOS decides when to call performFetchWithCompletionHandler measured by the pattern when and how often the users start's the app.
setMinimumBackgroundFetchInterval表示不会在小于您指定的值的时间间隔内调用它。但是没有setMaximumBackgroundFetchInterval。因此,如果iOS决定每天只调用一次您的应用程序,甚至每周只调用一次,那么无论您的minimumBackgroundFetchInterval如何,都不会更频繁地调用它。 AFAIK iOS决定何时调用由模式测量的performFetchWithCompletionHandler用户启动应用程序的时间和频率。
In Xcode 5 Debug mode, you can force a background fetch from the menu: Debug > Simulate Background Fetch.
在Xcode 5 Debug模式下,您可以从菜单强制进行后台提取:Debug> Simulate Background Fetch。
#1
0
In this case
在这种情况下
setMinimumBackgroundFetchInterval means that it is not called in an interval which is smaller than the value you specified. But there's no setMaximumBackgroundFetchInterval. So if iOS decides to call your app just once a day or even just once a week than it won't be called more often regardless your minimumBackgroundFetchInterval. AFAIK iOS decides when to call performFetchWithCompletionHandler measured by the pattern when and how often the users start's the app.
setMinimumBackgroundFetchInterval表示不会在小于您指定的值的时间间隔内调用它。但是没有setMaximumBackgroundFetchInterval。因此,如果iOS决定每天只调用一次您的应用程序,甚至每周只调用一次,那么无论您的minimumBackgroundFetchInterval如何,都不会更频繁地调用它。 AFAIK iOS决定何时调用由模式测量的performFetchWithCompletionHandler用户启动应用程序的时间和频率。
In Xcode 5 Debug mode, you can force a background fetch from the menu: Debug > Simulate Background Fetch.
在Xcode 5 Debug模式下,您可以从菜单强制进行后台提取:Debug> Simulate Background Fetch。