El Dude
El Dude

Reputation: 5618

Ionic AppRate fails, incomplete object?

I am trying to add AppRate to my app based on the

https://ionicframework.com/docs/v3/native/app-rate/

example

   TypeError: AppRate.preferences.openUrl is not a function. (In   
   'AppRate.preferences.openUrl(iOSStoreUrl)', 'AppRate.preferences.openUrl' is undefined) 

That method is indeed missing on the object when inspected in debugger. On the plugin documentation they add the method manually.

https://github.com/pushandplay/cordova-plugin-apprate

This approach fails for me however, too. My ionic app has no window object.

Upvotes: 0

Views: 946

Answers (2)

bipoza
bipoza

Reputation: 131

For ionic 3, Make sure the latest versions are installed with support for @ionic-native/app-rate@4 In my case I have solved it by installing version 4 of @ionic-native and version 1.4.0 of apprate.

Try this:

   $ ionic cordova plugin rm cordova-plugin-apprate 
   $ ionic cordova plugin add [email protected] --save --exact 
   $ npm install --save @ionic-native/app-rate@4

Upvotes: 0

kkhd
kkhd

Reputation: 21

I had the same issue, but in ionic 4.

I solved it, firstly, reinstall the plugin from git repository or cordova plugins registry (to make sure we have the function openUrl added) and adding the missing method to @ionic-native/app-rate/ngx/index.d.ts like :

export interface AppRatePreferences {
    ...
    ...
    ...
    openUrl?:(url:string) => void;
}

And after where you have used the call of the plugin, you add openUrl: appRate.preferences.openUrl to preferences properties like :

appRate.preferences = {
      displayAppName: '',
      storeAppURL: {
        ios: '<my_app_id>',
        android: 'market://details?id=<package_name>',
        windows: 'ms-windows-store://pdp/?ProductId=<the apps Store ID>',
        blackberry: 'appworld://content/[App Id]/'
      },
      openUrl: appRate.preferences.openUrl
    };

Hope it helps you.

Upvotes: 2

Related Questions