Selene

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

  • 所有者: LinkedInAttic/Selene
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

主要指标

概览
名称与所有者LinkedInAttic/Selene
主编程语言Objective-C
编程语言Ruby (语言数: 2)
平台
许可证Apache License 2.0
所有者活动
创建于2014-08-13 17:44:03
推送于2018-09-13 18:55:35
最后一次提交2018-09-13 11:55:03
发布数10
最新版本名称2.0.0 (发布于 )
第一版名称1.0.0 (发布于 )
用户参与
星数641
关注者数36
派生数35
提交数32
已启用问题?
问题数2
打开的问题数0
拉请求数1
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?