forked from xtremepush/XtremePush-Phonegap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxtremepush.js
204 lines (179 loc) · 7.4 KB
/
xtremepush.js
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
var exec = require('cordova/exec');
function XtremePush() { }
/**
* Calling register function of the XtremePush plugin
* @param {Object} options JSON object containing the options for which bit of Xtremepush functionality
* to turn on/off
*
* Sample format:
* {
* appKey: "asdjfaSDFASfjkfasd",
* pushOpenCallback: "onPushOpened",
* inappMessagingEnabled: true,
* ios: {
* locationsEnabled: true,
* },
* android: {
* gcmProjectNumber: "012345678910",
* geoEnabled: true,
* beaconsEnabled: true
* }
* }
*
* Description:
* appKey - String (*required*) Key for Xtremepush project
* debugLogsEnabled - Boolean (optional) to turn on debug logs
* impressionsBatchingEnabled - Boolean (optional) to turn on caching impressions and batch sending when app closing
* impressionsStoreLimit - Integer (optional) size for impression cache
* inappMessagingEnabled - Boolean (optional) to turn on sending an event on app start
* inboxBadgeCallback - String (optional) JavaScript function to be executed when the badge is updated
* inboxEnabled - Boolean (optional) to turn on inbox functionality in the app
* pushOpenCallback - String (*required*) JavaScript function to be executed when a message is opened
* serverUrl - String (optional) to send all data to different Xtremepush API endpoint
* tagsBatchingEnabled - Boolean (optional) to turn on caching tags and batch sending when app closing
* tagsStoreLimit - Integer (optional) size for tag cache
* sessionsStoreLimit - Integer (optional) size for session event cache
* attributionsEnabled - Boolean (optional) *(requires plugin from master+attributions branch)* to turn on collection of IDFA, Ad ID and attribution information
* ios:
* locationsEnabled - Boolean (optional) Can be used to turn on Xtremepush location and iBeacon scanning functionality
* locationsPermissionsRequest - Boolean (optional) Can be used to prevent automatically showing the location permission request dialog
* nameCollectingEnabled - Boolean (optional) Can be used to turn off collection of the device name, e.g. "John's iPhone"
* pushPermissionsRequest - Boolean (optional) Can be used to prevent automatically showing the notification permission request dialog
* shouldWipeBadgeNumber - Boolean (optional) Badge of application gets cleared on app open
* android:
* beaconsEnabled - Boolean (optional) Can be used to turn on Xtremepush iBeacon scanning functionality
* gcmProjectNumber - String (optional) If push is used in your application, set the GCM/FCM project number here
* geoEnabled - Boolean (optional) Can be used to turn on Xtremepush geo-location functionality
* locationsPermissionsRequest - Boolean (optional) Can be used to prevent automatically showing the location permission request dialog
*/
XtremePush.prototype.register = function(options) {
return exec(null, null, 'XtremePush', 'register', [options]);
};
/**
* Calling hit tag function
* @param {String} tag value which will be sent
* @param {String} value associated with tag (optional)
*/
XtremePush.prototype.hitTag = function(tag, value) {
if (value) {
return exec(null, null, 'XtremePush', 'hitTag', [tag, value]);
} else {
return exec(null, null, 'XtremePush', 'hitTag', [tag]);
}
};
/**
* Calling hit impression function
* @param {String} impression value which will be sent
*/
XtremePush.prototype.hitImpression = function(impression){
return exec(null, null, 'XtremePush', 'hitImpression', [impression]);
};
/**
* Calling hit event function
* @param {String} title title of the event
* @param {String} value value of the event (optional)
*/
XtremePush.prototype.hitEvent = function(title, value){
if (value) {
return exec(null, null, 'XtremePush', 'hitEvent', [title, value]);
} else {
return exec(null, null, 'XtremePush', 'hitEvent', [title]);
}
};
XtremePush.prototype.hitEventWithValue = function(id){
return exec(null, null, 'XtremePush', 'hitEventWithValue', [id]);
};
XtremePush.prototype.setUser = function(id){
return exec(null, null, 'XtremePush', 'setUser', [id]);
};
XtremePush.prototype.setTempUser = function(id){
return exec(null, null, 'XtremePush', 'setTempUser', [id]);
};
/**
* Calling send tags function
*/
XtremePush.prototype.sendTags = function(){
return exec(null, null, 'XtremePush', 'sendTags',[]);
};
/**
* Calling send impressions function
*/
XtremePush.prototype.sendImpressions = function(){
return exec(null, null, 'XtremePush', 'sendImpressions', []);
};
/**
* Setting an external ID for the app user
* @param {String} id ID to send to Xtremepush
*/
XtremePush.prototype.setExternalId = function(id){
return exec(null, null, 'XtremePush', 'setExternalId', [id]);
};
/**
* Setting the subscription status of the app
* @param {bool} subscription true to enable subscription
*/
XtremePush.prototype.setSubscription = function(subscription){
return exec(null, null, 'XtremePush', 'setSubscription', [subscription]);
};
/**
* Calling function to open the app inbox
*/
XtremePush.prototype.openInbox = function(){
return exec(null, null, 'XtremePush', 'openInbox', []);
};
/**
* Retrieve the inbox badge number, will be returned to the function set above for inboxBadgeCallback
*/
XtremePush.prototype.getInboxBadge = function(){
return exec(null, null, 'XtremePush', 'getInboxBadge', []);
};
/**
* Returns device information
* @param {Function} success callback function which will be called in case of success of the function
*/
XtremePush.prototype.deviceInfo = function(success){
return exec(success, null, 'XtremePush', 'deviceInfo',[]);
};
/**
* Calling function to trigger the system permissions dialog for location services
*/
XtremePush.prototype.requestLocationsPermissions = function(){
return exec(null, null, 'XtremePush', 'requestLocationsPermissions', []);
};
/**
* Calling function to trigger the system permissions dialog for notifications (iOS only)
*/
XtremePush.prototype.requestPushPermissions = function(){
return exec(null, null, 'XtremePush', 'requestPushPermissions', []);
};
/**
* Calling function to show notification
*/
XtremePush.prototype.showNotification = function(id){
return exec(null, null, 'XtremePush', 'showNotification', [id]);
};
/**
* Calling function to open click in message
*/
XtremePush.prototype.clickMessage = function(id, action){
return exec(null, null, 'XtremePush', 'clickMessage', [id, action]);
};
/**
* Calling function to report message clicked
*/
XtremePush.prototype.reportMessageClicked = function(id, action){
return exec(null, null, 'XtremePush', 'reportMessageClicked', [id, action]);
};
/**
* Calling function to report message dismissed
*/
XtremePush.prototype.reportMessageDismissed = function(id){
return exec(null, null, 'XtremePush', 'reportMessageDismissed', [id]);
};
XtremePush.prototype.onConfigChanged = function(){
return exec(null, null, 'XtremePush', 'onConfigChanged', []);
};
XtremePush.prototype.unregisterForRemoteNotifications = function(){
return exec(null, null, 'XtremePush', 'unregisterForRemoteNotifications', []);
};
module.exports = new XtremePush();