1.0.25 • Published 2 years ago

@lemberg/react-native-android-inapp-updates v1.0.25

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Forked to fix this issue

react-native-android-inapp-updates

npm PRs Welcome

npm.io

React Native implementation of the Android In-App Update API. For more information on InApp Updates you can check the official documentation.

Build with ReasonML.

You will need to test the app via Internal App Sharing

Use internal app sharing to test in-app updates by performing the following steps:

  1. Make sure your test device has a version of your app installed that supports in-app updates and was installed using an internal app sharing URL.
  2. Follow the Play Console instructions to share your app internally. Upload a version of your app that uses a version code that is higher than the one you already have installed on the test device.
  3. On the test device, click the internal app sharing link for the updated version of your app but do not install the app from the Play Store page that appears after you click the link.
  4. Open the app from the device's app drawer or home screen. The update should now be available to your app, and you can test your implementation of in-app updates.

Project Milestone

  • startUpdateFlow Basic implementation.
  • Implement event emitter for flexible in-app updates download progress and downloaded status.
  • Implement clientVersionStalenessDays check for startUpdateFlow.

Requirements

  • In-app updates works only with devices running Android 5.0 (API level 21) or higher.
  • In-app updates can only work when signed with the same signing key as your app on the play store.

Getting started

$ npm install @gurukumparan/react-native-android-inapp-updates --save

or

$ yarn add @gurukumparan/react-native-android-inapp-updates

For react-native@0.60.0 or above

As react-native@0.60.0 or above supports autolinking, so there is no need to run linking process. Read more about autolinking here.

Mostly automatic installation

$ react-native link @gurukumparan/react-native-android-inapp-updates

Usage

import {startUpdateFlow} from '@gurukumparan/react-native-android-inapp-updates';
const updateModes = 'flexible';

try {
    const result = await startUpdateFlow(updateModes);
} catch (e) {
    console.log('error:', e);
}

Reference

Methods

startUpdateFlow()

promise string startUpdateFlow(appUpdateType,clientVersionStalenessDays)
Input
InputDescriptionTypeDefault Value
appUpdateTypeAndroid In-app updates typeenum(flexible or immediate)immediate
clientVersionStalenessDaysIf an update is available In-app modal will only triger after x number of days since the Google Play Store app on the user's device has learnt about an available update.int0
Promise Resolve
ValueDescription
CanceledIn-app modal canceled by user
SuccessfulUser press the update button
Promise Reject
ValueDescription
checkAppUpdate failure:appUpdateInfoTask failed getting result. This can mean numerous reason check the log for more explanation.
No update availableThere is no update available with the appUpdateType type.
startUpdateFlow failure:Failed starting the Google Play In-app updates modal.

checkUpdateAvailability()

promise string checkUpdateAvailability()
Promise Resolve
ValueDescription
Update availableApplication update is available
Promise Reject
ValueDescription
checkAppUpdate failure:appUpdateInfoTask failed getting result. This can mean numerous reason check the log for more explanation.
No update availableThere is no update available

onCompleteUpdate()

promise string onCompleteUpdate()
Promise Resolve
ValueDescription
successApplication update succeed
Promise Reject
ValueDescription
Download is not completedApplication update process fail

❤️ From Indonesia