Skip to content

Instantly share code, notes, and snippets.

@yodarjun
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save yodarjun/c669a82a8d25b1b57149 to your computer and use it in GitHub Desktop.

Select an option

Save yodarjun/c669a82a8d25b1b57149 to your computer and use it in GitHub Desktop.

Revisions

  1. @Arjunanand Arjunanand revised this gist Feb 12, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Notification.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    /* @ngInject */
    function Notification($firebase, $http, $stateParams, FirebaseMember, config) {
    function Notification($http, $stateParams) {
    'use strict';
    var types = {
    "LIKES_RESPONSE": {
  2. @Arjunanand Arjunanand created this gist Feb 12, 2015.
    52 changes: 52 additions & 0 deletions Notification.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    /* @ngInject */
    function Notification($firebase, $http, $stateParams, FirebaseMember, config) {
    '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);