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

@amalgamaco/check-app-version-presenter

v0.0.5

Published

Shows a dialog to the user if it's recommeded or required to update the app.

Downloads

13

Readme

CheckAppVersionPresenter

Quality Gate Status Coverage Maintainability Rating Reliability Rating Security Rating

CheckAppVersionPresenter checks the app's current version using the AppVersionChecker service and if it's recommended or required to update the app shows an alert message informing the user to do so.

Installation

NPM

$ npm install --save @amalgamaco/check-app-version-presenter

Yarn

$ yarn add @amalgamaco/check-app-version-presenter

Example

import CheckAppVersionPresenter from '@amalgamaco/check-app-version-presenter';

const versionChecker = new AppVersionChecker( { ... } );

const presenter = CheckAppVersionPresenter.defaultWith( {
	versionChecker,
	androidStoreURL: 'market://details?id=my-awesome-app',
	iosStoreURL: 'itms-apps://itunes.apple.com/us/app/apple-store/id1111111111',
	textsConfig: {
		recommendedToUpdatePopup: {
			title: 'Update to have new features!',
			updateButton: 'Go to the store!'
		}
	}
} );

Reference

constructor

When creating a new instance of the presenter you can pass the following paramters:

interface IConstructorParameters {
	versionChecker: IVersionChecker,
	showInfoMessage: IShowInfoMessage,
	openAppStorePage: IOpenAppStorePage,
	textsConfig?: ITextsConfigParameter
}

versionChecker

The version checker to use, it has to be an instance of AppVersionChecker.

const versionChecker = new AppVersionChecker( { ... } );

const presenter = new CheckAppVersionPresenter( { versionChecker, ... } );

showInfoMessage

An object in charge of showing the required or recommended info messages to the user, it must implement the IShowInfoMessage interface:

interface IShowMessageButton {
	text: string,
	onPress?: () => void
}

interface IShowMessageParameters {
	title: string,
	message: string,
	buttons: IShowMessageButton[]
}

interface IShowInfoMessage {
	showMessage: ( parameters: IShowMessageParameters ) => void;
}

You can use the ShowInfoMessage class included in the package to show the messages using the standard react native's Alert backend.

Example
import { ShowInfoMessage }, CheckAppVersionPresenter from '@amalgamaco/check-app-version-presenter';

const showInfoMessage = new ShowInfoMessage();
const presenter = new CheckAppVersionPresenter( { showInfoMessage, ... } );

openAppStorePage

An object in charge of opening the app's store page when the user chooses to update the app, it must implement the IOpenAppStorePage interface:

interface IOpenAppStorePage {
	openAppStore: () => Promise<boolean>;
}

You can use the OpenAppStorePage class included in the package to open the stores page using react native's Linking backend.

Example
import { OpenAppStorePage }, CheckAppVersionPresenter from '@amalgamaco/check-app-version-presenter';

const openAppStorePage = new OpenAppStorePage( {
	androidStoreURL: 'market://details?id=my-awesome-app',
	iosStoreURL: 'itms-apps://itunes.apple.com/us/app/apple-store/id1111111111'
} );

const presenter = new CheckAppVersionPresenter( { openAppStorePage, ... } );

textsConfig

An object with different texts to show in the recommended to update and required to update popups, it must implement the ITextsConfigParameter interface:

interface IRecommendedToUpdatePopupTextsConfigParameter {
	title?: string,
	message?: string,
	updateButton?: string,
	cancelButton?: string
}

interface IRequiredToUpdatePopupTextsConfigParameter {
	title?: string,
	message?: string,
	updateButton?: string
}

interface ITextsConfigParameter {
	recommendedToUpdatePopup?: IRecommendedToUpdatePopupTextsConfig,
	requiredToUpdatePopup?: IRequiredToUpdatePopupTextsConfig
}

If you don't pass any configuration the default texts will be used:

{
	recommendedToUpdatePopup: {
		title: 'We have new features for you!',
		message: 'You can now download the latest version of the app.',
		updateButton: 'Update',
		cancelButton: 'Cancel'
	},
	requiredToUpdatePopup: {
		title: 'We need you to update the app',
		message: 'To continue, please download the latest version of the app.',
		updateButton: 'Update'
	}
};
Example
const textsConfig = {
	recommendedToUpdatePopup: {
		title: 'Update to unlock new features!',
		updateButton: 'Go to the store'
	},
	requiredToUpdatePopup: {
		title: 'You have to update the app!',
	}
};

const presenter = new CheckAppVersionPresenter( { textsConfig, ... } );

static defaultWith

Creates a new instance of the CheckAppVersionPresenter using the default showInfoMessage and openStoreAppPage provided by the package, you can pass the following paramters:

interface IDefaultWithParamters {
	versionChecker: IVersionChecker,
	androidStoreURL: string,
	iosStoreURL: string,
	textsConfig?: ITextsConfigParameter
}

versionChecker

See constructor's versionChecker parameter reference.

androidStoreURL

The android store page url, for example: market://details?id=my-awesome-app.

iosStoreURL

The iOS store page url, for example: 'itms-apps://itunes.apple.com/us/app/apple-store/id1111111111'.

textsConfig

See constructor's textsConfig parameter reference.

checkCurrentVersion

Checks the current app version and shows the corresponding popup informing the user to update (or none if the app version is ok). Returns a promise tha resolves with the result of the version checking:

enum VersionCheckResult {
    UPDATE_REQUIRED = "APP_UPDATE_REQUIRED",
    UPDATE_RECOMMENDED = "APP_UPDATE_RECOMMENDED",
    VERSION_OK = "APP_VERSION_OK"
}

checkCurrentAppVersion: () => Promise<VersionCheckResult>