This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,18 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
Pod::Spec.new do |s|
s.name = 'UMTaskManagerInterface'
s.version = package['version']
s.summary = package['description']
s.description = package['description']
s.license = package['license']
s.author = package['author']
s.homepage = package['homepage']
s.platform = :ios, '10.0'
s.source = { git: 'https://github.com/expo/expo.git' }
s.source_files = 'UMTaskManagerInterface/**/*.{h,m}'
s.preserve_paths = 'UMTaskManagerInterface/**/*.{h,m}'
s.requires_arc = true
end

View File

@ -0,0 +1,63 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <UMTaskManagerInterface/UMTaskInterface.h>
#import <UMTaskManagerInterface/UMTaskLaunchReason.h>
// Interface for task consumers. Task consumers are the objects that are responsible for handling tasks.
// Consumers are getting signals from TaskManager (and service) about a few events that are happening during task's lifecycle.
@protocol UMTaskConsumerInterface <NSObject>
@property (nonatomic, strong) id<UMTaskInterface> __nullable task;
@required
/**
* The type of the task, like "location" or "geofencing".
*/
- (nonnull NSString *)taskType;
/**
* Called by UMTaskService when the task is created and associated with the consumer.
*/
- (void)didRegisterTask:(nonnull id<UMTaskInterface>)task;
@optional
/**
* Static method returning boolean value whether the consumer supports launch reason.
*/
+ (BOOL)supportsLaunchReason:(UMTaskLaunchReason)launchReason;
/**
* Version of the consumer. Increase returned number in case of any breaking changes made to the task consumer,
* so the existing tasks will be automatically unregistered when the native code gets upgraded.
*/
+ (NSUInteger)taskConsumerVersion;
/**
* Sets options for the task.
*/
- (void)setOptions:(nonnull NSDictionary *)options;
/**
* Called by UMTaskService to inform the consumer that the associated task is ready to be executed.
*/
- (void)didBecomeReadyToExecute;
/**
* Called right after the task has been unregistered.
*/
- (void)didUnregister;
/**
* Called by UMTaskManager when the task has been completed and we received a result from JS app.
*/
- (void)didFinish;
/**
* Method used to normalize task result that comes from JS app.
*/
- (NSUInteger)normalizeTaskResult:(nullable id)result;
@end

View File

@ -0,0 +1,38 @@
// Copyright 2015-present 650 Industries. All rights reserved.
// forward declaration for consumer interface
@protocol UMTaskConsumerInterface;
@protocol UMTaskInterface
/**
* Name of the task.
*/
@property (nonatomic, strong, readonly) NSString *__nonnull name;
/**
* Identifier of the application for which the task was created.
*/
@property (nonatomic, strong, readonly) NSString *__nonnull appId;
/**
* The URL to the application for which the task was created.
*/
@property (nonatomic, strong, readonly) NSString *__nonnull appUrl;
/**
* Task consumer instance that is responsible for handling (consuming) this task.
*/
@property (nonatomic, strong, readonly) id<UMTaskConsumerInterface> __nonnull consumer;
/**
* Options passed to the task.
*/
@property (nonatomic, strong) NSDictionary *__nullable options;
/**
* Executes the task with given dictionary data and given error.
*/
- (void)executeWithData:(nullable NSDictionary *)data withError:(nullable NSError *)error;
@end

View File

@ -0,0 +1,12 @@
// Copyright 2018-present 650 Industries. All rights reserved.
typedef enum {
UMTaskLaunchReasonUnrecognized,
UMTaskLaunchReasonUser,
UMTaskLaunchReasonBluetoothCentrals,
UMTaskLaunchReasonBluetoothPeripherals,
UMTaskLaunchReasonBackgroundFetch,
UMTaskLaunchReasonLocation,
UMTaskLaunchReasonNewsstandDownloads,
UMTaskLaunchReasonRemoteNotification,
} UMTaskLaunchReason;

View File

@ -0,0 +1,55 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <UMTaskManagerInterface/UMTaskInterface.h>
NS_ASSUME_NONNULL_BEGIN
// Interface for UMTaskManager module.
@protocol UMTaskManagerInterface
/**
* Returns boolean value whether task with given taskName has been registered by the app.
*/
- (BOOL)hasRegisteredTaskWithName:(NSString *)taskName;
/**
* Returns boolean value whether or not the task's consumer is a member of given class.
*/
- (BOOL)taskWithName:(NSString *)taskName hasConsumerOfClass:(Class)consumerClass;
/**
* Registers task with given name, task consumer class and options.
* Can throw an exception if task with given name is already registered
* or given consumer class doesn't conform to UMTaskConsumerInterface protocol.
*/
- (void)registerTaskWithName:(NSString *)taskName
consumer:(Class)consumerClass
options:(NSDictionary *)options;
/**
* Unregisters task with given name and consumer class.
* Can throw an exception if the consumer class mismatches.
*/
- (void)unregisterTaskWithName:(NSString *)taskName
consumerClass:(nullable Class)consumerClass;
/**
* Returns boolean value whether the application contains
* given backgroundMode in UIBackgroundModes field in Info.plist file.
*/
- (BOOL)hasBackgroundModeEnabled:(NSString *)backgroundMode;
/**
* Called by task manager service to send an event with given body.
*/
- (void)executeWithBody:(NSDictionary *)body;
/**
* Whether or not the module was initialized for headless (background) JS app.
*/
- (BOOL)isRunningInHeadlessMode;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,67 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <UMTaskManagerInterface/UMTaskInterface.h>
@protocol UMTaskServiceInterface
/**
* Returns boolean value whether the task with given name is already registered for given appId.
*/
- (BOOL)hasRegisteredTaskWithName:(nonnull NSString *)taskName
forAppId:(nonnull NSString *)appId;
/**
* Registers task in any kind of persistent storage, so it could be restored in future sessions.
*/
- (void)registerTaskWithName:(nonnull NSString *)taskName
appId:(nonnull NSString *)appId
appUrl:(nonnull NSString *)appUrl
consumerClass:(nonnull Class)consumerClass
options:(nullable NSDictionary *)options;
/**
* Unregisters task with given name and for given appId. If consumer class is provided,
* it can throw an exception if task's consumer is not a member of that class.
*/
- (void)unregisterTaskWithName:(nonnull NSString *)taskName
forAppId:(nonnull NSString *)appId
consumerClass:(nullable Class)consumerClass;
/**
* Unregisters all tasks registered for the app with given appId.
*/
- (void)unregisterAllTasksForAppId:(nonnull NSString *)appId;
/**
* Returns boolean value whether or not the task's consumer is a member of given class.
*/
- (BOOL)taskWithName:(nonnull NSString *)taskName
forAppId:(nonnull NSString *)appId
hasConsumerOfClass:(nonnull Class)consumerClass;
/**
* Returns options associated with the task with given name and appId or nil if task not found.
*/
- (nullable NSDictionary *)getOptionsForTaskName:(nonnull NSString *)taskName
forAppId:(nonnull NSString *)appId;
/**
* Returns an array of registered tasks for given appId.
*/
- (nonnull NSArray *)getRegisteredTasksForAppId:(nullable NSString *)appId;
/**
* Notifies the service that a task has just finished.
*/
- (void)notifyTaskWithName:(nonnull NSString *)taskName
forAppId:(nonnull NSString *)appId
didFinishWithResponse:(nonnull NSDictionary *)response;
/**
* Passes a reference of task manager for given appId to the service.
*/
- (void)setTaskManager:(nonnull id<UMTaskManagerInterface>)taskManager
forAppId:(nonnull NSString *)appId
withUrl:(nonnull NSString *)appUrl;
@end