cordova-plugin-market icon indicating copy to clipboard operation
cordova-plugin-market copied to clipboard

Erro execute open

Open igorlacerdacarneiro opened this issue 6 years ago • 6 comments

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?

igorlacerdacarneiro avatar Jan 28 '19 17:01 igorlacerdacarneiro

The same is happening to me, have you found a solution?

Blast06 avatar Feb 04 '19 00:02 Blast06

No, I've adopted a solution that does not use a library.

igorlacerdacarneiro avatar Feb 04 '19 11:02 igorlacerdacarneiro

Oh, please, can you tell me how you did it?

Blast06 avatar Feb 05 '19 11:02 Blast06

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;         }       }     )   }`

igorlacerdacarneiro avatar Feb 05 '19 12:02 igorlacerdacarneiro

Thanks a lot

Blast06 avatar Feb 15 '19 19:02 Blast06

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.

hemantv avatar Apr 27 '19 09:04 hemantv