react-native-auto-updater
react-native-auto-updater copied to clipboard
[Android] Add Readme info for usage with RN >= 0.29.0
React Native 0.29.0 modified the application template to have two files:
- MainActivity.java
- MainApplication.java
It'd be great if the docs could be updated to show usage info for it.
It appears to me that to install this package in RN >= 0.29 apps the following changes need to be made.
in MainApplication.java:
import com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdaterPackage;
import javax.annotation.Nullable;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
// add this method here
/**
* Name of the JS Bundle file shipped with the app.
* This file has to be added as an Android Asset.
* */
@Nullable
@Override
protected String getBundleAssetName() {
return "main.android.jsbundle";
}
// add package to list here
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new ReactNativeAutoUpdaterPackage(),
new MainReactPackage()
);
}
And in MainActivity.java:
import com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdater;
import com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdater.ReactNativeAutoUpdaterUpdateType;
import com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdater.ReactNativeAutoUpdaterFrequency;
import com.aerofs.reactnativeautoupdater.ReactNativeAutoUpdaterActivity;
/**
* If your updates metadata JSON has a relative URL for downloading
* the JS bundle, set this hostname.
* */
@Override
protected String getHostnameForRelativeDownloadURLs() {
return "https://www.aerofs.com";
}
/**
* Decide what type of updates to download.
* Available options -
* MAJOR - will download only if major version number changes
* MINOR - will download if major or minor version number changes
* PATCH - will download for any version change
* default value - PATCH
* */
@Override
protected ReactNativeAutoUpdaterUpdateType getAllowedUpdateType() {
return ReactNativeAutoUpdater.ReactNativeAutoUpdaterUpdateType.MINOR;
}
/**
* Decide how frequently to check for updates.
* Available options -
* EACH_TIME - each time the app starts
* DAILY - maximum once per day
* WEEKLY - maximum once per week
* default value - EACH_TIME
* */
@Override
protected ReactNativeAutoUpdaterFrequency getUpdateFrequency() {
return ReactNativeAutoUpdaterFrequency.EACH_TIME;
}
/**
* To show progress during the update process.
* */
@Override
protected boolean getShowProgress() {
return false;
}
/**
* URL for the metadata of the update.
* */
@Override
protected String getUpdateMetadataUrl() {
return "https://www.aerofs.com/u/8691535/update.android.json";
}
/**
* Name of the metadata file shipped with the app.
* This metadata is used to compare the shipped JS code against the updates.
* */
@Override
protected String getMetadataAssetName() {
return "metadata.android.json";
}
Good catch! We haven't upgraded to RN 0.29 yet. If you could make the changes to the README files, I would be happy to take a look at your pull request. Thanks!