Selene

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

  • Owner: LinkedInAttic/Selene
  • Platform:
  • License:: Apache License 2.0
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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 = @;
// 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

Main metrics

Overview
Name With OwnerLinkedInAttic/Selene
Primary LanguageObjective-C
Program languageRuby (Language Count: 2)
Platform
License:Apache License 2.0
所有者活动
Created At2014-08-13 17:44:03
Pushed At2018-09-13 18:55:35
Last Commit At2018-09-13 11:55:03
Release Count10
Last Release Name2.0.0 (Posted on )
First Release Name1.0.0 (Posted on )
用户参与
Stargazers Count641
Watchers Count36
Fork Count35
Commits Count32
Has Issues Enabled
Issues Count2
Issue Open Count0
Pull Requests Count1
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private