Send notifications from a site for push android notifications

0

I created a social network, and I implemented notifications in it. However, I can not find an effective way to send site notifications (tastings, comments, messages) via push notifications to the android app. I configured the firebase, the onesignal, and the application receives test pushs, but how do I send these notifications that are on my server to a mobile device? I know I need Firebase for this, but how do I send server notifications to firebase? Can anyone give me a light? I have been on this project for months and I can not seem to get out of the blue.

    
asked by anonymous 02.09.2017 / 04:28

1 answer

0

On your server, basically, you need to make a post for this url ( link ) with your server's key within the Authorization header and the Content-Type (for JSON is "application / json"), passing in JSON format the token of the device to be sent the notification and an object containing data to display the notification itself and / or another object with data that you may want to trap in Service that you must have implemented in Android. These parameters can be, as in the example:

{
    "to": "token_do_usuario",
    "data": {
        "chave": "algum_dado_que_voce_queira_passar"
    },
    "notification": {
        "title": "Título da notificação",
        "body": "Detalhes da notificação",
        "sound": "default"
    }
}

Remembering this is an example. You can get more details at: link

    
02.09.2017 / 05:15