Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. /**
  2. * The following snippet will ask the user to rate your app the second time they launch it.
  3. * It lets the user rate it now, "Remind Me Later" or never rate the app.
  4. */
  5. var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
  6. win.addEventListener('open', checkReminderToRate);
  7. win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' }));
  8. win.open();
  9.  
  10. function checkReminderToRate() {
  11. var now = new Date().getTime();
  12. var remindToRate = Ti.App.Properties.getString('RemindToRate');
  13. if (!remindToRate) {
  14. Ti.App.Properties.setString('RemindToRate', now);
  15. }
  16. else if (remindToRate < now) {
  17. var alertDialog = Titanium.UI.createAlertDialog({
  18. title: 'Please rate this app!',
  19. message: 'Would you take a moment to rate this app?',
  20. buttonNames: ['OK', 'Remind Me Later', 'Never'],
  21. cancel: 2
  22. });
  23. alertDialog.addEventListener('click', function(evt) {
  24. switch (evt.index) {
  25. case 0:
  26. Ti.App.Properties.setString('RemindToRate', Number.MAX_VALUE);
  27. // NOTE: replace this with your own iTunes link; also, this won't WON'T WORK IN THE SIMULATOR!
  28. if (Ti.Android) {
  29. Ti.Platform.openURL('URL TO YOUR APP IN THE GOOGLE MARKETPLACE');
  30. }
  31. else {
  32. Ti.Platform.openURL('URL TO YOUR APP IN THE ITUNES STORE');
  33. }
  34. break;
  35. case 1:
  36. // "Remind Me Later"? Ok, we'll remind them tomorrow when they launch the app.
  37. Ti.App.Properties.setString('RemindToRate', now + (1000 * 60 * 60 * 24));
  38. break;
  39. case 2:
  40. Ti.App.Properties.setString('RemindToRate', Number.MAX_VALUE);
  41. break;
  42. }
  43. });
  44. alertDialog.show();
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement