Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

Http request to google cloud messaging - unauthorized error

$
0
0

@badaboomba wrote:

Hello, Im trying to do a http request for push notification. Below is my code,

     var req = {
        method: 'POST',
        url: 'https://gcm-http.googleapis.com/gcm/send',

        headers: {
            'Content-Type': 'application/json',
                'Authorization': apiKey
        },
        body: JSON.stringify({
	        'to' : deviceToken,
	        "data": {
	          "title": "fdsafdsa",
	          "message": "gdsa"
        	}
        })
    };

   $http(req).success(function(resp){

      console.log("Push success", resp);
    }).error(function(error){

      console.log("Push error", error);
    });

As the title suggest, the request isn't going through and am getting an unauthorized error. Any help would be greatly appreciated.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>