|
1 | 1 | # react-native-rn-in-app-update
|
2 | 2 |
|
3 |
| -## Getting started |
| 3 | +Google in-app updates support for react-native. Specially created for android only. After installing plugin user will get android app update popup if there is any update available on play store. |
| 4 | + |
| 5 | +## Installation |
4 | 6 |
|
5 | 7 | `$ npm install react-native-rn-in-app-update --save`
|
6 | 8 |
|
7 |
| -### Manual installation for (RN < 0.60) |
| 9 | +## Linking (RN < 0.60) |
8 | 10 |
|
9 | 11 | `$ react-native link react-native-rn-in-app-update`
|
10 | 12 |
|
11 |
| -## Add Below Lines in MainActivity.java |
| 13 | + |
| 14 | +## Additional configuration in android (Required) |
| 15 | + |
| 16 | +### Add Below Lines in MainActivity.java |
12 | 17 |
|
13 | 18 | => Import package:
|
14 |
| -import com.logicwind.inappupdate.InAppUpdateUtils; |
| 19 | +``` |
| 20 | +... |
| 21 | +... |
| 22 | +import com.logicwind.inappupdate.InAppUpdateUtils; // add this |
15 | 23 |
|
16 | 24 | => Create object :
|
17 | 25 | private InAppUpdateUtils appUpdateUtils;
|
18 | 26 |
|
19 |
| -=> Add below lines in OnCreate method : |
20 |
| -appUpdateUtils = new InAppUpdateUtils(this); |
21 |
| -appUpdateUtils.initAppUpdaterAndCheckForUpdate(); |
22 |
| -appUpdateUtils.registerListener(); |
23 | 27 |
|
24 |
| -=> Add below methods also : |
| 28 | +@Override |
| 29 | +protected void onCreate(Bundle savedInstanceState) { |
| 30 | + ... |
| 31 | + ... |
| 32 | + appUpdateUtils = new InAppUpdateUtils(this); // add this |
| 33 | + appUpdateUtils.initAppUpdaterAndCheckForUpdate(); // add this |
| 34 | + appUpdateUtils.registerListener(); // add this |
| 35 | +} |
| 36 | +
|
| 37 | +// Add below method also |
25 | 38 | @Override
|
26 | 39 | protected void onResume() {
|
27 |
| -super.onResume(); |
28 |
| -appUpdateUtils.ifUpdateDownloadedThenInstall(); |
| 40 | + super.onResume(); |
| 41 | + appUpdateUtils.ifUpdateDownloadedThenInstall(); |
29 | 42 | }
|
30 | 43 |
|
| 44 | +// Add below method also |
31 | 45 | @Override
|
32 |
| -protected void onDestroy() { |
33 |
| -super.onDestroy(); |
34 |
| -appUpdateUtils.unregisterListener(); |
| 46 | + protected void onDestroy() { |
| 47 | + super.onDestroy(); |
| 48 | + appUpdateUtils.unregisterListener(); |
35 | 49 | }
|
| 50 | +``` |
| 51 | + |
| 52 | +### That's it. Configuration done. No need to add anything in your application js file. |
0 commit comments