This repository was archived by the owner on Sep 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathappRate.js
More file actions
92 lines (79 loc) · 3.34 KB
/
appRate.js
File metadata and controls
92 lines (79 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// install : cordova plugin add https://github.com/pushandplay/cordova-plugin-apprate.git
// link : https://github.com/pushandplay/cordova-plugin-apprate
/* globals AppRate: true */
angular.module('ngCordova.plugins.appRate', [])
.provider('$cordovaAppRate', [function () {
/**
* Set defaults settings to AppRate
*
* @param {Object} defaults - AppRate default settings
* @param {string} defaults.language
* @param {string} defaults.appName
* @param {boolean} defaults.promptForNewVersion
* @param {boolean} defaults.openStoreInApp
* @param {number} defaults.usesUntilPrompt
* @param {boolean} defaults.useCustomRateDialog
* @param {string} defaults.iosURL
* @param {string} defaults.androidURL
* @param {string} defaults.blackberryURL
* @param {string} defaults.windowsURL
*/
this.setPreferences = function (defaults) {
if (!defaults || !angular.isObject(defaults)) {
return;
}
AppRate.preferences.useLanguage = defaults.language || null;
AppRate.preferences.displayAppName = defaults.appName || '';
AppRate.preferences.promptAgainForEachNewVersion = defaults.promptForNewVersion || true;
AppRate.preferences.openStoreInApp = defaults.openStoreInApp || false;
AppRate.preferences.usesUntilPrompt = (typeof defaults.usesUntilPrompt === 'undefined'|| defaults.usesUntilPrompt===null)?3:defaults.usesUntilPrompt;
AppRate.preferences.useCustomRateDialog = defaults.useCustomRateDialog || false;
AppRate.preferences.storeAppURL.ios = defaults.iosURL || null;
AppRate.preferences.storeAppURL.android = defaults.androidURL || null;
AppRate.preferences.storeAppURL.blackberry = defaults.blackberryURL || null;
AppRate.preferences.storeAppURL.windows8 = defaults.windowsURL || null;
};
/**
* Set custom locale
*
* @param {Object} customObj
* @param {string} customObj.title
* @param {string} customObj.message
* @param {string} customObj.cancelButtonLabel
* @param {string} customObj.laterButtonLabel
* @param {string} customObj.rateButtonLabel
*/
this.setCustomLocale = function (customObj) {
var strings = {
title: 'Rate %@',
message: 'If you enjoy using %@, would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!',
cancelButtonLabel: 'No, Thanks',
laterButtonLabel: 'Remind Me Later',
rateButtonLabel: 'Rate It Now'
};
strings = angular.extend(strings, customObj);
AppRate.preferences.customLocale = strings;
};
this.$get = ['$q', function ($q) {
return {
promptForRating: function (immediate) {
var q = $q.defer();
var prompt = AppRate.promptForRating(immediate);
q.resolve(prompt);
return q.promise;
},
navigateToAppStore: function () {
var q = $q.defer();
var navigate = AppRate.navigateToAppStore();
q.resolve(navigate);
return q.promise;
},
onButtonClicked: function (cb) {
AppRate.preferences.callbacks.onButtonClicked = cb.bind(this);
},
onRateDialogShow: function (cb) {
AppRate.preferences.callbacks.onRateDialogShow = cb.bind(this);
}
};
}];
}]);