1 // Copyright 2015-present 650 Industries. All rights reserved. 2 3 #import <ExpoModulesCore/EXTaskInterface.h> 4 #import <ExpoModulesCore/EXTaskLaunchReason.h> 5 6 // Interface for task consumers. Task consumers are the objects that are responsible for handling tasks. 7 // Consumers are getting signals from TaskManager (and service) about a few events that are happening during task's lifecycle. 8 9 @protocol EXTaskConsumerInterface <NSObject> 10 11 @property (nonatomic, strong) id<EXTaskInterface> __nullable task; 12 13 @required 14 15 /** 16 * The type of the task, like "location" or "geofencing". 17 */ 18 - (nonnull NSString *)taskType; 19 20 /** 21 * Called by EXTaskService when the task is created and associated with the consumer. 22 */ 23 - (void)didRegisterTask:(nonnull id<EXTaskInterface>)task; 24 25 @optional 26 27 /** 28 * Static method returning boolean value whether the consumer supports launch reason. 29 */ 30 + (BOOL)supportsLaunchReason:(EXTaskLaunchReason)launchReason; 31 32 /** 33 * Version of the consumer. Increase returned number in case of any breaking changes made to the task consumer, 34 * so the existing tasks will be automatically unregistered when the native code gets upgraded. 35 */ 36 + (NSUInteger)taskConsumerVersion; 37 38 /** 39 * Sets options for the task. 40 */ 41 - (void)setOptions:(nonnull NSDictionary *)options; 42 43 /** 44 * Called by EXTaskService to inform the consumer that the associated task is ready to be executed with accompanying data. 45 */ 46 - (void)didBecomeReadyToExecuteWithData:(nullable NSDictionary *)data; 47 48 /** 49 * Called right after the task has been unregistered. 50 */ 51 - (void)didUnregister; 52 53 /** 54 * Called by EXTaskManager when the task has been completed and we received a result from JS app. 55 */ 56 - (void)didFinish; 57 58 /** 59 * Method used to normalize task result that comes from JS app. 60 */ 61 - (NSUInteger)normalizeTaskResult:(nullable id)result; 62 63 @end 64