pushandplay / cordova-plugin-apprate

This plugin provide the "rate this app" functionality into your Cordova/Phonegap application
Apache License 2.0
301 stars 192 forks source link

IONIC 4 App rate plugin not working #274

Open rupamhazra opened 4 years ago

rupamhazra commented 4 years ago

Hi, I have used apprate but playstore not opening to give rating.

IONIC 4 Apprate : 1.5.0

Error in Success callbackId: Notification1169701122 : TypeError: AppRate.preferences.openUrl is not a function

TypeError: AppRate.preferences.openUrl is not a function at Function.AppRate.navigateToAppStore (AppRate.js:257) at promptForStoreRatingWindowButtonClickHandler (AppRate.js:85) at Object.callbackFromNative (cordova.22d0b106f4dfd80eb9b7.js:1) at :1:9

HaroldBeyer commented 4 years ago

I have the same error, but working with Ionic 3

dharam1986 commented 4 years ago

I am also getting the same error. I tried with appRate.preferences = { displayAppName: '', storeAppURL: { ios: '', android: 'market://details?id=', windows: 'ms-windows-store://pdp/?ProductId=', blackberry: 'appworld://content/[App Id]/' }, openUrl: appRate.preferences.openUrl };

But no luck found. Can someone please suggest.

rupamhazra commented 4 years ago

I am also getting the same error. I tried with appRate.preferences = { displayAppName: '', storeAppURL: { ios: '', android: 'market://details?id=', windows: 'ms-windows-store://pdp/?ProductId=', blackberry: 'appworld://content/[App Id]/' }, openUrl: appRate.preferences.openUrl };

But no luck found. Can someone please suggest.

I have solved by editing this plugin and follow below steps

1) Install inapp browser plugin 2) Find AppRate.js file in your android plugins folder and edit AppRate.preferences object 1) comment out this or remove this code. // openUrl: function (url) { // cordova.InAppBrowser.open(url, '_system', 'location=no'); // } 2) Next find AppRate.navigateToAppStore = function() { this method and edit below condition else if (/(Android)/i.test(navigator.userAgent.toLowerCase())) { //AppRate.preferences.openUrl(this.preferences.storeAppURL.android); // comment this code cordova.InAppBrowser.open(this.preferences.storeAppURL.android, '_system', 'location=no'); // add this code

}

this will solve the problem

dharam1986 commented 4 years ago

Thanks @rupamhazra for your quick response. I applied your changes but however still I am getting the same error. I added the import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; in my module nad app.component file but same result. [Edited]: I got the issue. Actually, my AppRate.js is not updating with ionic cordova run android command. I tried with remove android.json from platforms/Android but same result. Could you please let me now how I update the plugin file?

rupamhazra commented 4 years ago

Thanks @rupamhazra for your quick response. I applied your changes but however still I am getting the same error. I added the import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; in my module nad app.component file but same result. [Edited]: I got the issue. Actually, my AppRate.js is not updating with ionic cordova run android command. I tried with remove android.json from platforms/Android but same result. Could you please let me now how I update the plugin file?

Please find your plugin path like my path : C:\IONIC\RedyRider-Mat\plugins\cordova-plugin-apprate\www here you can see the AppRate,js file and follow the above steps which i told.

dharam1986 commented 4 years ago

Yes I did it but I am unable to make build of this file. I edited the plugin but after run command ionic cordova run android --device, I havent found my changes in AppRate.js So I am looking for a way for compile this edited file.

HaroldBeyer commented 4 years ago

I have solved it by downgrading the version from 1.5.0 to 1.4.0

mayankkataria commented 2 years ago

For android, adding below line to preferences worked for me - openUrl: (url) => window.open(url, '_blank', 'location=yes')