I've been looking around online trying to research how to set up a push notification to go off after x number of seconds or a set time. I haven't been able to find anything to help me out though. I've found numerous good tutorials like this, however they don't seem to state how to set up when the alerts will go off.
我一直在寻找在线试图研究如何设置推送通知在x秒或设定时间后关闭。我找不到任何可以帮助我的东西。我已经找到了许多这样的好教程,但是它们似乎没有说明如何设置警报何时关闭。
Also, please could someone tell me what would happen if the user had the app open when the alert is due to go off? Will it just be ignored or will it still be shown?
此外,请有人告诉我,如果用户在警报响起时打开应用程序会发生什么情况?它会被忽略还是会被展示?
2 个解决方案
#1
1
Have you considered using local notifications instead? You can schedule it to go off at a certain time without having to make the server round-trip
您是否考虑过使用本地通知?您可以安排它在某个时间关闭,而无需使服务器往返
#2
0
You need a script to connect to Apple's push notification servers in order to send out push notifications. The push notifications will be sent whenever you tell Apple's server to send them. You can setup a cron job on your server to send out the push notifications at specific times/intervals. Here is a PHP tutorial that will teach you how to send out push notifications. Once you have the push notifications working, setting up the cron job should be easy.
您需要一个脚本连接到Apple的推送通知服务器才能发送推送通知。只要您告诉Apple的服务器发送推送通知,就会发送推送通知。您可以在服务器上设置cron作业,以特定时间/间隔发送推送通知。这是一个PHP教程,将教你如何发送推送通知。一旦推送通知正常工作,设置cron作业应该很容易。
If the app is open and receives a push notification the following method will be called on your UIApplication and you can decide how to react to the notification:
如果应用程序已打开并收到推送通知,则将在您的UIApplication上调用以下方法,您可以决定如何对通知做出反应:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
#1
1
Have you considered using local notifications instead? You can schedule it to go off at a certain time without having to make the server round-trip
您是否考虑过使用本地通知?您可以安排它在某个时间关闭,而无需使服务器往返
#2
0
You need a script to connect to Apple's push notification servers in order to send out push notifications. The push notifications will be sent whenever you tell Apple's server to send them. You can setup a cron job on your server to send out the push notifications at specific times/intervals. Here is a PHP tutorial that will teach you how to send out push notifications. Once you have the push notifications working, setting up the cron job should be easy.
您需要一个脚本连接到Apple的推送通知服务器才能发送推送通知。只要您告诉Apple的服务器发送推送通知,就会发送推送通知。您可以在服务器上设置cron作业,以特定时间/间隔发送推送通知。这是一个PHP教程,将教你如何发送推送通知。一旦推送通知正常工作,设置cron作业应该很容易。
If the app is open and receives a push notification the following method will be called on your UIApplication and you can decide how to react to the notification:
如果应用程序已打开并收到推送通知,则将在您的UIApplication上调用以下方法,您可以决定如何对通知做出反应:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo