Gonesh k r
Gonesh k r

Reputation: 35

how to set array of date to fireDate in local notification at a time

Actually in my app I'm starting more than two timers at different times. After certain time intervals I want notifications to fire. It's working fine when the app is on foreground but not in the background. How can I solve this?

Please help. Thanks!

Upvotes: 1

Views: 408

Answers (2)

Nilesh
Nilesh

Reputation: 699

you can handle with both timer into this appdelgate method

- (void)applicationDidEnterBackground:(UIApplication *)application {
}

when app going to background that time this method is called and your code still execute into this method, Hope this will help you.

Note : first enable background mode into Project Target -> Availability Tab -> Background Modes -> ON

Upvotes: 0

Mahendra
Mahendra

Reputation: 8924

You need to do following...

enter image description here

You need to turn on background mode.

In AppDelegate, Add this code to run app in background

Create a property

@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTask;

and then do following...

- (void)applicationDidEnterBackground:(UIApplication *)application {

    self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
        DLOG(@"End of tolerate time. Application should be suspended now if we do not ask more 'tolerance'");

    }];

    if (self.backgroundTask == UIBackgroundTaskInvalid) {
        DLOG(@"This application does not support background mode");
    } else {
        //if application supports background mode, we'll see this log.
        DLOG(@"Application will continue to run in background");
    }

}

I hope it will help you.

Upvotes: 1

Related Questions