Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1.  
  2. var gcm = require('node-gcm');
  3.  
  4. var message = new gcm.Message();
  5.  
  6. message.addNotification('title', 'Oli');
  7. message.addNotification('icon', 'ic_launcher');
  8. message.addNotification('body', 'Dani');
  9.  
  10.  
  11. //Add your mobile device registration tokens here
  12. var regTokens = ['eEkUuNzhlO4:APA91bG5_BSb6q_5LQ3KaQJJ1mG7juGDObuXoteiL-YRW2bsaAjY_SGJAmSFVHp8e1oXPcJXLRdkhYN2Zl4yg1oia_mkW9_9bmvvCymzHwwQvO10m2pHrox3nX8yYI1EbIYNE_lPCcxq'];
  13. //var regTokens = ['fDW5baHE-Fo:APA91bGupJIm8pXHAezE9--WTU85Lm0bBF3fW3KkZkM3DpAvHY-SppqbUUJfjQn-orXqxaXq6HAPHvFtwArV81vOCIkZhjtg2EKxcnAdZqrKQAjGbtraz5-i5vp6HeA1x2GC9tbBopUo'];
  14. //Replace your developer API key with GCM enabled here
  15. var sender = new gcm.Sender('AIzaSyCacxA1c8lCDcBSHy3UqUivvJqRSEGFHiE');
  16.  
  17. sender.send(message, regTokens, function (err, response) {
  18. if(err) {
  19. console.error(err);
  20. } else {
  21. console.log(response);
  22. }
  23. });
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. const apn = require('apn');
  32.  
  33. let options = {
  34. token: {
  35. key: "APNsAuthKey_XKCR67883A.p8",
  36. // Replace keyID and teamID with the values you've previously saved.
  37. keyId: "XKCR67883A",
  38. teamId: "45G735U63R"
  39. },
  40. production: true
  41. };
  42.  
  43. let apnProvider = new apn.Provider(options);
  44.  
  45. // Replace deviceToken with your particular token:
  46. let deviceToken = "5e130a69f04e663f7b7b94ceb78076b0937ecddca88990cbe3fbac8b5ad398b8";
  47.  
  48. // Prepare the notifications
  49. let notification = new apn.Notification();
  50. notification.expiry = Math.floor(Date.now() / 1000) + 3600; // will expire in 24 hours from now
  51. notification.badge = 2;
  52. notification.sound = "ping.aiff";
  53. notification.alert = "aqui =D";
  54. notification.payload = {'messageFrom': 'Solarian Programmer'};
  55.  
  56. // Replace this with your app bundle ID:
  57. notification.topic = "cl.Samtech.IsamtechCL";
  58.  
  59. // Send the actual notification
  60. apnProvider.send(notification, deviceToken).then( result => {
  61. // Show the result of the send operation:
  62. console.log(result);
  63. process.exit();
  64. });
  65.  
  66.  
  67. // Close the server
  68. apnProvider.shutdown();
  69.  
  70.  
  71.  
  72.  
  73.  
  74. var Connection = require('tedious').Connection;
  75. var config = {
  76. userName: 'usuWEb2s',
  77. password : 'Smt7$RtvB2',
  78. server : '192.168.1.7',
  79. options:{
  80. database: 'BaseGPSF'
  81. }
  82. }
  83. var connection = new Connection(config);
  84. connection.on('connect', function(err){
  85. console.log("Connected");
  86. executeStatement();
  87. })
  88.  
  89.  
  90. var Request = require('tedious').Request;
  91. var TYPES = require('tedious').TYPES;
  92.  
  93. function executeStatement() {
  94. request = new Request("SELECT top 1000 usuario, deviceToken, fecha_inserta from isam..NotificationIOS_hist;", function(err) {
  95. if (err) {
  96. console.log(err);}
  97. });
  98. var result = "";
  99. request.on('row', function(columns) {
  100. columns.forEach(function(column) {
  101. if (column.value === null) {
  102. console.log('NULL');
  103. } else {
  104. result+= column.value + " ";
  105. }
  106. });
  107. console.log(result);
  108. result ="";
  109. });
  110.  
  111. request.on('done', function(rowCount, more) {
  112. console.log(rowCount + ' rows returned');
  113. });
  114. connection.execSql(request);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement