Skip to content

gasparnd/push-notification-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Get started

Install fastapi

pip install fastapi

or

pip3 install fastapi
pip install "uvicorn[standard]"

or

pip3 install "uvicorn[standard]"

Install dependencies

pip install pydantic

or

pip3 install pydantic
pip install exponent_server_sdk

or

pip3 install exponent_server_sdk

Start server

Run this command in your console, in the root of the project

$ uvicorn main:app --reload

How to use it

  1. Update the notification token with your device
NOTIFICATION_TOKEN = "YOUR NOTIFICATION TOKEN HERE"
  1. Use the post method send_notification . It needs the next values to send a notification:
{
    "route": "your app route",
    "title": "Title of the notification",
    "body": "Body of the notification",
    "userId": 234,
    "userName": "Gaspar"
}

How to send different data?

Update the "NotifactionModel", and "PushMessage" method.


class NotificationModel(BaseModel):
    ...
    newValue: str

message = PushMessage(
  to=NOTIFICATION_TOKEN,
  title=notification_item.title,
  body=notification_item.body,
  data={
    ...
    'userName': notification_item.userName, 'newValue': notification_item.newValue
  }
  )

Post method:

{
    "route": "your app route",
    "title": "Title of the notification",
    "body": "Body of the notification",
    "userId": 234,
    "userName": "Gaspar",
    "newValue": "Fuu"
}

About

A simple push notification service in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages