Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone App - Generate Alert Popups when App is Closed

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.

like image 398
Ryan Avatar asked Dec 08 '25 08:12

Ryan


2 Answers

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];
like image 157
Smikey Avatar answered Dec 10 '25 02:12

Smikey


Sorry buddy, not possible.

There might be solutions for a popup when the app is reopened, but not when it's closed and without push.

EDIT: Actually, yes!!, but it's janktacular. You can create an .ical file with let's say, 15 minute alerts, sync it to a caldav/webdav server and have the iPhone subscribe to it in the Mail/Contacts/Calendars settings pane. Check out Omnifocus, this is their push work around. It syncs things that are due to my MobileMe iDisk, and I subscribed to the calendar - Boom, notifications.

like image 43
nullArray Avatar answered Dec 10 '25 02:12

nullArray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!