pushandplay / cordova-plugin-apprate

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

ERROR TypeError: Cannot read property 'getPreferences' of undefined #304

Closed lucasramosdev closed 3 years ago

lucasramosdev commented 3 years ago

i confirm the plugin works fine and its @ionic-native/app-rate issue use the AppRate object from window and it should work as expected

    // tslint:disable-next-line: no-string-literal
    const appRate: any = window['AppRate'];
    const preferences = appRate.getPreferences();
    preferences.simpleMode = true;
    preferences.storeAppURL = {
      ios: 'id123456789',
      android: 'market://details?id=com.example.app',
      windows: 'ms-windows-store://review/?ProductId=XXXXXXXX',
    };
    appRate.setPreferences(preferences);
    appRate.promptForRating(true);

possible reference https://github.com/pushandplay/cordova-plugin-apprate/issues/291

Originally posted by @wnabil in https://github.com/pushandplay/cordova-plugin-apprate/issues/295#issuecomment-731752062

I tried this way and response: ERROR TypeError: Cannot read property 'getPreferences' of undefined at AppComponent.rateMe (app.component.ts:47) at AppComponent_Template_ion_item_click_15_listener (template.html:31) at executeListenerWithErrorHandling (core.js:14316) at wrapListenerIn_markDirtyAndPreventDefault (core.js:14351) at HTMLElement. (platform-browser.js:582) at ZoneDelegate.invokeTask (zone-evergreen.js:399) at Object.onInvokeTask (core.js:27425) at ZoneDelegate.invokeTask (zone-evergreen.js:398) at Zone.runTask (zone-evergreen.js:167) at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:480)

Config: "@ionic/angular": "5.5.2", "@ionic-native/app-rate": "5.31.1", "cordova-plugin-apprate": "^1.7.2",

lucasramosdev commented 3 years ago

I got it the solve:

Was just build the app.