forked from transistorsoft/react-native-background-fetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
177 lines (173 loc) · 8.5 KB
/
index.d.ts
File metadata and controls
177 lines (173 loc) · 8.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
declare module "react-native-background-fetch" {
interface BackgroundFetchConfig {
/**
* The minimum interval in minutes to execute background fetch events. Defaults to 15 minutes. Minimum is 15 minutes.
*/
minimumFetchInterval?:number;
/**
* [Android only] Set false to continue background-fetch events after user terminates the app. Default to true.
*/
stopOnTerminate?:boolean;
/**
* [Android only] Set true to initiate background-fetch events when the device is rebooted. Defaults to false.
*/
startOnBoot?:boolean;
/**
* [Android only] Set true to automatically relaunch the application (if it was terminated) -- the application will launch to the foreground then immediately minimize. Defaults to false.
*/
forceReload?:boolean;
/**
* [Android only] Set true to enable Headless mechanism for handling fetch events after app termination.
*/
enableHeadless?:boolean;
/**
* [Android only] Set detailed description of the kind of network your job requires.
*
* If your job doesn't need a network connection, you don't need to use this option, as the default is [[BackgroundFetch.NEWORK_TYPE_NONE]].
*
* Calling this method defines network as a strict requirement for your job. If the network requested is not available your job will never run.
*/
requiredNetworkType?:NetworkType;
/**
* [Android only] Specify that to run this job, the device's battery level must not be low.
*
* This defaults to false. If true, the job will only run when the battery level is not low, which is generally the point where the user is given a "low battery" warning.
*/
requiresBatteryNotLow?:boolean;
/**
* [Android only] Specify that to run this job, the device's available storage must not be low.
*
* This defaults to false. If true, the job will only run when the device is not in a low storage state, which is generally the point where the user is given a "low storage" warning.
*/
requiresStorageNotLow?:boolean;
/**
* [Android only] Specify that to run this job, the device must be charging (or be a non-battery-powered device connected to permanent power, such as Android TV devices). This defaults to false.
*/
requiresCharging?:boolean;
/**
* [Android only] When set true, ensure that this job will not run if the device is in active use.
*
* The default state is false: that is, the for the job to be runnable even when someone is interacting with the device.
*
* This state is a loose definition provided by the system. In general, it means that the device is not currently being used interactively, and has not been in use for some time. As such, it is a good time to perform resource heavy jobs. Bear in mind that battery usage will still be attributed to your application, and surfaced to the user in battery stats.
*/
requiresDeviceIdle?:boolean;
}
/**
* | BackgroundFetchStatus | Description |
* |------------------------------------|-------------------------------------------------|
* | BackgroundFetch.STATUS_RESTRICTED | Background fetch updates are unavailable and the user cannot enable them again. For example, this status can occur when parental controls are in effect for the current user. |
* | BackgroundFetch.STATUS_DENIED | The user explicitly disabled background behavior for this app or for the whole system. |
* | BackgroundFetch.STATUS_AVAILABLE | Background fetch is available and enabled. |
*/
type BackgroundFetchResult = 0 | 1 | 2;
/**
* | BackgroundFetchResult | Description |
* |---------------------------------------|---------------------------------------------------------------|
* | BackgroundFetch.FETCH_RESULT_NEW_DATA | New data was successfully downloaded. |
* | BackgroundFetch.FETCH_RESULT_NO_DATA | There was no new data to download. |
* | BackgroundFetch.FETCH_RESULT_FAILED | An attempt to download data was made but that attempt failed. |
*/
type BackgroundFetchStatus = 0 | 1 | 2;
/**
* | NetworkType | Description |
* |---------------------------------------|---------------------------------------------------------------|
* | BackgroundFetch.NETWORK_TYPE_NONE | This job doesn't care about network constraints, either any or none. |
* | BackgroundFetch.NETWORK_TYPE_ANY | This job requires network connectivity. |
* | BackgroundFetch.NETWORK_TYPE_CELLULAR | This job requires network connectivity that is a cellular network. |
* | BackgroundFetch.NETWORK_TYPE_UNMETERED | This job requires network connectivity that is unmetered. |
* | BackgroundFetch.NETWORK_TYPE_NOT_ROAMING | This job requires network connectivity that is not roaming. |
*/
type NetworkType = 0 | 1 | 2 | 3 | 4;
/**
* BackgroundFetch is a module to receive periodic callbacks (min every 15 min) while your app is running in the background or terminated.
*/
export default class BackgroundFetch {
/**
* Background fetch updates are unavailable and the user cannot enable them again. For example, this status can occur when parental controls are in effect for the current user.
*/
static STATUS_RESTRICTED: BackgroundFetchStatus;
/**
* The user explicitly disabled background behavior for this app or for the whole system.
*/
static STATUS_DENIED: BackgroundFetchStatus;
/**
* Background fetch is available and enabled.
*/
static STATUS_AVAILABLE: BackgroundFetchStatus;
/**
* New data was successfully downloaded.
*/
static FETCH_RESULT_NEW_DATA: BackgroundFetchResult;
/**
* There was no new data to download.
*/
static FETCH_RESULT_NO_DATA: BackgroundFetchResult;
/**
* An attempt to download data was made but that attempt failed.
*/
static FETCH_RESULT_FAILED: BackgroundFetchResult;
/**
* This job doesn't care about network constraints, either any or none.
*/
static NETWORK_TYPE_NONE: NetworkType;
/**
* This job requires network connectivity.
*/
static NETWORK_TYPE_ANY: NetworkType;
/**
* This job requires network connectivity that is a cellular network.
*/
static NETWORK_TYPE_CELLULAR: NetworkType;
/**
* This job requires network connectivity that is unmetered.
*/
static NETWORK_TYPE_UNMETERED: NetworkType;
/**
* This job requires network connectivity that is not roaming.
*/
static NETWORK_TYPE_NOT_ROAMING: NetworkType;
/**
* Initial configuration of BackgroundFetch, including config-options and Fetch-callback. The [[start]] method will automatically be executed.
*/
static configure(config:BackgroundFetchConfig, callback:() => void, failure?:(status:BackgroundFetchStatus) => void):void;
/**
* Add an extra fetch event listener in addition to the one initially provided to [[configure]].
* @event
*/
static onFetch(callback:() => void):void;
/**
* Start subscribing to fetch events.
*/
static start(success?:() => void, failure?:(status:BackgroundFetchStatus) => void):void;
/**
* Stop subscribing to fetch events.
*/
static stop():void;
/**
* You must execute [[finish]] within your fetch-callback to signal completion of your task. You may optionally provide a [[BackgroundFetchResult]]. If no result is provided, default to FETCH_RESULT_NEW_DATA.
*
* | BackgroundFetchResult |
* |---------------------------------------|
* | BackgroundFetch.FETCH_RESULT_NEW_DATA |
* | BackgroundFetch.FETCH_RESULT_NO_DATA |
* | BackgroundFetch.FETCH_RESULT_FAILED |
*
*/
static finish(result?:BackgroundFetchResult):void;
/**
* Query the BackgroundFetch API status
*
* | BackgroundFetchStatus | Description |
* |------------------------------------|-------------------------------------------------|
* | BackgroundFetch.STATUS_RESTRICTED | Background fetch updates are unavailable and the user cannot enable them again. For example, this status can occur when parental controls are in effect for the current user. |
* | BackgroundFetch.STATUS_DENIED | The user explicitly disabled background behavior for this app or for the whole system. |
* | BackgroundFetch.STATUS_AVAILABLE | Background fetch is available and enabled. |
*/
static status(callback:(status:BackgroundFetchStatus) => void):void;
/**
* [Android only] Register a function to execute when the app is terminated. Requires stopOnTerminate: false.
*/
static registerHeadlessTask(task:() => void):void;
}
}