Last active
August 29, 2015 14:15
-
-
Save yodarjun/c669a82a8d25b1b57149 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @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