cordova-plugin-market
cordova-plugin-market copied to clipboard
Erro execute open
I'm trying to use the plugin to redirect users to the store and update the application. On import I could only make it work as follows:
import { Market } from '@ionic-native/market/ngx';
In use I'm trying it as follows:
let id = 'br.com.packge' this.market.open(id).then(response => { console.debug(response); }).catch(error => { console.warn(error); });
The more I have to return or the error:
ERROR TypeError: Object(...) is not a function
I'm doing something wrong, already reviewing all the import processes. I'm a beginner in Ionic and I can not find the source of the error, could anyone help me find where I'm going wrong?
The same is happening to me, have you found a solution?
No, I've adopted a solution that does not use a library.
Oh, please, can you tell me how you did it?
My solution was, I created an endpoint where I stored the latest version released and that is available in the application store. So, when I enter the application I call this endpoint and with the native Device, Platform and AppVersion libraries, I can make the comparisons and check if it has a newer version for the user.
Here's my code to better understand: `let appUrl: string let localAppVersion: any const devicePlatform: string = this.device.platform localAppVersion = await this.appVersion.getVersionNumber () if (devicePlatform == 'Android') { appUrl = 'https://play.google.com/store/apps/details?id=YOUR_PACKAGE' } else if (devicePlatform == 'iOS') { appUrl = 'https://itunes.apple.com/us/app/YOUR_APP/APP_ID' } else { console.log ('Device not recognized.') }
this.disableButton = true; let loader = this.loadingCtrl.create ({content: 'Validating application version ...'}) loader.present () this.userProvider.getAppVersion (). appVersion => { loader.dismiss () if (localAppVersion <appVersion) { this.alertCtrl.create ({ title: 'New version available!', message: 'An application update is available. To continue using it, please update it. ', buttons: [ { text: 'Cancel', scroll: 'cancel' }, { text: 'Update', handler: () => {window.open (appUrl)} } ] }). } else { console.log ('Application updated') this.disableButton = false; } } ) }`
Thanks a lot
There seems to be some issue with Ionic Native wrapper of plugin. You can still use the plugin using window["cordova"].plugins["market"].open(APP_ID);
Works just fine.