iPhone App - Generate Alert Popups when App is Closed

為{幸葍}努か 提交于 2019-12-01 10:55:23

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];

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.

Unfortunately, no. This would require some sort of background processing for your app, and that is not allowed in the current iPhone SDK. Push notifications are the only solution I'm afraid.

If it's an issue of development effort, I know Urban Airship has some solutions to make Push Notifications easier.

Nope, you'd have to use push notifications. Your app would have to be running to display any alerts.

All the workarounds I can think of would require internet access: add an event to a calendar somehow, or again, use push notifications. urbanairship.com has a pretty straightforward push notification service you could utilize.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!