I'm using node-push server from here
I'm able to start the server successfully. Below is my config file
{
"webPort": 8000,
"mongodbUrl": "mongo URL",
"gcm": {
"apiKey": "API KEY"
},
"apn": {
"connection": {
"gateway": "gateway.sandbox.push.apple.com",
"cert": "/path/to/cert.pem",
"key": "/path/to/key.pem"
},
"feedback": {
"address": "feedback.sandbox.push.apple.com",
"cert": "/path/to/cert.pem",
"key": "/path/to/key.pem",
"interval": 43200,
"batchFeedback": true
}
}
}
Below is my service
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.get('/sendTestGCM',function(request,response){
var querystring = require('querystring');
var http = require('http');//importing http
var registrationIds = [];
registrationIds.push('key here');
var gcm_android = querystring.stringify({//message to be sent
"users": registrationIds,
"android": {
"data": {
"message": "Test Message with Node-push server package"
}
},
"type":"android"
});
var options = { //URL information
host: 'localhost',
path: '/send',
port: '8000',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': gcm_android.length
}
};
var post_request = http.request(options,function(res){//Post Request
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
console.log("status code"+res.statusCode);
response.end(""+chunk);
});
});
post_request.write(gcm_android);
post_request.end();
});
app.listen("port");
When I test this service it is throwing exception as "Error: No default engine was specified and no extension was provided.".
Anyone please suggest me reason for this.
Thanks In Advance.