-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcocoon_notifications_parse.js
More file actions
42 lines (39 loc) · 1.7 KB
/
cocoon_notifications_parse.js
File metadata and controls
42 lines (39 loc) · 1.7 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
(function(){
if (window.cordova && typeof require !== 'undefined') {
require('cocoon-plugin-notifications-common.Notifications'); //force dependency load
}
var Cocoon = window.Cocoon;
/**
* This namespace represents the Cocoon Notification extension for push notifications using Parse
* @namespace Cocoon.Notification.Parse
*
* @example
* //Set up notification listener
* Cocoon.Notification.Parse.on(notification, function(userData){
* console.log("A push notification has been received: " + JSON.stringify(userData));
* });
*
* // Initialize the service. Ready to start receiving notification callbacks
* // The initialization parameters should be passed as commandline argument APP_ID and CLIENT_KEY or using the Cocoon cloud plugin parameters.
* // The service will be automatically registered after the initialization. This may show a Dialog to request user permissions.
* // You can disable autoregister with {register: false} params and call Cocoon.Notification.Local.register() manually to control when the permissions dialog is shown.
* // By default the register parameter is set to true.
*
* Cocoon.Notification.Parse.initialize({register: false}, function(registered) {
* if (!registered) {
* alert('Push notifications disabled by user')
* }
* else {
* subscribeRemoteChannel();
* }
* })
*
* function subscribeRemoteChannel() {
*
* }
*/
Cocoon.define("Cocoon.Notification", function(extension) {
extension.Parse = new Cocoon.Notification.NotificationService('LDNotificationParsePlugin');
return extension;
});
})();