Add app rate feature


#1

I am trying to add app rate feature in my app using the code in controllers.js:

/* RATE APP */
    $scope.rateApp = function(){
        document.addEventListener("deviceready", function () {
            AppRate.preferences.useLanguage = 'en';
            var popupInfo = {};
            popupInfo.title = Shop.name;
            popupInfo.message = "You like "+Shop.name+" We would be glad if you share your experience with others on playstore. Thanks for your shopping with us";
            popupInfo.cancelButtonLabel = "No, thanks";
            popupInfo.laterButtonLabel = "Remind Me Later";
            popupInfo.rateButtonLabel = "Rate Now";
            AppRate.preferences.customLocale = popupInfo;

            AppRate.preferences.usesUntilPrompt = 3;
            AppRate.preferences.promptAgainForEachNewVersion = true;
            AppRate.preferences.openStoreInApp = true;
            AppRate.preferences.storeAppURL.ios = '849930087';
            AppRate.preferences.storeAppURL.android = 'market://details?id=app.anyapp.com';

            AppRate.promptForRating(true);

        }, false);
    }

    /* END RATE APP */

and in app.js calling AppRate.promptForRating(true);

i get the popup but when i click on Rate Now nothing happens, it should be redirected to playstore but it doesnt, can anyone guide me whats wrong with this


#2

In iOnic 2 I write it like that.

this.appRate.preferences = {
  openStoreInApp: true,
  displayAppName: 'Alloca',
  usesUntilPrompt: 2,
  promptAgainForEachNewVersion: true,
  storeAppURL: {
    ios: '1222926795',
    android: 'market://details?id=com.mytech.alloca'
  },
  customLocale: {
    title: "Bewerten Sie Alloca",
    message: "Sagen Sie uns Ihre Meinung um Alloca in Zukunft noch besser zu machen!",
    cancelButtonLabel: "Nein, Danke",
    laterButtonLabel: "Später",
    rateButtonLabel: "Jetzt bewerten"
  }
};

Should work like on Angular 1/iOnic 1


#3

should i add this in controllers.js???


#4

Try this:

AppRate.preferences = {
  openStoreInApp: true,
  displayAppName: 'Alloca',
  usesUntilPrompt: 2,
  promptAgainForEachNewVersion: true,
  storeAppURL: {
    ios: '1222926795',
    android: 'market://details?id=com.mytech.alloca'
  },
  customLocale: {
    title: "Bewerten Sie Alloca",
    message: "Sagen Sie uns Ihre Meinung um Alloca in Zukunft noch besser zu machen!",
    cancelButtonLabel: "Nein, Danke",
    laterButtonLabel: "Später",
    rateButtonLabel: "Jetzt bewerten"
  }
}; AppRate.promptForRating(false); // Open after the 3rd start

#5

I had that previous code in controllers.js so should i put it there??? or direct to app.js?


#6

In your app.js I guess

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
  StatusBar.styleDefault();
}
AppRate.preferences = {
  openStoreInApp: true,
  displayAppName: 'Alloca',
  usesUntilPrompt: 2,
  promptAgainForEachNewVersion: true,
  storeAppURL: {
    ios: '1222926795',
    android: 'market://details?id=com.mytech.alloca'
  },
  customLocale: {
    title: "Bewerten Sie Alloca",
    message: "Sagen Sie uns Ihre Meinung um Alloca in Zukunft noch besser zu machen!",
    cancelButtonLabel: "Nein, Danke",
    laterButtonLabel: "Später",
    rateButtonLabel: "Jetzt bewerten"
  }
}; 
AppRate.promptForRating(false); // Open after the 3rd start
  });
})

#7

Thanks it worked like a charm.


#8

Good to hear :slight_smile:


#9

Can u help me to obfuscate the codes if possible


#11

Hi @LoLStats

Thanks for the nice tipps!
I am using ionic1 and trying to install that as well, but it is not working :frowning:
Have I done sth wrong?

Thanks in advance! :slight_smile:

export function onReady($ionicPlatform, $window) {
	$ionicPlatform.ready(function() {
		console.log('ionicPlatform');
		// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
		// for form inputs)
		if ($window.cordova && $window.cordova.plugins && $window.cordova.plugins.Keyboard) {
			cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
			cordova.plugins.Keyboard.disableScroll(true);
		}
		if ($window.Keyboard) {
			$window.Keyboard.shrinkView(true);
		}
		if ($window.StatusBar) {
			// org.apache.cordova.statusbar required
			StatusBar.styleDefault();
		}

		$window.AppRate.preferences = {
			openStoreInApp: true,
			language: 'de',
			displayAppName: '',
			usesUntilPrompt: 2,
			promptAgainForEachNewVersion: true,
			storeAppURL: {
				ios: '',
				android: ''
			},
			customLocale: {
				title: "Bewerten Sie Alloca",
				message: "Sagen Sie uns Ihre Meinung um Alloca in Zukunft noch besser zu machen!",
				cancelButtonLabel: "Nein, Danke",
				laterButtonLabel: "Später",
				rateButtonLabel: "Jetzt bewerten"
			}
		};

		$window.AppRate.promptForRating(false); // Open after the 3rd start
	});
}