npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-apk-update

v0.1.2

Published

React Native library designed to provide in-app update functionality for Android applications distributed outside the Google Play Store. This library allows you to check for updates, download APK files, and install them directly within your app, making it

Readme

rn-apk-update

rn-apk-update is a React Native library designed to provide in-app update functionality for Android applications distributed outside the Google Play Store. This library allows you to check for updates, download APK files, and install them directly within your app, making it a perfect solution for apps distributed via APK files.

Demo

Watch the demo of rn-apk-update:

Features

  • Check for updates from a remote server.
  • Download APK files with a progress bar.
  • Prompt users to update their app with a customizable modal.
  • Install APKs directly from within the app.

Installation

To install the library, run the following command:

yarn add rn-apk-update

or

npm install rn-apk-update

Peer Dependencies

yarn add react-native-blob-util@^0.19.11 react-native-device-info@^13.0.0 @react-native-community/progress-bar-android@^1.0.5

or

npm install react-native-blob-util@^0.19.11 react-native-device-info@^13.0.0 @react-native-community/progress-bar-android@^1.0.5

Android Setup

In order to enable APK downloads and installation in your app, you need to add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />

These permissions are required to:

Allow the app to request permission to install APKs from unknown sources. Handle APK files stored on external storage (depending on your app’s target SDK version).

Usage

Below is an example of how to use rn-apk-update in a React Native app:

import { useState, useRef } from 'react';
import { StyleSheet, View, Button } from 'react-native';
import ApkUpdate, { type UpdatePromptMethods } from 'rn-apk-update';

const App = () => {
  const [downloadProgress, setDownloadProgress] = useState<number>(0);
  const { checkForUpdate, UpdatePrompt, downloadAndInstallApk } = ApkUpdate();
  const updatePromptRef = useRef<UpdatePromptMethods>(null);

  const handleCheckForUpdates = async () => {
    const isUpdateAvailable = await checkForUpdate('https://example.com/version.json');

    if (isUpdateAvailable) {
      updatePromptRef?.current?.prompt(
        'Update Available', 'A new version of the app is available.\nDo you want to update?', [
        {
          title: 'Update',
          onPress: () => downloadAndInstallApk('https://example.com/app.apk', {
            onProgress(progress: number) {
              setDownloadProgress(progress);
            },
            onProgressComplete() {
              updatePromptRef?.current?.close();
            },
          }),
        },
        { title: 'Cancel', onPress: () => updatePromptRef?.current?.close() },
      ]);
    }
  };

  return (
    <View style={styles.container}>
      <UpdatePrompt ref={updatePromptRef} progress={downloadProgress} />

      <Button
        title="Check for Updates"
        onPress={handleCheckForUpdates}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

export default App;

Customization

Custom Styling For Update Prompt

Prompt Customization

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT