How to use rn-update-apk - 10 common examples

To help you get started, we’ve selected a few rn-update-apk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mikehardy / react-native-update-apk / example / App.js View on Github external
.catch(rej => {

        // Modern SSL servers have gotten more strict about which SSL/TLS protocols/versions they allow.
        // If you arrived here, you have an old device with an unpatchable SSL Provider, your downloads will probably fail.
        // You should provide some sort of messaging to these users or provide updates over HTTP as needed
        // Luckily this only applies to Android 4.x without Google Play Services, a very small percentage.
        console.log("SSL Provider patch failed", rej);
        let message = "Old Android API, and SSL Provider could not be patched.";
        if (rej.message.includes("repairable")) {

          // In this particular case the user may even be able to fix it with a Google Play Services update
          message +=
            " This is repairable on this device though." +
            " You should send the users to the Play Store to update Play Services...";
          Alert.alert("Possible SSL Problem", message);
          UpdateAPK.patchSSLProvider(false, true); // This will ask Google Play Services to help the user repair
        } else {
          Alert.alert("Possible SSL Problem", message);
        }
      });
github mikehardy / react-native-update-apk / example / App.js View on Github external
async componentDidMount() {

    // If you want to update devices below Android 5, they have SSL issues with some servers.
    // You will get a protocol error unless you patch the SSL Provider.
    // This will fail if they don't have Google Play Services installed though.
    // You can optionally force the patch on Android 5+ with boolean param 1
    // You can also optionally display a Google dialog for user repair (if possible) with boolean param 2
    UpdateAPK.patchSSLProvider() 
      .then(ret => {

        // This means 
        console.log("SSL Provider Patch proceeded without error");
      })
      .catch(rej => {

        // Modern SSL servers have gotten more strict about which SSL/TLS protocols/versions they allow.
        // If you arrived here, you have an old device with an unpatchable SSL Provider, your downloads will probably fail.
        // You should provide some sort of messaging to these users or provide updates over HTTP as needed
        // Luckily this only applies to Android 4.x without Google Play Services, a very small percentage.
        console.log("SSL Provider patch failed", rej);
        let message = "Old Android API, and SSL Provider could not be patched.";
        if (rej.message.includes("repairable")) {

          // In this particular case the user may even be able to fix it with a Google Play Services update
github mikehardy / react-native-update-apk / example / App.js View on Github external
console.log("SSL Provider patch failed", rej);
        let message = "Old Android API, and SSL Provider could not be patched.";
        if (rej.message.includes("repairable")) {

          // In this particular case the user may even be able to fix it with a Google Play Services update
          message +=
            " This is repairable on this device though." +
            " You should send the users to the Play Store to update Play Services...";
          Alert.alert("Possible SSL Problem", message);
          UpdateAPK.patchSSLProvider(false, true); // This will ask Google Play Services to help the user repair
        } else {
          Alert.alert("Possible SSL Problem", message);
        }
      });

      UpdateAPK.getApps().then(apps => {
        console.log("Installed Apps: ", JSON.stringify(apps));
        this.setState({ allApps: apps});
      }).catch(e => console.log("Unable to getApps?", e));

      UpdateAPK.getNonSystemApps().then(apps => {
        console.log("Installed Non-System Apps: ", JSON.stringify(apps));
        this.setState({ allNonSystemApps: apps});
      }).catch(e => console.log("Unable to getNonSystemApps?", e));
    }
github mikehardy / react-native-update-apk / example / App.js View on Github external
message +=
            " This is repairable on this device though." +
            " You should send the users to the Play Store to update Play Services...";
          Alert.alert("Possible SSL Problem", message);
          UpdateAPK.patchSSLProvider(false, true); // This will ask Google Play Services to help the user repair
        } else {
          Alert.alert("Possible SSL Problem", message);
        }
      });

      UpdateAPK.getApps().then(apps => {
        console.log("Installed Apps: ", JSON.stringify(apps));
        this.setState({ allApps: apps});
      }).catch(e => console.log("Unable to getApps?", e));

      UpdateAPK.getNonSystemApps().then(apps => {
        console.log("Installed Non-System Apps: ", JSON.stringify(apps));
        this.setState({ allNonSystemApps: apps});
      }).catch(e => console.log("Unable to getNonSystemApps?", e));
    }
github mikehardy / react-native-update-apk / example / App.js View on Github external
constructor(props) {
    super(props);
    this.state = {
      // If you have something in state, you will be able to provide status to users
      downloadProgress: -1,
      allApps: [],
      allNonSystemApps: [],
    };

    updater = new UpdateAPK.UpdateAPK({

      // iOS must use App Store and this is the app ID. This is a sample: "All Birds of Ecuador" (¡Qué lindo!)
      iosAppId: "1104809018", 

      apkVersionUrl:
        "https://raw.githubusercontent.com/mikehardy/react-native-update-apk/master/example/test-version.json",

      // The name of this 'fileProviderAuthority' is defined in AndroidManifest.xml. THEY MUST MATCH.
      // By default other modules like rn-fetch-blob define one (conveniently named the same as below)
      // but if you don't match the names you will get an odd-looking XML exception:
      // "Attempt to invoke virtual method 'android.content.res.XmlResourceParser ....' on a null object reference"
      fileProviderAuthority: "com.example.provider",

      // This callback is called if there is a new version but it is not a forceUpdate.
      needUpdateApp: needUpdate => {
        Alert.alert(
github mikehardy / react-native-update-apk / example / App.js View on Github external
Installed Package Installer:
          {UpdateAPK.getInstalledPackageInstaller()}
        
        
          
          
          
          
        
        {this.state.downloadProgress != -1 && (
          
        )}
        <button title="Check Server For Update">
      
    );
  }
}</button>
github mikehardy / react-native-update-apk / example / App.js View on Github external
Installed Version Code: {UpdateAPK.getInstalledVersionCode()}