Push notification 电子中的推送通知

Push notification 电子中的推送通知,push-notification,electron,Push Notification,Electron,有没有办法在electron中使用firebase推送通知?我想为我的electron应用程序创建一个推送通知,这是一个聊天应用程序,每当有新消息出现时,我都想获得该通知。但我没有在网上获得任何好的材料来实现它。我该如何实现它呢?您可以使用,或者如果您喜欢自己实现它,使用Websocket websocket的Python代码段 客户端: from ws4py.client.threadedclient import WebSocketClient client_url = "ws://serv

有没有办法在electron中使用firebase推送通知?我想为我的electron应用程序创建一个推送通知,这是一个聊天应用程序,每当有新消息出现时,我都想获得该通知。但我没有在网上获得任何好的材料来实现它。我该如何实现它呢?

您可以使用,或者如果您喜欢自己实现它,使用Websocket

websocket的Python代码段

客户端:

from ws4py.client.threadedclient import WebSocketClient
client_url = "ws://server_url + "/websocket/create
ws_client = WebsocketClient(client_url)
ws_client.connect()
服务器端:假设您有一台服务器,其服务器url为api/websocket/create服务:

from ws4py.websocket import WebSocket

class ws_server(Websocket):
    WebSocket.__init__(self, *args, **kwargs)

class WebSocketHandler(object):

    @cherrypy.expose
    def create(self):
        # wsInstance is of type ws_server. Must set userName.
        wsInstance = cherrypy.request.ws_handler
在服务器的配置中:

cherrypy.tree.mount(WebSocketHandler(), '/websocket',
                            config={
                                '/': {
                                    'tools.response_headers.on': True,
                                    'tools.sessions.locking': 'explicit',
                                    'tools.websocket.on': True,
                                    'tools.websocket.handler_cls': ws_server,
                                },
                            })