简体   繁体   English

通过Parse.com安排iOS推送通知

[英]Schedule iOS Push Notification with Parse.com

I am trying to schedule push notifications using Parse in iOS. 我正在尝试使用iOS中的Parse安排推送通知。 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: 我只有一个免费帐户(这意味着我无法在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). 在应用程序中,当您按发送通知时,您可以设置文本和发送通知的日期(使用该代码仅发送标准的PFPush代码)。 Then I just use NSDate and every day check the date to see if it matches the date for the scheduled notification. 然后,我只使用NSDate,然后每天检查日期以查看它是否与计划的通知的日期匹配。 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). 因此,在预定的日期发送通知,如果不是匹配的日期,则什么也没有发生(没有发送通知,并且该应用会在另外24小时内重新检查)。 This works, but the app has to be open in the foreground at the time that the notification is scheduled for sending (ie 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). 因此,我的实际问题是如何在后台运行所有这些操作,因此该应用程序可以仅在iPad上的后台运行,并且仍会检查日期并能够发布PFPush(推送通知)。

Any help or code would be much appreciated. 任何帮助或代码将不胜感激。

Thanks so much in advance, and let me know if you need more information! 提前非常感谢,如果您需要更多信息,请告诉我!

In this case 在这种情况下

setMinimumBackgroundFetchInterval means that it is not called in an interval which is smaller than the value you specified. setMinimumBackgroundFetchInterval表示不会在小于您指定的值的间隔中调用它。 But there's no setMaximumBackgroundFetchInterval. 但是没有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. 因此,如果iOS决定每天或每周仅一次调用您的应用,那么无论您的minimumBackgroundFetchInterval是多少,它都不会被频繁调用。 AFAIK iOS decides when to call performFetchWithCompletionHandler measured by the pattern when and how often the users start's the app. AFAIK iOS决定何时调用performFetchWithCompletionHandler,具体由模式决定,何时以及用户启动应用程序的频率。

In Xcode 5 Debug mode, you can force a background fetch from the menu: Debug > Simulate Background Fetch. 在Xcode 5调试模式下,可以从菜单中强制进行后台提取:调试>模拟后台提取。 在此处输入图片说明

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

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