{"_id":"@amalgamaco/check-app-version-presenter","name":"@amalgamaco/check-app-version-presenter","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.5":{"name":"@amalgamaco/check-app-version-presenter","version":"0.0.5","description":"Shows a dialog to the user if it's recommeded or required to update the app.","main":"dist/index.js","types":"dist/index.d.ts","type":"module","scripts":{"build":"tsc","lint":"eslint src/ tests/","prepare":"yarn build","prepublishOnly":"yarn test && yarn lint","preversion":"yarn lint","release":"release-it","test":"NODE_ENV=test JEST_JUNIT_OUTPUT_DIR=reports TZ=UTC jest"},"repository":{"type":"git","url":"git+ssh://git@github.com/amalgamaco/app-version-checker.git"},"keywords":[],"author":{"name":"Mauro E. Bender","email":"mauro@amalgama.co","url":"https://github.com/maurobender"},"license":"ISC","publishConfig":{"registry":"https://registry.npmjs.org","access":"public"},"bugs":{"url":"https://github.com/amalgamaco/app-version-checker/issues"},"homepage":"https://github.com/amalgamaco/app-version-checker/tree/main/packages/check-app-version-presenter#README","devDependencies":{"@babel/cli":"^7.17.3","@babel/core":"^7.17.5","@babel/preset-env":"^7.16.11","@release-it/conventional-changelog":"^4.1.0","@types/jest":"^27.4.0","@types/lodash":"^4.14.179","@types/node":"^17.0.19","@types/react":"^17.0.39","@types/react-native":"^0.66.16","@types/semver":"^7.3.9","@typescript-eslint/eslint-plugin":"^5.12.0","@typescript-eslint/parser":"^5.12.0","eslint":"^8.9.0","eslint-config-airbnb-base":"^15.0.0","eslint-import-resolver-typescript":"^2.5.0","eslint-plugin-import":"^2.25.4","jest":"^27.5.1","jest-junit":"^13.0.0","react":"^17.0.2","react-native":"^0.67.2","react-native-typescript-transformer":"^1.2.13","release-it":"^14.12.5","ts-jest":"^27.1.3","typescript":"^4.5.5"},"dependencies":{"@amalgamaco/app-version-checker":"^0.0.7","lodash":"^4.17.21"},"release-it":{"git":{"tagName":"check-app-version-presenter-v${version}","requireCleanWorkingDir":false,"requireUpstream":true,"commitMessage":"Release Check App Version Presenter v${version}","changelog":"npx auto-changelog --stdout --commit-limit false --unreleased --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"},"hooks":{"after:bump":"npx auto-changelog -p"},"github":{"release":true,"releaseName":"Release Check App Version Presenter v${version}"},"npm":{"skipChecks":true}},"jest":{"preset":"react-native","collectCoverage":true,"coverageDirectory":"<rootDir>/reports/coverage","coverageReporters":["json","lcov","text","html","text-summary","cobertura"],"reporters":["default","jest-junit"],"testMatch":["<rootDir>/tests/**/?(*.)(spec|test).js"],"modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/dist/"]},"peerDependencies":{"react":"^17.0.2","react-native":"^0.67.2"},"gitHead":"a1e4040701de5e3c3c53b9e9a837b0e04d67feb5","_id":"@amalgamaco/check-app-version-presenter@0.0.5","_nodeVersion":"16.20.1","_npmVersion":"8.19.4","dist":{"integrity":"sha512-y77m7tqz5EF2qoYdLI258nkbveJtcWDOzPkYk3pOCcEiRRbQlNmo++8mG9BZMNfnmMAmcGk8vCZRwPwD75bRiA==","shasum":"540e9c17587867ed465f661638f243c81cadb4d6","tarball":"https://registry.npmjs.org/@amalgamaco/check-app-version-presenter/-/check-app-version-presenter-0.0.5.tgz","fileCount":12,"unpackedSize":18728,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEOGhxvgHDZ396Y8JxHa+CvC42xMmNX9z4gRZuiFhCENAiEA4ixpYEeLH/yP2RC5tjDeanvch2nnWc/wOC8Pg7c10/E="}]},"_npmUser":{"name":"maurobender","email":"maurobender@gmail.com"},"directories":{},"maintainers":[{"name":"sebakz","email":"sebastian.kissling@gmail.com"},{"name":"ezeaguerre","email":"ezeaguerre@gmail.com"},{"name":"damianh97","email":"damianhuaier@gmail.com"},{"name":"maurobender","email":"maurobender@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/check-app-version-presenter_0.0.5_1689859754417_0.008054555553040244"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-20T13:29:14.343Z","0.0.5":"2023-07-20T13:29:14.563Z","modified":"2023-07-20T13:29:14.876Z"},"maintainers":[{"name":"sebakz","email":"sebastian.kissling@gmail.com"},{"name":"ezeaguerre","email":"ezeaguerre@gmail.com"},{"name":"damianh97","email":"damianhuaier@gmail.com"},{"name":"maurobender","email":"maurobender@gmail.com"}],"description":"Shows a dialog to the user if it's recommeded or required to update the app.","homepage":"https://github.com/amalgamaco/app-version-checker/tree/main/packages/check-app-version-presenter#README","keywords":[],"repository":{"type":"git","url":"git+ssh://git@github.com/amalgamaco/app-version-checker.git"},"author":{"name":"Mauro E. Bender","email":"mauro@amalgama.co","url":"https://github.com/maurobender"},"bugs":{"url":"https://github.com/amalgamaco/app-version-checker/issues"},"license":"ISC","readme":"# CheckAppVersionPresenter\n\n[![Quality Gate Status](https://sonarqube.amalgama.co/api/project_badges/measure?project=check-app-version-presenter&metric=alert_status&token=905ab15644987c9c467e2dc2f67e34c99e8269e1)](https://sonarqube.amalgama.co/dashboard?id=check-app-version-presenter) [![Coverage](https://sonarqube.amalgama.co/api/project_badges/measure?project=check-app-version-presenter&metric=coverage&token=905ab15644987c9c467e2dc2f67e34c99e8269e1)](https://sonarqube.amalgama.co/dashboard?id=check-app-version-presenter) [![Maintainability Rating](https://sonarqube.amalgama.co/api/project_badges/measure?project=check-app-version-presenter&metric=sqale_rating&token=905ab15644987c9c467e2dc2f67e34c99e8269e1)](https://sonarqube.amalgama.co/dashboard?id=check-app-version-presenter) [![Reliability Rating](https://sonarqube.amalgama.co/api/project_badges/measure?project=check-app-version-presenter&metric=reliability_rating&token=905ab15644987c9c467e2dc2f67e34c99e8269e1)](https://sonarqube.amalgama.co/dashboard?id=check-app-version-presenter) [![Security Rating](https://sonarqube.amalgama.co/api/project_badges/measure?project=check-app-version-presenter&metric=security_rating&token=905ab15644987c9c467e2dc2f67e34c99e8269e1)](https://sonarqube.amalgama.co/dashboard?id=check-app-version-presenter)\n\n CheckAppVersionPresenter checks the app's current version using the [AppVersionChecker service](/packages/app-version-checker) and if it's recommended or required to update the app shows an alert message informing the user to do so.\n\n ## Installation\n\n### NPM\n\n```sh\n$ npm install --save @amalgamaco/check-app-version-presenter\n```\n### Yarn\n ```sh\n $ yarn add @amalgamaco/check-app-version-presenter\n ```\n\n## Example\n\n```js\nimport CheckAppVersionPresenter from '@amalgamaco/check-app-version-presenter';\n\nconst versionChecker = new AppVersionChecker( { ... } );\n\nconst presenter = CheckAppVersionPresenter.defaultWith( {\n\tversionChecker,\n\tandroidStoreURL: 'market://details?id=my-awesome-app',\n\tiosStoreURL: 'itms-apps://itunes.apple.com/us/app/apple-store/id1111111111',\n\ttextsConfig: {\n\t\trecommendedToUpdatePopup: {\n\t\t\ttitle: 'Update to have new features!',\n\t\t\tupdateButton: 'Go to the store!'\n\t\t}\n\t}\n} );\n```\n\n\n## Reference\n\n### constructor\n\nWhen creating a new instance of the presenter you can pass the following paramters:\n\n```ts\ninterface IConstructorParameters {\n\tversionChecker: IVersionChecker,\n\tshowInfoMessage: IShowInfoMessage,\n\topenAppStorePage: IOpenAppStorePage,\n\ttextsConfig?: ITextsConfigParameter\n}\n```\n\n#### versionChecker\n\nThe version checker to use, it has to be an instance of `AppVersionChecker`.\n\n```js\nconst versionChecker = new AppVersionChecker( { ... } );\n\nconst presenter = new CheckAppVersionPresenter( { versionChecker, ... } );\n```\n\n#### showInfoMessage\n\nAn object in charge of showing the required or recommended info messages to the user, it must implement the `IShowInfoMessage` interface:\n\n```ts\ninterface IShowMessageButton {\n\ttext: string,\n\tonPress?: () => void\n}\n\ninterface IShowMessageParameters {\n\ttitle: string,\n\tmessage: string,\n\tbuttons: IShowMessageButton[]\n}\n\ninterface IShowInfoMessage {\n\tshowMessage: ( parameters: IShowMessageParameters ) => void;\n}\n```\n\nYou can use the [ShowInfoMessage class](/packages/check-app-version-presenter/src/interactors/ShowInfoMessage.ts) included in the package to show the messages using the standard react native's [Alert](https://reactnative.dev/docs/alert) backend.\n\n##### __Example__\n\n```js\nimport { ShowInfoMessage }, CheckAppVersionPresenter from '@amalgamaco/check-app-version-presenter';\n\nconst showInfoMessage = new ShowInfoMessage();\nconst presenter = new CheckAppVersionPresenter( { showInfoMessage, ... } );\n```\n\n#### openAppStorePage\n\nAn object in charge of opening the app's store page when the user chooses to update the app, it must implement the `IOpenAppStorePage` interface:\n\n```ts\ninterface IOpenAppStorePage {\n\topenAppStore: () => Promise<boolean>;\n}\n```\n\nYou can use the [OpenAppStorePage class](/packages/check-app-version-presenter/src/interactors/OpenAppStorePage.ts) included in the package to open the stores page using react native's [Linking](https://reactnative.dev/docs/linking) backend.\n\n##### __Example__\n\n```js\nimport { OpenAppStorePage }, CheckAppVersionPresenter from '@amalgamaco/check-app-version-presenter';\n\nconst openAppStorePage = new OpenAppStorePage( {\n\tandroidStoreURL: 'market://details?id=my-awesome-app',\n\tiosStoreURL: 'itms-apps://itunes.apple.com/us/app/apple-store/id1111111111'\n} );\n\nconst presenter = new CheckAppVersionPresenter( { openAppStorePage, ... } );\n```\n\n#### textsConfig\n\nAn object with different texts to show in the recommended to update and required to update popups, it must implement the `ITextsConfigParameter` interface:\n\n```ts\ninterface IRecommendedToUpdatePopupTextsConfigParameter {\n\ttitle?: string,\n\tmessage?: string,\n\tupdateButton?: string,\n\tcancelButton?: string\n}\n\ninterface IRequiredToUpdatePopupTextsConfigParameter {\n\ttitle?: string,\n\tmessage?: string,\n\tupdateButton?: string\n}\n\ninterface ITextsConfigParameter {\n\trecommendedToUpdatePopup?: IRecommendedToUpdatePopupTextsConfig,\n\trequiredToUpdatePopup?: IRequiredToUpdatePopupTextsConfig\n}\n```\n\nIf you don't pass any configuration the default texts will be used:\n\n```ts\n{\n\trecommendedToUpdatePopup: {\n\t\ttitle: 'We have new features for you!',\n\t\tmessage: 'You can now download the latest version of the app.',\n\t\tupdateButton: 'Update',\n\t\tcancelButton: 'Cancel'\n\t},\n\trequiredToUpdatePopup: {\n\t\ttitle: 'We need you to update the app',\n\t\tmessage: 'To continue, please download the latest version of the app.',\n\t\tupdateButton: 'Update'\n\t}\n};\n```\n\n##### __Example__\n\n```js\nconst textsConfig = {\n\trecommendedToUpdatePopup: {\n\t\ttitle: 'Update to unlock new features!',\n\t\tupdateButton: 'Go to the store'\n\t},\n\trequiredToUpdatePopup: {\n\t\ttitle: 'You have to update the app!',\n\t}\n};\n\nconst presenter = new CheckAppVersionPresenter( { textsConfig, ... } );\n```\n\n### static defaultWith\n\nCreates a new instance of the `CheckAppVersionPresenter` using the default `showInfoMessage` and `openStoreAppPage` provided by the package, you can pass the following paramters:\n\n```ts\ninterface IDefaultWithParamters {\n\tversionChecker: IVersionChecker,\n\tandroidStoreURL: string,\n\tiosStoreURL: string,\n\ttextsConfig?: ITextsConfigParameter\n}\n```\n\n#### versionChecker\n\nSee [constructor's versionChecker parameter reference](/packages/check-app-version-presenter#versionchecker).\n\n#### androidStoreURL\n\nThe android store page url, for example: `market://details?id=my-awesome-app`.\n\n#### iosStoreURL\n\nThe iOS store page url, for example: `'itms-apps://itunes.apple.com/us/app/apple-store/id1111111111'`.\n\n#### textsConfig\n\nSee [constructor's textsConfig parameter reference](/packages/check-app-version-presenter#textsconfig).\n\n### checkCurrentVersion\n\nChecks 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:\n\n```ts\nenum VersionCheckResult {\n    UPDATE_REQUIRED = \"APP_UPDATE_REQUIRED\",\n    UPDATE_RECOMMENDED = \"APP_UPDATE_RECOMMENDED\",\n    VERSION_OK = \"APP_VERSION_OK\"\n}\n\ncheckCurrentAppVersion: () => Promise<VersionCheckResult>\n```\n","readmeFilename":"README.md"}