Skip to content

Instantly share code, notes, and snippets.

@dawsontoth
Created June 6, 2011 20:40
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save dawsontoth/1011043 to your computer and use it in GitHub Desktop.
Save dawsontoth/1011043 to your computer and use it in GitHub Desktop.
Rate my app in Appcelerator Titanium Mobile
/**
* The following snippet will ask the user to rate your app the second time they launch it.
* It lets the user rate it now, "Remind Me Later" or never rate the app.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.addEventListener('open', checkReminderToRate);
win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' }));
win.open();
function checkReminderToRate() {
var now = new Date().getTime();
var remindToRate = Ti.App.Properties.getString('RemindToRate');
if (!remindToRate) {
Ti.App.Properties.setString('RemindToRate', now);
}
else if (remindToRate < now) {
var alertDialog = Titanium.UI.createAlertDialog({
title: 'Please rate this app!',
message: 'Would you take a moment to rate this app?',
buttonNames: ['OK', 'Remind Me Later', 'Never'],
cancel: 2
});
alertDialog.addEventListener('click', function(evt) {
switch (evt.index) {
case 0:
Ti.App.Properties.setString('RemindToRate', Number.MAX_VALUE);
// NOTE: replace this with your own iTunes link; also, this won't WON'T WORK IN THE SIMULATOR!
if (Ti.Android) {
Ti.Platform.openURL('URL TO YOUR APP IN THE GOOGLE MARKETPLACE');
}
else {
Ti.Platform.openURL('URL TO YOUR APP IN THE ITUNES STORE');
}
break;
case 1:
// "Remind Me Later"? Ok, we'll remind them tomorrow when they launch the app.
Ti.App.Properties.setString('RemindToRate', now + (1000 * 60 * 60 * 24));
break;
case 2:
Ti.App.Properties.setString('RemindToRate', Number.MAX_VALUE);
break;
}
});
alertDialog.show();
}
}
@m4nu56
Copy link

m4nu56 commented Jul 15, 2011

Cool too I take it :)

@m4nu56
Copy link

m4nu56 commented Jul 24, 2011

Hello do you know if it's possible to know the URL of the app in iTunes Store before submitting the app to apple in the first place ?

@dawsontoth
Copy link
Author

If you log in to iTunesConnect and create the app, there will be a link to "View in App Store". You don't have to submit the binary for review to be able to see the link.

@m4nu56
Copy link

m4nu56 commented Jul 26, 2011

Thank's I'll look into it this same afternoon ! Keep going the good work @dawsontoth :)

@m4nu56
Copy link

m4nu56 commented Aug 2, 2011

Hello @dawsontoth, for iTunes store I've found the "View in App Store" link in the itunes connect platform. For Android, is there a way to open the link to my app directly into the Android Market App of the mobile phone ? Right now it's opening in the market.android.com webpage without even showing the mobile version if there's one. Thank's for your help..

@dawsontoth
Copy link
Author

@m4nu56
Copy link

m4nu56 commented Aug 4, 2011

It did help me thank's. For those interested, just use a link like this: market://details?id=com.android.example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment