Skip to content

Commit

Permalink
Merge pull request #9 from master-atul/feature/new-extraction-method
Browse files Browse the repository at this point in the history
This fixes https://github.com/master-atul/react-native-appstore-version-checker/issues/8

v2.4.0 will have the fix !!

Nothing to do . Just upgrade the package and use it
the default way

```getAppstoreAppVersion('com.supercell.clashofclans') //put any apps packageId here
.then((appVersion) => {
  console.log('clashofclans android app version on playstore', appVersion);
})
.catch((err) => {
  console.log('error occurred', err);
});```
  • Loading branch information
a7ul authored Apr 21, 2018
2 parents 3f9930f + 9e9f372 commit c8f4ef8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ public void appVersionExtractor(
Callback errorCallback) {
try {
Document doc = Jsoup.connect(url).get();
Elements versionElement = doc.select(extractor);
String versionText = versionElement.text();
String versionText;
if(extractor.equalsIgnoreCase("")){
versionText = doc.getElementsContainingOwnText("Current Version").parents().first().getAllElements().last().text();
}else{
versionText = doc.select(extractor).text();
}
// https://stackoverflow.com/a/49924787/2881112
successCallback.invoke(versionText);
} catch (Exception e) {
errorCallback.invoke(e.getMessage());
Expand Down
4 changes: 2 additions & 2 deletions src/versionChecker.android.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {NativeModules} from 'react-native';
import {get} from './fetcher';
const getAppstoreAppVersion = (id, options = { jquerySelector: "" }) => {

const getAppstoreAppVersion = (id, { jquerySelector = '[itemprop=\'softwareVersion\']' }) => {
const url = `https://play.google.com/store/apps/details?id=${id}`;
return new Promise((resolve, reject) => {
NativeModules.RNAppstoreVersionChecker.appVersionExtractor(url,jquerySelector,resolve, reject);
NativeModules.RNAppstoreVersionChecker.appVersionExtractor(url,options.jquerySelector,resolve, reject);
});
};

Expand Down

0 comments on commit c8f4ef8

Please sign in to comment.