Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit f11cbc7

Browse files
authored
Merge pull request #7 from Magic-Neko/sig
release: @react-native-oh-tpl/react-native-background-timer@2.4.1-0.0.2
2 parents 392884c + f9f5008 commit f11cbc7

File tree

16 files changed

+98
-832
lines changed

16 files changed

+98
-832
lines changed

OAT.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<oatconfig>
4+
<licensefile>LICENSE</licensefile>
5+
<policylist>
6+
<policy name="projectPolicy" desc="">
7+
<policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
8+
</policy>
9+
<policy name="projectPolicy" desc="">
10+
<policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/>
11+
<policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性"/>
12+
<policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
13+
<policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
14+
<policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
15+
</policy>
16+
</policylist>
17+
<filefilterlist>
18+
<filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
19+
<filteritem type="filepath" name="harmony/background_timer/hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
20+
<filteritem type="filepath" name="harmony/background_timer/src/main/cpp/generated/.*" desc="Codegen生成文件,不手动修改"/>
21+
<filteritem type="filepath" name="harmony/background_timer/src/main/ets/generated/.*" desc="Codegen生成文件,不手动修改"/>
22+
<filteritem type="filename" name="*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
23+
<filteritem type="filename" name="*/*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
24+
<filteritem type="filename" name="LICENSE" desc="版权文件,不添加版权头"/>
25+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
26+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
27+
<filteritem type="filepath" name="js/*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
28+
<filteritem type="filepath" name="js/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
29+
<filteritem type="filepath" name="src/*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
30+
<filteritem type="filepath" name="src/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
31+
<filteritem type="filepath" name="*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
32+
<filteritem type="filepath" name="*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
33+
<filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
34+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
35+
<filteritem type="filepath" name="hvigor/hvigor-config.json5" desc="工程模板,不修改版权头,以防有修改版权风险"/>
36+
</filefilter>
37+
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
38+
<filteritem type="filepath" name="harmony/background_timer/hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
39+
<filteritem type="filepath" name="harmony/background_timer/src/main/cpp/generated/.*" desc="Codegen生成文件,不手动修改"/>
40+
<filteritem type="filepath" name="harmony/background_timer/src/main/ets/generated/.*" desc="Codegen生成文件,不手动修改"/>
41+
<filteritem type="filename" name="*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
42+
<filteritem type="filename" name="*/*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
43+
<filteritem type="filename" name="LICENSE" desc="版权文件,不添加许可证头"/>
44+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不添加许可证头"/>
45+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不添加许可证头"/>
46+
<filteritem type="filepath" name="js/*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
47+
<filteritem type="filepath" name="js/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
48+
<filteritem type="filepath" name="src/*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
49+
<filteritem type="filepath" name="src/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
50+
<filteritem type="filepath" name="*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
51+
<filteritem type="filepath" name="*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
52+
<filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
53+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
54+
<filteritem type="filepath" name="hvigor/hvigor-config.json5" desc="工程模板,不修改版权头,以防有修改版权风险"/>
55+
</filefilter>
56+
57+
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies">
58+
<filteritem type="filepath" name="harmony/background_timer.har" desc="项目打包文件"/>
59+
</filefilter>
60+
</filefilterlist>
61+
</oatconfig>
62+
</configuration>

README.OpenSource

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"Name": "react-native-background-timer",
4+
"License": "MIT License",
5+
"License File": "https://github.com/react-native-oh-library/react-native-background-timer/blob/sig/LICENSE",
6+
"Version Number": "3.0.0-alpha.1",
7+
"Owner" : "xiafeng@huawei.com",
8+
"Upstream URL": "https://github.com/react-native-oh-library/react-native-background-timer",
9+
"Description": "A <LinearGradient> element for React Native"
10+
}
11+
]

README.md

Lines changed: 7 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,176 +1,13 @@
1-
# React Native Background Timer
2-
Emit event periodically (even when app is in the background).
1+
# @react-native-oh-tpl/react-native-background-timer
32

4-
## Installation
5-
1. If you use Expo to create a project [you'll just need to](https://facebook.github.io/react-native/docs/getting-started#caveats) "[eject](https://docs.expo.io/versions/latest/expokit/eject)".
3+
## 文档地址 / Documentation URL
64

7-
```bash
8-
expo eject
9-
```
5+
[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-background-timer.md)
106

11-
2. Install React Native Background Timer package.
7+
## Codegen
128

13-
```bash
14-
yarn add react-native-background-timer
15-
# or using npm
16-
npm install react-native-background-timer --save
17-
```
9+
该库已接入 codegen,具体请查阅文档。
1810

19-
3. Link React Native Background Timer library. This step is not necessary when you use React Native >= 0.60 (and your app is not ejected from Expo).
11+
## 请悉知 / Acknowledgements
2012

21-
```bash
22-
react-native link react-native-background-timer
23-
```
24-
25-
4. If you use CocoaPods or React Native >= 0.60 (and your app is not ejected from Expo) or your app is ejected from Expo, then before running your app on iOS, make sure you have CocoaPods installed and run:
26-
27-
```bash
28-
cd ios
29-
pod install
30-
```
31-
32-
Link the library manually if you get errors:
33-
34-
- Android: `TypeError: Cannot read property 'setTimeout' of undefined` or `TypeError: null is not an object (evaluating 'RNBackgroundTimer.setTimeout')`
35-
- iOS: `Native module cannot be null`
36-
37-
<details>
38-
<summary>Android manual linking</summary>
39-
40-
- `android/settings.gradle`
41-
42-
```diff
43-
+ include ':react-native-background-timer'
44-
+ project(':react-native-background-timer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-timer/android')
45-
```
46-
47-
- `android/app/build.gradle`
48-
49-
```diff
50-
dependencies {
51-
+ implementation project(':react-native-background-timer')
52-
}
53-
```
54-
55-
- `android/app/src/main/java/com/your-app/MainApplication.java`
56-
57-
```diff
58-
+ import com.ocetnik.timer.BackgroundTimerPackage;
59-
60-
@Override
61-
protected List<ReactPackage> getPackages() {
62-
return Arrays.<ReactPackage>asList(
63-
+ new BackgroundTimerPackage()
64-
);
65-
}
66-
```
67-
</details>
68-
69-
<details>
70-
<summary>iOS manual linking</summary>
71-
72-
- `ios/Podfile`
73-
74-
```diff
75-
+ pod 'react-native-background-timer', :path => '../node_modules/react-native-background-timer'
76-
```
77-
</details>
78-
79-
## Usage
80-
81-
```js
82-
import BackgroundTimer from 'react-native-background-timer';
83-
```
84-
85-
### Crossplatform
86-
To use the same code both on Android and iOS use runBackgroundTimer() and stopBackgroundTimer(). There can be used only one background timer to keep code consistent.
87-
88-
```js
89-
BackgroundTimer.runBackgroundTimer(() => {
90-
//code that will be called every 3 seconds
91-
},
92-
3000);
93-
//rest of code will be performing for iOS on background too
94-
95-
BackgroundTimer.stopBackgroundTimer(); //after this call all code on background stop run.
96-
```
97-
98-
### iOS
99-
After iOS update logic of background task little bit changed. So we can't use as it was.
100-
You have to use only start() and stop() without parameters. And all code that is performing will continue performing on background including all setTimeout() timers.
101-
102-
Example:
103-
```js
104-
BackgroundTimer.start();
105-
// Do whatever you want incuding setTimeout;
106-
BackgroundTimer.stop();
107-
```
108-
109-
> If you call stop() on background no new tasks will be started!
110-
> Don't call .start() twice, as it stop performing previous background task and starts new.
111-
> If it will be called on backgound no tasks will run.
112-
113-
### Android
114-
You can use the `setInterval` and `setTimeout` functions.
115-
This API is identical to that of `react-native` and can be used to quickly replace existing timers
116-
with background timers.
117-
118-
```js
119-
// Start a timer that runs continuous after X milliseconds
120-
const intervalId = BackgroundTimer.setInterval(() => {
121-
// this will be executed every 200 ms
122-
// even when app is the the background
123-
console.log('tic');
124-
}, 200);
125-
126-
// Cancel the timer when you are done with it
127-
BackgroundTimer.clearInterval(intervalId);
128-
```
129-
130-
```js
131-
// Start a timer that runs once after X milliseconds
132-
const timeoutId = BackgroundTimer.setTimeout(() => {
133-
// this will be executed once after 10 seconds
134-
// even when app is the the background
135-
console.log('tac');
136-
}, 10000);
137-
138-
// Cancel the timeout if necessary
139-
BackgroundTimer.clearTimeout(timeoutId);
140-
```
141-
142-
### Obsolete
143-
Obsolete usage which doesn't support multiple background timers.
144-
145-
```js
146-
import {
147-
DeviceEventEmitter,
148-
NativeAppEventEmitter,
149-
Platform,
150-
} from 'react-native';
151-
152-
import BackgroundTimer from 'react-native-background-timer';
153-
```
154-
155-
```js
156-
const EventEmitter = Platform.select({
157-
ios: () => NativeAppEventEmitter,
158-
android: () => DeviceEventEmitter,
159-
})();
160-
```
161-
162-
```js
163-
// start a global timer
164-
BackgroundTimer.start(5000); // delay in milliseconds only for Android
165-
```
166-
```js
167-
// listen for event
168-
EventEmitter.addListener('backgroundTimer', () => {
169-
// this will be executed once after 5 seconds
170-
console.log('toe');
171-
});
172-
```
173-
```js
174-
// stop the timer
175-
BackgroundTimer.stop();
176-
```
13+
本项目基于 [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-background-timer/blob/sig/LICENSE) ,请自由地享受和参与开源。

android/build.gradle

Lines changed: 0 additions & 20 deletions
This file was deleted.

android/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

android/src/main/java/com/ocetnik/timer/BackgroundTimerModule.java

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)