This a demo project for react-native-foreground-service module.
react-native-foregroun-service
library allows to stat and stop foreground service on Android platform.
- Clone the project
- Run
yarn install
command in the terminal - Build and run splurt-server
- Run
yarn start
in the terminal - Run
yarn run-android
in another terminal instance
- Register a
user
to splurt-server by pushing to users collection in the db
{
"name": "<user_name>",
"pwd": "<user_password>"
}
- Register a
service
to splurt-server by pushing it to services collection in the db
{
"name": "<service_name>",
"pwd": "<service_password>"
}
- Login the user via phone
- Define the following environment variables (enter each line separately)
service_name="<service_name>"
service_password="<service_password>"
http_port="8888"
user_id="<logged user's _id property from db>"
- Login the service to receive a
service_jwt
by running this command
service_jwt=$(curl -d "{\"name\":\"$service_name\", \"pwd\":\"$service_password\"}"\
-H "Content-Type: application/json"\
-X POST "http://localhost:$http_port/services/login")
- Push service notification
message
to a user by making a user request to auser_id
echo $(curl -X POST "http://localhost:$http_port/push/$user_id"\
-H "Authorization: Bearer $service_jwt"\
-H "Content-Type: application/json"\
-d '{ "title": "message" }')
- user: client account that would receive notifications
- service: service that would be sending notifications
- service_jwt: JSON web token used for service authentication to be able to send notifications
- http_port: port that was setup in the splurt server (default is 8888)
- user_id: id of the user inside the users collection
- message: string to be pushed as notification to user
MIT