{"_id":"@bspedromanzo/react-native-foreground-service","_rev":"4-416af49dd9a5e49fa92548316321924b","name":"@bspedromanzo/react-native-foreground-service","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@bspedromanzo/react-native-foreground-service","version":"1.0.0","keywords":["react-native","foreground","service","android","voximplant"],"author":{"url":"https://voximplant.com","name":"Zingaya Inc.","email":"info@voximplant.com"},"license":"MIT","_id":"@bspedromanzo/react-native-foreground-service@1.0.0","maintainers":[{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"}],"homepage":"https://github.com/voximplant/react-native-foreground-service","bugs":{"url":"https://github.com/bspedromanzo/react-native-foreground-service/issues"},"dist":{"shasum":"edc7cfeaeafb4e9505a20a38c43b2d29521a3ab1","tarball":"https://registry.npmjs.org/@bspedromanzo/react-native-foreground-service/-/react-native-foreground-service-1.0.0.tgz","fileCount":13,"integrity":"sha512-OSdXwvBCpLq9q2KWgarLVHJKN3Gsay2cHRX4AEDQqBGn/vo2+qemELG0imgIUdPB6reux7KRtzhNn7mVLJe8cQ==","signatures":[{"sig":"MEUCIAvzWSkBAHDxV7UWIfzyRf7cC7ZhoEczjGiasY0/KZ1bAiEA5khfYH7a/32PJvImuLJXs5IEKgbmAVHlP2fEbi92zA0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34547},"main":"index.js","gitHead":"9f2e7241b2099744fafc68226733832a7658fa04","scripts":{},"_npmUser":{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"},"repository":{"url":"git+https://git@github.com/bspedromanzo/react-native-foreground-service.git","type":"git"},"_npmVersion":"9.8.1","description":"React native module to start foreground service on android","directories":{},"_nodeVersion":"18.18.2","_hasShrinkwrap":false,"peerDependencies":{"react-native":">= 0.41.2"},"_npmOperationalInternal":{"tmp":"tmp/react-native-foreground-service_1.0.0_1740171482394_0.6098290614427482","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@bspedromanzo/react-native-foreground-service","version":"1.0.2","keywords":["react-native","foreground","service","android","voximplant"],"author":{"url":"https://voximplant.com","name":"Zingaya Inc.","email":"info@voximplant.com"},"license":"MIT","_id":"@bspedromanzo/react-native-foreground-service@1.0.2","maintainers":[{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"}],"homepage":"https://github.com/voximplant/react-native-foreground-service","bugs":{"url":"https://github.com/bspedromanzo/react-native-foreground-service/issues"},"dist":{"shasum":"4a5b793a25170e5a3178bea8495565d0cac9c128","tarball":"https://registry.npmjs.org/@bspedromanzo/react-native-foreground-service/-/react-native-foreground-service-1.0.2.tgz","fileCount":13,"integrity":"sha512-DJ35ig+4ZKbjn5gAy/t5jbY08gUY3aT19H2LXwY0cF/VfPhyIGqlWTXU+YBFjNbFICWTZKo3n8gjU+5h6N/o2Q==","signatures":[{"sig":"MEQCIGs2vPi5YgAtPjGgSsDPFzYPpNNN/Q8xJQWjxSfcJzgMAiARbHolvhSJi2m93JFmfEnVytay97InxwAhhX5TN1zYKg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34547},"main":"index.js","gitHead":"4672f2432be84f63bff33de68d0f3c6346eac725","scripts":{},"_npmUser":{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"},"repository":{"url":"git+https://git@github.com/bspedromanzo/react-native-foreground-service.git","type":"git"},"_npmVersion":"9.8.1","description":"React native module to start foreground service on android","directories":{},"_nodeVersion":"18.18.2","_hasShrinkwrap":false,"peerDependencies":{"react-native":">= 0.41.2"},"_npmOperationalInternal":{"tmp":"tmp/react-native-foreground-service_1.0.2_1740172124223_0.6778227574103584","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@bspedromanzo/react-native-foreground-service","version":"1.0.3","keywords":["react-native","foreground","service","android","voximplant"],"author":{"url":"https://voximplant.com","name":"Zingaya Inc.","email":"info@voximplant.com"},"license":"MIT","_id":"@bspedromanzo/react-native-foreground-service@1.0.3","maintainers":[{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"}],"homepage":"https://github.com/voximplant/react-native-foreground-service","bugs":{"url":"https://github.com/bspedromanzo/react-native-foreground-service/issues"},"dist":{"shasum":"9e02d191c25b7d1140041a55423a5b173fff4733","tarball":"https://registry.npmjs.org/@bspedromanzo/react-native-foreground-service/-/react-native-foreground-service-1.0.3.tgz","fileCount":13,"integrity":"sha512-z9Ol9R7APm7VeDWCab7Yn1/gmyzPzjyrVH5PWh4eeyDL1kxjG6DSVbTVWyXzlYcC0gW80jx7ru50gE/ORJggiw==","signatures":[{"sig":"MEUCIBMMoAD5jPMmhzbhyAK2c331w1xl+5HZ5kJyUtFjhhnlAiEAxe7F88j2TrHORpW99w6agVbxm7U/zE68H7FrJ1iFrZQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34797},"main":"index.js","gitHead":"48e748df0f4e0e232d1b0f23dd17c8cdd11f5dc4","scripts":{},"_npmUser":{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"},"repository":{"url":"git+https://git@github.com/bspedromanzo/react-native-foreground-service.git","type":"git"},"_npmVersion":"9.8.1","description":"React native module to start foreground service on android","directories":{},"_nodeVersion":"18.18.2","_hasShrinkwrap":false,"peerDependencies":{"react-native":">= 0.41.2"},"_npmOperationalInternal":{"tmp":"tmp/react-native-foreground-service_1.0.3_1740188951054_0.04937125996212921","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@bspedromanzo/react-native-foreground-service","version":"1.0.4","keywords":["react-native","foreground","service","android","voximplant"],"author":{"url":"https://voximplant.com","name":"Zingaya Inc.","email":"info@voximplant.com"},"license":"MIT","_id":"@bspedromanzo/react-native-foreground-service@1.0.4","maintainers":[{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"}],"homepage":"https://github.com/voximplant/react-native-foreground-service","bugs":{"url":"https://github.com/bspedromanzo/react-native-foreground-service/issues"},"dist":{"shasum":"2e04748f1b0f2ce4fd795171a3ed75909a48c248","tarball":"https://registry.npmjs.org/@bspedromanzo/react-native-foreground-service/-/react-native-foreground-service-1.0.4.tgz","fileCount":13,"integrity":"sha512-ScCZKSZXUGgE2rEfPJER0GoowMe8u8QFQjMDB3Sw4GiJTuHSaOjMIuypwzmqwHpusxzFFfWQxoT1EcXwsHhYGg==","signatures":[{"sig":"MEYCIQCr5tnFIYkpX5yWJ54ZBLFnbaGaSsJiEq35h/0pI5tdrAIhAMFcOAdHmwFAgc5gr75pO/+OSkr824dw6e7XOG7L88v6","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34797},"main":"index.js","gitHead":"61d8d7cad46831ba125e335d4b38eed775c96817","scripts":{},"_npmUser":{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"},"repository":{"url":"git+https://git@github.com/bspedromanzo/react-native-foreground-service.git","type":"git"},"_npmVersion":"9.8.1","description":"React native module to start foreground service on android","directories":{},"_nodeVersion":"18.18.2","_hasShrinkwrap":false,"peerDependencies":{"react-native":">= 0.41.2"},"_npmOperationalInternal":{"tmp":"tmp/react-native-foreground-service_1.0.4_1740405693143_0.5976778480330274","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@bspedromanzo/react-native-foreground-service","version":"1.0.5","description":"React native module to start foreground service on android","main":"index.js","scripts":{},"repository":{"type":"git","url":"git+https://git@github.com/bspedromanzo/react-native-foreground-service.git"},"keywords":["react-native","foreground","service","android","voximplant"],"author":{"name":"Zingaya Inc.","email":"info@voximplant.com","url":"https://voximplant.com"},"license":"MIT","homepage":"https://github.com/voximplant/react-native-foreground-service","peerDependencies":{"react-native":">= 0.41.2"},"_id":"@bspedromanzo/react-native-foreground-service@1.0.5","gitHead":"e5129cdcfbd4fc43b86c47a88059bb2b8ce31821","bugs":{"url":"https://github.com/bspedromanzo/react-native-foreground-service/issues"},"_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-/glldLutO1LUD1l2NUlEq1hvVMTY2GLQI0Mhki5Oc25/SlhNt2jL2AGucUpRGZuqnKHIMl8T8T7Ew/wuJwzfEw==","shasum":"3d3f1685da03465babc7402f3dd2c44e46b54843","tarball":"https://registry.npmjs.org/@bspedromanzo/react-native-foreground-service/-/react-native-foreground-service-1.0.5.tgz","fileCount":13,"unpackedSize":34823,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFpMKabMnRefGMO4HRgnlDCv1REYeivTc8uAiRwjciBiAiBvIOHpdP0qutjlmSO9U1CgojNIx69MAXD90lrUU+50jA=="}]},"_npmUser":{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"},"directories":{},"maintainers":[{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-native-foreground-service_1.0.5_1740407645807_0.37294230267208106"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-21T20:58:02.308Z","modified":"2025-02-24T14:34:06.167Z","1.0.0":"2025-02-21T20:58:02.580Z","1.0.2":"2025-02-21T21:08:44.409Z","1.0.3":"2025-02-22T01:49:11.224Z","1.0.4":"2025-02-24T14:01:33.365Z","1.0.5":"2025-02-24T14:34:05.989Z"},"bugs":{"url":"https://github.com/bspedromanzo/react-native-foreground-service/issues"},"author":{"name":"Zingaya Inc.","email":"info@voximplant.com","url":"https://voximplant.com"},"license":"MIT","homepage":"https://github.com/voximplant/react-native-foreground-service","keywords":["react-native","foreground","service","android","voximplant"],"repository":{"type":"git","url":"git+https://git@github.com/bspedromanzo/react-native-foreground-service.git"},"description":"React native module to start foreground service on android","maintainers":[{"name":"phmanzo","email":"pedro.h.manzo@gmail.com"}],"readme":"\r\n# react-native-foreground-service\r\n\r\nA foreground service performs some operation that is noticeable to the user. \r\nFor example, an audio app would use a foreground service to play an audio track. \r\nForeground services must display a notification. \r\nForeground services continue running even when the user isn't interacting with the app.\r\n\r\nSee [the Android official documentation](https://developer.android.com/guide/components/services) for details on the concept.\r\n\r\n\r\n## Getting started \r\n\r\n`$ npm install @voximplant/react-native-foreground-service --save`\r\n\r\n### Automatic installation (Android only)\r\n\r\n- React Native 0.60+\r\n\r\n    CLI autolink feature links the module while building the app.\r\n\r\n    1. Add the FOREGROUND_SERVICE permission to the application's `AndroidManifest.xml`:\r\n        ```\r\n        <uses-permission android:name=\"android.permission.FOREGROUND_SERVICE\"/>\r\n        ```\r\n    2. Add VIForegroundService as a service to the application's `AndroidManifest.xml`:\r\n        ```\r\n        <service android:name=\"com.voximplant.foregroundservice.VIForegroundService\"> </service>\r\n\r\n- React Native <= 0.59\r\n\r\n    `$ react-native link @voximplant/react-native-foreground-service`\r\n\r\n    1. Add the FOREGROUND_SERVICE permission to the application's `AndroidManifest.xml`:\r\n        ```\r\n        <uses-permission android:name=\"android.permission.FOREGROUND_SERVICE\"/>\r\n        ```\r\n    2. Add VIForegroundService as a service to the application's `AndroidManifest.xml`:\r\n        ```\r\n        <service android:name=\"com.voximplant.foregroundservice.VIForegroundService\"> </service>\r\n        ```\r\n\r\n### Manual installation (Android only, React Native <= 0.59)\r\n1. Open up `android/app/src/main/java/[...]/MainActivity.java`\r\n    - Add `import com.voximplant.foregroundservice.VIForegroundServicePackage;` to the imports at the top of the file\r\n    - Add `new VIForegroundServicePackage()` to the list returned by the `getPackages()` method\r\n2. Append the following lines to `android/settings.gradle`:\r\n  \t```\r\n  \tinclude ':@voximplant_react-native-foreground-service'\r\n    project(':@voximplant_react-native-foreground-service').projectDir = new File(rootProject.projectDir, '../node_modules/@voximplant/react-native-foreground-service/android')\r\n  \t```\r\n3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\r\n  \t```\r\n    implementation project(':@voximplant_react-native-foreground-service')\r\n  \t```\r\n4. Add the FOREGROUND_SERVICE permission to the application's `AndroidManifest.xml`:\r\n    ```\r\n    <uses-permission android:name=\"android.permission.FOREGROUND_SERVICE\"/>\r\n    ```\r\n5. Add VIForegroundService as a service to the application's `AndroidManifest.xml`:\r\n    ```\r\n    <service android:name=\"com.voximplant.foregroundservice.VIForegroundService\"\r\n             android:exported=\"false\"> </service>\r\n    ```\r\n6. For targetSdkVersion Android API >= 31\r\n\r\n    Add android:exported=\"true\" to the application's `AndroidManifest.xml` activity section\r\n    ```\r\n    <activity\r\n        android:name=\".MainActivity\"\r\n        android:label=\"@string/app_name\"\r\n        android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\"\r\n        android:windowSoftInputMode=\"adjustResize\"\r\n        android:exported=\"true\">        <===== Add this line\r\n    ```\r\n\r\n## Demo project\r\nDemo application: [react-native-foreground-service-demo](https://github.com/voximplant/react-native-foreground-service-demo)\r\n  \t\r\n## Usage\r\n\r\n### Import module\r\n```javascript\r\nimport VIForegroundService from '@voximplant/react-native-foreground-service';\r\n```\r\n\r\n### Create notification channel (Android 8+)\r\nSince the foreground service must display a notification, for Android 8+ it is required to create a notification \r\nchannel first:\r\n```javascript\r\nconst channelConfig = {\r\n    id: 'channelId',\r\n    name: 'Channel name',\r\n    description: 'Channel description',\r\n    enableVibration: false\r\n};\r\nawait VIForegroundService.getInstance().createNotificationChannel(channelConfig);\r\n```\r\n\r\n### Start foreground service\r\n```javascript\r\nasync startForegroundService() {\r\n    const notificationConfig = {\r\n        channelId: 'channelId',\r\n        id: 3456,\r\n        title: 'Title',\r\n        text: 'Some text',\r\n        icon: 'ic_icon',\r\n        button: 'Some text',\r\n    };\r\n    try {\r\n        await VIForegroundService.getInstance().startService(notificationConfig);\r\n    } catch (e) {\r\n        console.error(e);\r\n    }\r\n}\r\n```\r\n\r\n### Stop foreground service\r\n```javascript\r\nawait VIForegroundService.getInstance().stopService();\r\n```\r\n\r\n## Reference\r\n\r\n### Methods\r\n```javascript\r\nasync startService(notificationConfig)\r\n```\r\nStarts the foreground service and displays a notification with the defined configuration\r\n\r\n------------------------------\r\n\r\n```javascript\r\nasync stopService()\r\n```\r\nStops the foreground service\r\n\r\n------------------------------\r\n\r\n```javascript\r\nasync createNotificationChannel(channelConfig)\r\n```\r\nCreates a notification channel for the foreground service. \r\nFor Android 8+ the notification channel should be created before starting the foreground service\r\n\r\n------------------------------\r\n\r\n```javascript\r\non(event, handler)\r\n```\r\nAdds a `handler` to be invoked when a button on the notification is pressed.\r\nSupported event: `VIForegroundServiceButtonPressed`.\r\n\r\n------------------------------\r\n\r\n```javascript\r\noff(event, handler)\r\n```\r\nRemoves the registered `handler` for the `VIForegroundServiceButtonPressed` event.\r\nIf `handler` is not provided, this function will remove all registered handlers.\r\n\r\n### Configs\r\n```javascript\r\nNotificationChannelConfig\r\n```\r\n| Property name   | Description                                                                                                           | Required |\r\n|-----------------|-----------------------------------------------------------------------------------------------------------------------|----------|\r\n| id              | Unique channel id                                                                                                     | yes      |\r\n| name            | Notification channel name                                                                                             | yes      |\r\n| description     | Notification channel description                                                                                      | no       |\r\n| importance      | Notification channel importance. One of:<ul><li>1 – 'min'</li> <li>2 – 'low' (by default)</li><li>3 – 'default'</li><li>4 – 'high'</li><li>5 – 'max'</li></ul> | no       |\r\n| enableVibration | Sets whether notification posted to this channel should vibrate. False by default.                                    | no       |\r\n\r\n```javascript\r\nNotificationConfig\r\n```\r\n\r\n| Property name | Description                                                                                                                                             | Required              |\r\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|\r\n| channelId     | Notification channel id to display the notification                                                                                                     | yes (Android 8+ only) |\r\n| id            | Unique notification id                                                                                                                                  | yes                   |\r\n| title         | Notification title                                                                                                                                      | yes                   |\r\n| text          | Notification text                                                                                                                                       | yes                   |\r\n| icon          | Icon name                                                                                                                                               | yes                   |\r\n| button        | Button text                                                                                                                                             | no                    |\r\n| priority      | Priority of this notification. One of: <ul><li>&nbsp;0 – PRIORITY_DEFAULT (by default)</li><li>-1 – PRIORITY_LOW</li><li>-2 – PRIORITY_MIN</li><li>&nbsp;1 – PRIORITY_HIGH</li><li>&nbsp;2 – PRIORITY_MAX</li></ul> | no       |# react-native-foreground-service\n","readmeFilename":"README.md"}