{"_id":"@camerond-28/expo-server-sdk","_rev":"2-09c83a1ff57ecb56d321cd1b37149bb0","name":"@camerond-28/expo-server-sdk","dist-tags":{"latest":"3.6.2"},"versions":{"3.6.1":{"name":"@camerond-28/expo-server-sdk","version":"3.6.1","description":"Server-side library for working with Expo using Node.js","main":"build/ExpoClient.js","types":"build/ExpoClient.d.ts","scripts":{"build":"./build.sh","lint":"eslint src","prepare":"yarn build","test":"jest","tsc":"tsc","watch":"tsc --watch"},"eslintConfig":{"extends":"universe/node"},"jest":{"coverageDirectory":"<rootDir>/../coverage","preset":"ts-jest","rootDir":"src","testEnvironment":"node"},"repository":{"type":"git","url":"git+https://github.com/expo/expo-server-sdk-node.git"},"keywords":["expo","push-notifications"],"author":{"name":"support@expo.io"},"license":"MIT","bugs":{"url":"https://github.com/expo/expo-server-sdk-node/issues"},"homepage":"https://github.com/expo/expo-server-sdk-node#readme","dependencies":{"node-fetch":"^2.6.0","promise-limit":"^2.7.0","react-zlib-js":"^1.0.5","yarn":"^1.22.17"},"devDependencies":{"@types/jest":"^27.0.1","@types/node-fetch":"^2.5.12","eslint":"^7.32.0","eslint-config-universe":"^7.0.1","fetch-mock":"^9.11.0","jest":"^27.0.6","prettier":"^2.3.2","ts-jest":"~27.0.5","typescript":"^4.3.5"},"gitHead":"17739a2b41625b0f42935ae7f9c60ff1ae81f613","_id":"@camerond-28/expo-server-sdk@3.6.1","_nodeVersion":"16.13.1","_npmVersion":"8.3.0","dist":{"integrity":"sha512-U7PNmfhrdt+JXZTaYfjvyutE9Lh5P8RRtA2IRgQdScmf67qhxtLNzvY8RGa5EwedClcawtO+y/kcrRK5Wzlk1w==","shasum":"5416daa50bae24d6d949fa1ad04e9d0450f675eb","tarball":"https://registry.npmjs.org/@camerond-28/expo-server-sdk/-/expo-server-sdk-3.6.1.tgz","fileCount":6,"unpackedSize":31013,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKP4bACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGwQ/+Jk2xq+0GVHUEAXhmGH2rkYquBCHUR9O9Ht/gBVM/nIY20sWP\r\nQpkHGtqviaFs2Rs1ahBNCokuhEMH+lyjexkvRF0gQig4yTYFqKHN42ZmGIVY\r\nL04gbzaJY7FzpC3jIfEZ5wYg8o+UX1j9zGvSRzsDrm22sAAxoYU5tvrdjBAp\r\niSD58ix0eWH3zVIBK3Edf8kiWQqOOf0gLvVGYna9Hsqr9xFaiqaGZXayvXRp\r\nlOS3WAMUdKHjDNdM12GieqBS1XbP0+3Fn5VJFD5ChyLklwAAFcrzCbDDacx+\r\n5austr5C3d58ipwClSxgQ2OkXT5WHouCG98ZnM4JrTv9dOyTlcSUjt6KGKt5\r\n/iEczyEpxhGh0+CUIwoTNL0f9RfA+IgLdPeSiY1WtBf+echxsuPM6lX+KzOe\r\nAHLwhjX9dj/3CytWmxrFGtlbosH8knOlpYN0qykQvWfk0E8VugBhLNiD4Z1O\r\n0PV/6Wx/aONdvYfm1YrEAVOYadyIjE5L0/lWVvAE+Q678RveJdg72IDAnEGj\r\nYMIZkNKQKU4IvmCThCf+LEBvT4SJFax7cB8qWAuBQIr2zP57gIRq0uwhswrc\r\nOqPYLOeKiXv7avjpxzz+qoGib9N5aFUR6Nbmee2YUU7LPwLjvT04ima/JlSv\r\ncrxpCQoRR+P4Ny3gRSV9EeAnUNy3VCH4e1U=\r\n=Hn76\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCoX42LSSyaGUzrET/D7tApsqSJZD14y+kFrfYO53fCowIhAOrmdK7bjuTrCALnL/O1MSc3+VncNB00LHGhAmPCURiW"}]},"_npmUser":{"name":"camerond-28","email":"Cam170@icloud.com"},"directories":{},"maintainers":[{"name":"camerond-28","email":"Cam170@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/expo-server-sdk_3.6.1_1646853659245_0.7609167844332316"},"_hasShrinkwrap":false},"3.6.2":{"name":"@camerond-28/expo-server-sdk","version":"3.6.2","description":"Server-side library for working with Expo using Node.js","main":"build/ExpoClient.js","types":"build/ExpoClient.d.ts","scripts":{"build":"./build.sh","lint":"eslint src","prepare":"yarn build","test":"jest","tsc":"tsc","watch":"tsc --watch"},"eslintConfig":{"extends":"universe/node"},"jest":{"coverageDirectory":"<rootDir>/../coverage","preset":"ts-jest","rootDir":"src","testEnvironment":"node"},"repository":{"type":"git","url":"git+https://github.com/expo/expo-server-sdk-node.git"},"keywords":["expo","push-notifications"],"author":{"name":"support@expo.io"},"license":"MIT","bugs":{"url":"https://github.com/expo/expo-server-sdk-node/issues"},"homepage":"https://github.com/expo/expo-server-sdk-node#readme","dependencies":{"node-fetch":"^2.6.0","promise-limit":"^2.7.0","react-zlib-js":"^1.0.5","yarn":"^1.22.17"},"devDependencies":{"@types/jest":"^27.0.1","@types/node-fetch":"^2.5.12","eslint":"^7.32.0","eslint-config-universe":"^7.0.1","fetch-mock":"^9.11.0","jest":"^27.0.6","prettier":"^2.3.2","ts-jest":"~27.0.5","typescript":"^4.3.5"},"gitHead":"17739a2b41625b0f42935ae7f9c60ff1ae81f613","_id":"@camerond-28/expo-server-sdk@3.6.2","_nodeVersion":"16.13.1","_npmVersion":"8.3.0","dist":{"integrity":"sha512-/nh8Ui0i0xVmK8cX5km+cpW9fHma5vqSklc1HDZ18b/6Q+DEy7YasfEeTKw/97Fqfz+jS2c7J8ZXoOWUBp9kSQ==","shasum":"4f6fe1f5030bd467eb5307fba80dcce55f9b0cd6","tarball":"https://registry.npmjs.org/@camerond-28/expo-server-sdk/-/expo-server-sdk-3.6.2.tgz","fileCount":6,"unpackedSize":31023,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKQhPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrpVw/9GEO+4mG/O7BwMf9D14zf9wJQfYeSEJJtuuqsTdvb7SHWQ44v\r\n9HiRNODTpfMF2CrPO12DRu6kFeDln/COXWiHo8sJ/NyDHKFdXk2c18OY6iKY\r\nUeyq9hNLl+xDIJ649a/n5lhYoLCKirC6NHU7JSiUij0OI2xcvRzvUBrJyCmC\r\nkSE++YKvDZ/O0iOaBkui20yMMZUWhP8eq6xNqYfx8OZHM1PH+AgXr3goQvy4\r\nKkEzLPW3MEF7s/pQO2RuBupYhc1uBv3YSYKWOiDoJRfLiK6/AqyVjqsOSxIp\r\nyNBNEV8zhQJTAtIbboBich5MW2v6lu99OyDsHfFlHRG9gTILI9IN1NUHwOsO\r\nvCF3jmaf/gdereMOTCNnC53PLxdjtGqlR3fdNe6V/IL9Hz4jy3Pj0EPndfn0\r\nL6QXZkA2oqhxyJ50YnV3AzeM6s3GSQmhaT/9+fsQZjRBbbse9vjXbAOhXKr6\r\nxZXE+pe45dOmiK47nyH4kbgXnMQpCWtSJRfSBQtwiIFuoGunuD0Fvux/kdXi\r\nnNjwXjSmDZWO8X8Hu7Tk6KO5b7JHK+7c1m0PK07DFf8v+ElX1rqJqxwFumnf\r\n8K4Zn/xlUHtxZ21QtoSSTtsxG8aF08JhCfrec6noVNb/Wyfog9y8J4XDRCfS\r\nTcSLKsf4mNEf3Zhb/MB08DOBAAuKkyhMP8M=\r\n=bh2E\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEXbA/WYwmXil4IvHOQSv/aUXhaD5a1MypAQNEvH1d3WAiEAsSGHWk5KxpCv26urKQaqOaFoCJN/WPua6dlSQwqhqn8="}]},"_npmUser":{"name":"camerond-28","email":"Cam170@icloud.com"},"directories":{},"maintainers":[{"name":"camerond-28","email":"Cam170@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/expo-server-sdk_3.6.2_1646856271205_0.5082445250106753"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-09T19:20:59.193Z","3.6.1":"2022-03-09T19:20:59.417Z","modified":"2022-04-04T21:34:10.362Z","3.6.2":"2022-03-09T20:04:31.371Z"},"maintainers":[{"name":"camerond-28","email":"Cam170@icloud.com"}],"description":"Server-side library for working with Expo using Node.js","homepage":"https://github.com/expo/expo-server-sdk-node#readme","keywords":["expo","push-notifications"],"repository":{"type":"git","url":"git+https://github.com/expo/expo-server-sdk-node.git"},"author":{"name":"support@expo.io"},"bugs":{"url":"https://github.com/expo/expo-server-sdk-node/issues"},"license":"MIT","readme":"# expo-server-sdk-node ![Tests](https://github.com/expo/expo-server-sdk-node/workflows/Tests/badge.svg) [![codecov](https://codecov.io/gh/expo/expo-server-sdk-node/branch/master/graph/badge.svg)](https://codecov.io/gh/expo/expo-server-sdk-node)\nServer-side library for working with Expo using Node.js.\n\nIf you have problems with the code in this repository, please file issues & bug reports at https://github.com/expo/expo. Thanks!\n\n## Usage\n\n_Note: the following code assumes that you are using JavaScript modules with `import`. If you aren't then you should use the old syntax for the SDK import: `const { Expo } = require('expo-server-sdk')`._\n\n```bash\nyarn add expo-server-sdk\n```\n\n```js\nimport { Expo } from 'expo-server-sdk';\n\n// Create a new Expo SDK client\n// optionally providing an access token if you have enabled push security\nlet expo = new Expo({ accessToken: process.env.EXPO_ACCESS_TOKEN });\n\n// Create the messages that you want to send to clients\nlet messages = [];\nfor (let pushToken of somePushTokens) {\n  // Each push token looks like ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]\n\n  // Check that all your push tokens appear to be valid Expo push tokens\n  if (!Expo.isExpoPushToken(pushToken)) {\n    console.error(`Push token ${pushToken} is not a valid Expo push token`);\n    continue;\n  }\n\n  // Construct a message (see https://docs.expo.io/push-notifications/sending-notifications/)\n  messages.push({\n    to: pushToken,\n    sound: 'default',\n    body: 'This is a test notification',\n    data: { withSome: 'data' },\n  })\n}\n\n// The Expo push notification service accepts batches of notifications so\n// that you don't need to send 1000 requests to send 1000 notifications. We\n// recommend you batch your notifications to reduce the number of requests\n// and to compress them (notifications with similar content will get\n// compressed).\nlet chunks = expo.chunkPushNotifications(messages);\nlet tickets = [];\n(async () => {\n  // Send the chunks to the Expo push notification service. There are\n  // different strategies you could use. A simple one is to send one chunk at a\n  // time, which nicely spreads the load out over time:\n  for (let chunk of chunks) {\n    try {\n      let ticketChunk = await expo.sendPushNotificationsAsync(chunk);\n      console.log(ticketChunk);\n      tickets.push(...ticketChunk);\n      // NOTE: If a ticket contains an error code in ticket.details.error, you\n      // must handle it appropriately. The error codes are listed in the Expo\n      // documentation:\n      // https://docs.expo.io/push-notifications/sending-notifications/#individual-errors\n    } catch (error) {\n      console.error(error);\n    }\n  }\n})();\n\n...\n\n// Later, after the Expo push notification service has delivered the\n// notifications to Apple or Google (usually quickly, but allow the the service\n// up to 30 minutes when under load), a \"receipt\" for each notification is\n// created. The receipts will be available for at least a day; stale receipts\n// are deleted.\n//\n// The ID of each receipt is sent back in the response \"ticket\" for each\n// notification. In summary, sending a notification produces a ticket, which\n// contains a receipt ID you later use to get the receipt.\n//\n// The receipts may contain error codes to which you must respond. In\n// particular, Apple or Google may block apps that continue to send\n// notifications to devices that have blocked notifications or have uninstalled\n// your app. Expo does not control this policy and sends back the feedback from\n// Apple and Google so you can handle it appropriately.\nlet receiptIds = [];\nfor (let ticket of tickets) {\n  // NOTE: Not all tickets have IDs; for example, tickets for notifications\n  // that could not be enqueued will have error information and no receipt ID.\n  if (ticket.id) {\n    receiptIds.push(ticket.id);\n  }\n}\n\nlet receiptIdChunks = expo.chunkPushNotificationReceiptIds(receiptIds);\n(async () => {\n  // Like sending notifications, there are different strategies you could use\n  // to retrieve batches of receipts from the Expo service.\n  for (let chunk of receiptIdChunks) {\n    try {\n      let receipts = await expo.getPushNotificationReceiptsAsync(chunk);\n      console.log(receipts);\n\n      // The receipts specify whether Apple or Google successfully received the\n      // notification and information about an error, if one occurred.\n      for (let receiptId in receipts) {\n        let { status, message, details } = receipts[receiptId];\n        if (status === 'ok') {\n          continue;\n        } else if (status === 'error') {\n          console.error(\n            `There was an error sending a notification: ${message}`\n          );\n          if (details && details.error) {\n            // The error codes are listed in the Expo documentation:\n            // https://docs.expo.io/push-notifications/sending-notifications/#individual-errors\n            // You must handle the errors appropriately.\n            console.error(`The error code is ${details.error}`);\n          }\n        }\n      }\n    } catch (error) {\n      console.error(error);\n    }\n  }\n})();\n\n```\n\n## Developing\n\nThe source code is in the `src/` directory and babel is used to turn it into ES5 that goes in the `build/` directory.\n\nTo build, `npm run build`.\n\nTo build and watch for changes, `npm run watch`.\n\n## See Also\n\n  * https://github.com/expo-community/expo-server-sdk-ruby\n  * https://github.com/expo-community/expo-server-sdk-python\n","readmeFilename":"README.md"}