All Projects → PopTudor → Java-fcm

PopTudor / Java-fcm

Licence: MIT license
Java wrapper library to send messages to Android clients through Firebase Cloud Messaging

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Java-fcm

ChatApp
Chat app based on Firebase tools.
Stars: ✭ 88 (+203.45%)
Mutual labels:  fcm, cloud-messaging
andpush
Android Push Notification in Ruby: The fastest client for FCM (Firebase Cloud Messaging)
Stars: ✭ 83 (+186.21%)
Mutual labels:  fcm, firebase-cloud-messaging
Electron Push Receiver
A module to bring Web Push support to Electron allowing it to receive notifications from Firebase Cloud Messaging (FCM).
Stars: ✭ 158 (+444.83%)
Mutual labels:  fcm, firebase-cloud-messaging
fcmxmppserverv2
XMPP Connection Server for FCM using the latest version of the Smack library (4.3.4) + Connection Draining Implementation
Stars: ✭ 43 (+48.28%)
Mutual labels:  fcm, firebase-cloud-messaging
FCM-OnDeviceNotificationScheduler
Demo implementation to Schedule FCM Notifications on Android Device using AlarmManager + WorkManager.
Stars: ✭ 111 (+282.76%)
Mutual labels:  fcm, firebase-cloud-messaging
Push Receiver
A library to subscribe to GCM/FCM and receive notifications within a node process.
Stars: ✭ 125 (+331.03%)
Mutual labels:  fcm, firebase-cloud-messaging
Qiscus Sdk Android
Qiscus provide everything you need to power up your app with chats. And it's now made simple.
Stars: ✭ 175 (+503.45%)
Mutual labels:  fcm, firebase-cloud-messaging
Applozic Android Sdk
Android Real Time Chat & Messaging SDK
Stars: ✭ 611 (+2006.9%)
Mutual labels:  fcm, firebase-cloud-messaging
fcm
Golang client library for Firebase Cloud Messaging.
Stars: ✭ 22 (-24.14%)
Mutual labels:  fcm, firebase-cloud-messaging
Fcm Toolbox
📲 Firebase Cloud Messaging toolbox
Stars: ✭ 217 (+648.28%)
Mutual labels:  fcm, firebase-cloud-messaging
Pushraven
A simple Java library to interface with Firebase Cloud Messaging (FCM) API. Pushraven allows you to push notifications to clients in very few lines of code.
Stars: ✭ 67 (+131.03%)
Mutual labels:  fcm, firebase-cloud-messaging
fcmpush
Firebase Cloud Messaging API wrapper for Ruby, suppot HTTP v1 API including access_token auto refresh feature.
Stars: ✭ 44 (+51.72%)
Mutual labels:  fcm, firebase-cloud-messaging
Kotlin Firebase Group Chat
Group and OneonOne chat using firebase built in Kotlin similar to whatsapp.
Stars: ✭ 44 (+51.72%)
Mutual labels:  fcm, firebase-cloud-messaging
Rpush
The push notification service for Ruby.
Stars: ✭ 1,886 (+6403.45%)
Mutual labels:  fcm, firebase-cloud-messaging
Pyfcm
Python client for FCM - Firebase Cloud Messaging (Android, iOS and Web)
Stars: ✭ 674 (+2224.14%)
Mutual labels:  fcm, firebase-cloud-messaging
Fcm
Firebase Cloud Messaging (FCM) notifications channel for Laravel
Stars: ✭ 169 (+482.76%)
Mutual labels:  fcm, firebase-cloud-messaging
Fcm
Ruby bindings to Firebase Cloud Messaging (FCM) for Android, iOS or Web
Stars: ✭ 409 (+1310.34%)
Mutual labels:  fcm, firebase-cloud-messaging
Fcm Django
FCM Django: Send push notifications via django to websites, iOS & android mobile devices through FCM (Firebase Cloud Messaging)
Stars: ✭ 495 (+1606.9%)
Mutual labels:  fcm, firebase-cloud-messaging
Go Fcm
Firebase Cloud Messaging ( FCM ) Library using golang ( Go )
Stars: ✭ 212 (+631.03%)
Mutual labels:  fcm, firebase-cloud-messaging
FCMBundle
A Bundle for Symfony projects to send notifications in mobile devices through Firebase Cloud Messaging API
Stars: ✭ 43 (+48.28%)
Mutual labels:  fcm, firebase-cloud-messaging

Java-fcm

The purpose of this library is to provide a easy to use, ready-to-go Firebase Cloud Messaging implementation for your project. I hope people will get interested into this project and I appreciate all the valuable contributions that you guys/girls make!

If you are just getting started with FCM you should start reading the official docs.

This library was inspired by the nodejs version https://github.com/ToothlessGear/node-gcm

Installation

Gradle

Add the following to your build.gradle file

repositories {
    maven {
        url  "http://dl.bintray.com/tudor/Pixsee" 
    }
}
...

then

dependencies {
    compile 'org.pixsee.java-fcm:Java-fcm:1.0.0'
}

Maven

<dependency>
  <groupId>org.pixsee.java-fcm</groupId>
  <artifactId>Java-fcm</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

Requirements

This library provides the easy means for sending messages to Android or iOS clients. Before starting to use it, you require(as per docs) a SERVER_KEY which is available in the Cloud Messaging tab of the Firebase console Settings pane.

Example & Usage

Send a message

import org.pixsee.fcm.Sender;
...
Sender fcm = new Sender("SERVER_KEY");
...
// build the message 
Message message = new Message.MessageBuilder()
    .toToken(toClientToken) // single android/ios device
    .addData("key_1","value_1")
    .build();
// send the message
fcm.send(message);
...
// build complex message
Message message = new Message.MessageBuilder()
    .toToken(to)
    .collapseKey("chat-app")
    .contentAvailable(true)
    .priority(Message.Priority.HIGH) // or just type "normal" or "high"
    .timeToLive(3)
    .restrictedPackageName("your.package.name")
    .addData("key1", "data1")
    .addData("key2", "data2")
    .notification(new Notification("optional_title", "optional_body"))
    .build();
sender.send(message)
...
// build multiple tokens ids
List<String> registrationIds = new ArrayList<>();
registrationIds.add("token1");
registrationIds.add("token2");

Message message = new Message.MessageBuilder()
    .addRegistrationToken(registrationIds) // add array
    .addRegistrationToken(to) // add individual
    .addData("key1", "data1")
    .addData("key2", "data2")
    .notification(someNotification)
    .build();
    
sender.send(message, new Callback() {
    @Override
    public void onResponse(Call call, Response response) {
        if(response.isSuccessful())
          System.out.print("Hooray!");
    }
    @Override
    public void onFailure(Call call, Throwable t) {
        t.printStackTrace();
    }
});

Notification

Notification notification = new Notification("title", "body");
notification.setIcon("icon");
notification.setSound("sound");
notification.setBadge("badge");
notification.setClickAction("click.action");
Message message = messageBuilder.notification(notification).build(); // add notification

Logging request/response

provided by OkHttp interceptors

import okhttp3.logging.HttpLoggingInterceptor;
...
Sender sender = new Sender("server_key");
sender.setLoggingLevel(HttpLoggingInterceptor.Level.BODY);
sender.setLoggingLevel(HttpLoggingInterceptor.Level.BASIC);
sender.setLoggingLevel(HttpLoggingInterceptor.Level.NONE);
sender.setLoggingLevel(HttpLoggingInterceptor.Level.HEADERS);

Recipients

You can send a message to different types of targets. All the methods apply to a MessageBuilder object

Key Type Description Method
to String A single [registration token] or [topic]. toToken
topic String A single publish/subscribe [topic]. toTopic
condition String Multiple topics using a [condition]. toCondition
registration_ids String[] List of registration tokens/ids. Support up to 1000 addRegistrationToken

If you don't provide any of the above, you get a bad request inside onResponse callback

Support

Bitcoin Ether Ether
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].