Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

iOS library which schedules the execution of tasks on a background fetch

License

Notifications You must be signed in to change notification settings

sencloudx/Selene

Repository files navigation

Selene: Background Task Scheduler

Selene is an iOS library which schedules the execution of tasks on a background fetch.

Build Status

Installation

CocoaPods

Add to your Podfile: pod Selene

Submodule

You can also add this repo as a submodule and copy everything in the Selene folder into your project.

Use

1) Add the fetch background mode in your app’s Info.plist file.

2) Create a task

A task must conform to SLNTaskProtocol. For example:

@interface SampleTask: NSObject<SLNTaskProtocol>
@end
@implementation SampleTask
+ (NSString *)identifier {
 return NSStringFromClass(self);
}
+ (NSOperation *)operationWithCompletion:(SLNTaskCompletion_t)completion {
 NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
 // Do some work ....
 completion(UIBackgroundFetchResultNoData);
 }];
 return operation;
}
+ (CGFloat)averageResponseTime {
 return 5.0;
}
+ (SLNTaskPriority)priority {
 return SLNTaskPriorityLow;
}
@end

3) Add the task class to the scheduler

NSArray *tasks = @[[SomeTask class]];
// Run the scheduler every 5 minutes
[SLNScheduler setMinimumBackgroundFetchInterval:60 * 5];
// Add the tasks
[SLNScheduler scheduleTasks:tasks];

In the application delegate:

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
 [SLNScheduler startWithCompletion:completionHandler];
}

Interested? Here's the blog post

About

iOS library which schedules the execution of tasks on a background fetch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 97.4%
  • Ruby 2.6%

AltStyle によって変換されたページ (->オリジナル) /