Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var gcm = require('node-gcm');
- var message = new gcm.Message();
- message.addNotification('title', 'Oli');
- message.addNotification('icon', 'ic_launcher');
- message.addNotification('body', 'Dani');
- //Add your mobile device registration tokens here
- var regTokens = ['eEkUuNzhlO4:APA91bG5_BSb6q_5LQ3KaQJJ1mG7juGDObuXoteiL-YRW2bsaAjY_SGJAmSFVHp8e1oXPcJXLRdkhYN2Zl4yg1oia_mkW9_9bmvvCymzHwwQvO10m2pHrox3nX8yYI1EbIYNE_lPCcxq'];
- //var regTokens = ['fDW5baHE-Fo:APA91bGupJIm8pXHAezE9--WTU85Lm0bBF3fW3KkZkM3DpAvHY-SppqbUUJfjQn-orXqxaXq6HAPHvFtwArV81vOCIkZhjtg2EKxcnAdZqrKQAjGbtraz5-i5vp6HeA1x2GC9tbBopUo'];
- //Replace your developer API key with GCM enabled here
- var sender = new gcm.Sender('AIzaSyCacxA1c8lCDcBSHy3UqUivvJqRSEGFHiE');
- sender.send(message, regTokens, function (err, response) {
- if(err) {
- console.error(err);
- } else {
- console.log(response);
- }
- });
- const apn = require('apn');
- let options = {
- token: {
- key: "APNsAuthKey_XKCR67883A.p8",
- // Replace keyID and teamID with the values you've previously saved.
- keyId: "XKCR67883A",
- teamId: "45G735U63R"
- },
- production: true
- };
- let apnProvider = new apn.Provider(options);
- // Replace deviceToken with your particular token:
- let deviceToken = "5e130a69f04e663f7b7b94ceb78076b0937ecddca88990cbe3fbac8b5ad398b8";
- // Prepare the notifications
- let notification = new apn.Notification();
- notification.expiry = Math.floor(Date.now() / 1000) + 3600; // will expire in 24 hours from now
- notification.badge = 2;
- notification.sound = "ping.aiff";
- notification.alert = "aqui =D";
- notification.payload = {'messageFrom': 'Solarian Programmer'};
- // Replace this with your app bundle ID:
- notification.topic = "cl.Samtech.IsamtechCL";
- // Send the actual notification
- apnProvider.send(notification, deviceToken).then( result => {
- // Show the result of the send operation:
- console.log(result);
- process.exit();
- });
- // Close the server
- apnProvider.shutdown();
- var Connection = require('tedious').Connection;
- var config = {
- userName: 'usuWEb2s',
- password : 'Smt7$RtvB2',
- server : '192.168.1.7',
- options:{
- database: 'BaseGPSF'
- }
- }
- var connection = new Connection(config);
- connection.on('connect', function(err){
- console.log("Connected");
- executeStatement();
- })
- var Request = require('tedious').Request;
- var TYPES = require('tedious').TYPES;
- function executeStatement() {
- request = new Request("SELECT top 1000 usuario, deviceToken, fecha_inserta from isam..NotificationIOS_hist;", function(err) {
- if (err) {
- console.log(err);}
- });
- var result = "";
- request.on('row', function(columns) {
- columns.forEach(function(column) {
- if (column.value === null) {
- console.log('NULL');
- } else {
- result+= column.value + " ";
- }
- });
- console.log(result);
- result ="";
- });
- request.on('done', function(rowCount, more) {
- console.log(rowCount + ' rows returned');
- });
- connection.execSql(request);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement