Skip to content

Commit 1f407cc

Browse files
committed
Merge branch 'master' into develop
2 parents c5eec21 + c668aee commit 1f407cc

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ VersionCheck.needUpdate({
180180
Field | Type | Default
181181
--- | --- | ---
182182
appID | _string_ | App ID
183-
appName | _string_ | App Name
184183
ignoreErrors | _boolean_ | true
185184
- <a name="getPlayStoreUrl" href="#getPlayStoreUrl">#</a>**`getPlayStoreUrl([option: Object])`** _(Promise<storeUrl: String>)_ - Returns url of Play Store of app.
186185
- Option

packages/react-native-version-check/example/App.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { Component } from 'react';
2-
import { StyleSheet, Text, View } from 'react-native';
1+
import React, {Component} from 'react';
2+
import {Linking, StyleSheet, Text, View} from 'react-native';
33
import VersionCheck from 'react-native-version-check';
44

55
const styles = StyleSheet.create({
@@ -14,18 +14,26 @@ const styles = StyleSheet.create({
1414
textAlign: 'center',
1515
margin: 10,
1616
},
17+
linkText: {
18+
color: 'blue',
19+
},
1720
});
1821

1922
export default class example extends Component {
2023
state = {
2124
currentVersion: null,
2225
latestVersion: null,
2326
isNeeded: false,
27+
storeUrl: '',
2428
};
2529
componentDidMount() {
2630
VersionCheck.needUpdate({
2731
latestVersion: '1.0.0',
2832
}).then(res => this.setState(res));
33+
34+
VersionCheck.getStoreUrl({appID: '364709193'}).then(res => { //App Store ID for iBooks.
35+
this.setState({storeUrl: res})
36+
})
2937
}
3038
render() {
3139
return (
@@ -39,6 +47,15 @@ export default class example extends Component {
3947
<Text style={styles.text}>
4048
Is update needed?: {String(this.state.isNeeded)}
4149
</Text>
50+
<View>
51+
<Text style={styles.text}>
52+
Store Url:
53+
</Text>
54+
<Text style={[styles.text, styles.linkText]}
55+
onPress={() => Linking.openURL(this.state.storeUrl)}>
56+
{String(this.state.storeUrl)}
57+
</Text>
58+
</View>
4259
</View>
4360
);
4461
}

packages/react-native-version-check/src/getStoreUrl.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { getVersionInfo } from './versionInfo';
55

66
export type GetAppStoreUrlOption = {
77
country?: string,
8-
appName: string,
98
appID: string,
109
ignoreErrors?: boolean,
1110
};
@@ -18,11 +17,11 @@ export type GetPlayStoreUrlOption = {
1817
export type GetStoreUrlOption = GetAppStoreUrlOption & GetPlayStoreUrlOption;
1918

2019
export const getAppStoreUrl = async (
21-
option: GetAppStoreUrlOption = {}
20+
option: GetAppStoreUrlOption
2221
): Promise<string> => {
2322
try {
24-
if (isNil(option.appID) || isNil(option.appName)) {
25-
throw new Error('At least one of appID and appName is empty.');
23+
if (isNil(option.appID)) {
24+
throw new Error('appID is empty.');
2625
}
2726

2827
if (!option.country) {
@@ -31,9 +30,7 @@ export const getAppStoreUrl = async (
3130

3231
const countryCode = option.country ? `${option.country}/` : '';
3332

34-
return `https://itunes.apple.com/${countryCode}app/${option.appName}/id${
35-
option.appID
36-
}`;
33+
return `https://itunes.apple.com/${countryCode}app/id${option.appID}`;
3734
} catch (e) {
3835
if (option.ignoreErrors) {
3936
console.warn(e); // eslint-disable-line no-console

0 commit comments

Comments
 (0)