[英]Display UIAlertView on certain date?
I was wondering how I'd make a UIAlertView display on a certain date, for example, users download the iPhone application and then on the 12th August, a predetermined UIAlertView displays? 我想知道如何在特定日期显示UIAlertView,例如,用户下载iPhone应用程序,然后在8月12日,预定的UIAlertView显示? How could I do this?
我该怎么办?
Thanks! 谢谢!
You should take a look at the UILocalNotification API. 您应该看看UILocalNotification API。 It allows you to create and schedule local notification for your application, which will then be fired on the desired date, using a badge/popover/sound (same settings as for the remote notification API).
它允许您为应用程序创建和安排本地通知,然后使用徽章/弹出窗口/声音(与远程通知API的设置相同)在所需的日期触发该通知。
For your case you should specifically take a look at the fire date . 对于您的情况,您应该专门查看开火日期 。 Sample code would look moreless like this:
示例代码看起来像这样:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = @"Your message here";
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60*60];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
This will fire a local notification with a "Your message here" text in one hour. 这将在一小时内触发带有“您的消息在这里”文本的本地通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.