Skip to content

Instantly share code, notes, and snippets.

@yodarjun
Last active August 29, 2015 14:15
Show Gist options
  • Save yodarjun/c669a82a8d25b1b57149 to your computer and use it in GitHub Desktop.
Save yodarjun/c669a82a8d25b1b57149 to your computer and use it in GitHub Desktop.
/* @ngInject */
function Notification($http, $stateParams) {
'use strict';
var types = {
"LIKES_RESPONSE": {
text: "Someone liked your response!",
path: "response"
}
};
return {
push: function(object) {
var deviceToken = object.member.deviceToken;
var params = {
"request": {
"application": <YOUR PUSHWOOSH APP ID>,
"auth": <YOUR PUSHWOOSH API KEY>,
"notifications": [{
"send_date": "now",
"ignore_user_timezone": true,
"ios_root_params": {
"aps": {
"route": {
"path": types[object.type].path,
"params": $stateParams
}
}
},
"content": {
"en": types[object.type].text
},
"platforms": [1],
"ios_category_id": "1",
"devices": [deviceToken]
}]
}
};
$http.post('https://cp.pushwoosh.com/json/1.3/createMessage', params).then(success, failure);
function success() {
console.log("success");
}
function failure(error) {
window.Raven.captureException(error);
}
}
};
}
angular
.module('app.services')
.factory('Notification', Notification);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment