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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?