Firebase Cloud Messaging notification from Java instead of Firebase Console

前端 未结 7 1782
野趣味
野趣味 2020-12-12 16:21

I am new to Firebase and I am running into errors such as mismatch sender id and Authentication Error with HTTP status 401 when my Java application tries to send a notificat

7条回答
  •  春和景丽
    2020-12-12 17:19

    I needed to send FCM notification from my java EE application and I found this very helpful. Might save someone some time.

    ...The github repo is a library interface for Firebase Cloud Messaging (FCM) API (NB// I am not the author). So I followed instructions in the readme: added the jar file as a dependency to my project and could just invoke the library methods with respective parameters.

    e.g. Pushraven.setKey(my_key); to set your server key and

    Notification raven = new Notification();
    raven.title("MyTitle")
         .text("Hello World!")
         .color("#ff0000")
         .to(client_key);
    

    to build a notification. The instructions from the repo are pretty much clear and helpful.

提交回复
热议问题