iPhone应用程序 - 应用程序关闭时生成警报弹出窗口

Rya*_*yan 2 iphone sdk notifications reminders alerts

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

Smi*_*key 10

你现在可以做到!它真的很简单.创建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];
Run Code Online (Sandbox Code Playgroud)