{"_rev":"3-1495e129662034f2d8f081747dccc952","time":{"created":"2024-01-24T11:02:22.312Z","1.0.0":"2024-01-24T10:23:45.670Z","modified":"2024-01-24T11:02:22.928Z","1.0.7":"2024-01-24T11:02:22.648Z"},"_id":"@alifaiz/strapi-plugin-expo-notifications","name":"@alifaiz/strapi-plugin-expo-notifications","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.7":{"name":"@alifaiz/strapi-plugin-expo-notifications","version":"1.0.7","description":"Send expo notifications from Strapi","repository":{"type":"git","url":"git+https://github.com/ali-faiz-brainx/strapi-plugin-expo-notifications.git"},"license":"MIT","author":{"name":"Ali Faiz","email":"ali.faiz@brainxtech.com","url":"https://www.brainxtech.com"},"maintainers":[{"name":"alifaiz","email":"ali.faiz@brainxtech.com"}],"dependencies":{"expo-server-sdk":"^3.6.0"},"peerDependencies":{"@strapi/strapi":"^4.6.0"},"engines":{"node":">=16.x.x <=21.x.x"},"strapi":{"name":"expo-notifications","description":"Send expo notifications from Strapi","kind":"plugin","displayName":"My Notifications"},"gitHead":"b537f03c6a17d5667608dc61103b1afc7343ae1f","bugs":{"url":"https://github.com/ali-faiz-brainx/strapi-plugin-expo-notifications/issues"},"homepage":"https://github.com/ali-faiz-brainx/strapi-plugin-expo-notifications#readme","_id":"@alifaiz/strapi-plugin-expo-notifications@1.0.7","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"integrity":"sha512-/o22f3SGm5Ljbk1kqQsvOMQsryhHy2PSagVWn2MVdiWom2ZbIqupWRfkm1z1YzpOWxSplTH1zeTtUtFj8XeYLQ==","shasum":"1ad2d549e077061810cca62be9cff7f8513bccbd","tarball":"https://registry.npmjs.org/@alifaiz/strapi-plugin-expo-notifications/-/strapi-plugin-expo-notifications-1.0.7.tgz","fileCount":51,"unpackedSize":67110,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDNB1J4YXnmC/TmK9rMzhnKKp6wiFf//a0RT2zulX5pdAiEApuTlZrK+Xgy/Dyw8o187IG7iBfLxnp5v56a8yy+ohOw="}]},"_npmUser":{"name":"alifaiz","email":"ali.faiz@brainxtech.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strapi-plugin-expo-notifications_1.0.7_1706094142419_0.1431359258259539"},"_hasShrinkwrap":false}},"maintainers":[{"name":"alifaiz","email":"ali.faiz@brainxtech.com"}],"description":"Send expo notifications from Strapi","homepage":"https://github.com/ali-faiz-brainx/strapi-plugin-expo-notifications#readme","repository":{"type":"git","url":"git+https://github.com/ali-faiz-brainx/strapi-plugin-expo-notifications.git"},"author":{"name":"Ali Faiz","email":"ali.faiz@brainxtech.com","url":"https://www.brainxtech.com"},"bugs":{"url":"https://github.com/ali-faiz-brainx/strapi-plugin-expo-notifications/issues"},"license":"MIT","readme":"# Strapi plugin expo-notifications\n\n<img width=\"1322\" alt=\"screen_notofications\" src=\"https://user-images.githubusercontent.com/12623963/209171709-1121a482-f61e-475a-a291-3d96c15b1e7a.png\">\n\n## Latest additions\n\nAs of v2.0.1, error reports are fully relayed by the plugin. Each notification sent will get an array of errorsWhileSending and, five minutes later, an array of errorsWhileReceiving in the receivers field (json). You will then be able to remove the dysfunctional expoPushTokens from the concerned users. Please don't forget to do it on a regular basis, as properly handling errors and removing non-functioning tokens is important for ensuring reliable delivery of notifications.\n\nAs of v1.10.0, you have the option to attach a Strapi entry as JSON data.\nThe messages sent by the plugin will have the following structure:\n\n```\n\n{\nto: 'ExponentPushToken[XXX]',\nsound: 'default',\ntitle: 'Your title',\nbody: 'Your subtitle',\ndata: { contentType: [model_name], entryId: [id_of_the_entry] } // Optional\n}\n\n```\n\n## Introduction\n\nExpo-notifications is a Strapi plugin that allows a Strapi user to send notifications via the Expo API directly from the Strapi admin panel. Typical use case: you have a react-native app connected to Strapi and you wish to notify your users about some newly published content without leaving the CMS.\n\nFor the moment, the notification object is dead simple - a title, a subtitle and a Strapi entry as json data.\n\n## How does it work ?\n\nThe plugin expects a list of expoPushTokens in order to know where to send the notifications. So the set-up will consist in getting those tokens from the mobile app, storing them into Strapi and then gather the correct credentials.\n\n### Step 1: Get the expoPushToken of your mobile user\n\nIn order to send a notification to the users of your react-native app, you first have to get their own unique expoPushToken. This can be achieved via the Notifications.getExpoPushTokenAsync() function at the root of your mobile app.\n\n```\n\nconst token = await Notifications.getExpoPushTokenAsync().data;\n\n```\n\nThe Expo docs will guide you through this step: https://docs.expo.dev/push-notifications/push-notifications-setup/.\n\n### Step 2: Save the expoPushToken in Strapi\n\nNow that you have the mobile app's expoPushToken, you can store it in Strapi. This will be done by adding a dedicated field to your existing users content-type. The field has to be called expoPushToken and expect a string.\n\n![screen_add_field](https://user-images.githubusercontent.com/12623963/209175619-7fd1eda7-a89b-491a-a39c-f5f02836f625.png)\n\nUpdate your user with his/her expoPushToken. The plugin will scan your users list in search for their expoPushToken: each time a token is found, the user is added to a list of potential receivers.\n\n### Step 3: Configure the credentials\n\nNot the funniest part but you have to go through it: make sure you get the correct credentials to send notifications to IOS and Android devices. The way to get these credentials is explained in the Expo docs: https://docs.expo.dev/versions/latest/sdk/notifications/#credentials-configuration\n\n## Installation\n\nRun any of the following commands inside your strapi directory to install the plugin:\n\n```\n\nnpm i @surunnuage/strapi-plugin-expo-notifications\n\nyarn add @surunnuage/strapi-plugin-expo-notifications\n\n```\n\nThen, to allow the plugin to appear in Strapi admin's panel:\n\n```\n\nnpm run build\n\nyarn build\n\n```\n\n## Usage\n\n### Enable the plugin\n\nOpen the `config/plugins.js` file (or create it if it's not there) and enable the plugin. It will look as follow:\n\n```\n\njs\nmodule.exports = ({ env }) => ({\n  ...\n  \"expo-notifications\": {\n    enabled: true,\n  },\n  ...\n});\n\n```\n\n### [Optional but recommended] Add your expo key\n\nIn order to securely use the Expo push notifications API, an Expo Access Token can be added to an `.env` file (so it won't be commited to Github or another version control system). The token must be called EXPO_ACCESS_TOKEN. You can find yours here: https://expo.dev/accounts/YOUR_EXPO_USERNAME/settings/access-tokens\n\n```\nEXPO_ACCESS_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n```\n\n### [Optional] Add a test token\n\nExpo-notifications allows you to add a test token in order to test your submission before the real sending (a test button will appear if the plugin finds a test token):\n\n```\n\njs\nmodule.exports = ({ env }) => ({\n  ...\n  \"expo-notifications\": {\n    enabled: true,\n    config: {\n      testToken: \"ExponentPushToken[xxxxxxxxxxxxxxxxxxx]\",\n    },\n  },\n  ...\n});\n\n```\n\nAnd that's it, now you can send notifications to your mobile app directly from Strapi.\n\n## Further developments:\n\nNice to have:\n\n- Customization options\n- Scheduler\n\nLicense: MIT - https://opensource.org/licenses/MIT\n","readmeFilename":"README.md"}