iPhone App - Generate Alert Popups when App is Closed

前端 未结 4 560
再見小時候
再見小時候 2021-01-15 05:34

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 t

相关标签:
4条回答
  • 2021-01-15 05:43

    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.

    0 讨论(0)
  • 2021-01-15 05:55

    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];
    
    0 讨论(0)
  • 2021-01-15 06:07

    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.

    0 讨论(0)
  • 2021-01-15 06:09

    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.

    0 讨论(0)
提交回复
热议问题