iPhone应用程序 - 应用程序关闭时生成警报弹出窗口 [英] iPhone App - Generate Alert Popups when App is Closed

查看:215
本文介绍了iPhone应用程序 - 应用程序关闭时生成警报弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建iPhone应用程序时,是否可以在应用程序关闭时在iphone上生成弹出警报(类似于推送通知)。一个简单的例子就是拥有一个可以在2010年1月5日下午5点设置提醒的应用程序。该应用程序可以关闭,并在那时弹出提醒。我不认为这是可能的,但想知道是否有人有任何想法?同样,我不想要一个Push解决方案,而是一个不需要互联网访问的解决方案(即iPhone的本地推送)。谢谢。

In creating an iPhone app, is it possible to generate a popup alert on the iphone (similar to a Push notification) when the app has been closed. A simple example would be to have an app that can set a reminder at 5:00PM January 5th, 2010. The app can be closed and the reminder will popup at that time. I don't think this is possible but would like to know if anyone has any ideas? Again, i do not want a Push solution but rather a solution that does not require internet access (i.e. "local" push from iPhone). Thanks.

推荐答案

你现在可以做到!它真的很简单。创建UILocalNotification。

You can do it now! And it's really rather simple. Create a UILocalNotification.

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
        if (localNotification == nil)
            return;
//Initialise notification
        localNotification.fireDate = yourDate;
        localNotification.timeZone = [NSTimeZone defaultTimeZone];
        localNotification.alertBody = [NSString stringWithFormat:NSLocalizedString(@"Hey, you've forgotten something", nil)];
        localNotification.alertAction = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), buttonTitle];
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
        [warningDate release];
        [localNotification release];

这篇关于iPhone应用程序 - 应用程序关闭时生成警报弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆