Java Code Examples for com.google.firebase.messaging.FirebaseMessaging#getInstance()
The following examples show how to use
com.google.firebase.messaging.FirebaseMessaging#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelayService.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
String sendAndroidMessage(String apsTokenHex, String encryptedMessage, boolean useSound) { Message.Builder messageBuilder = Message.builder(); Notification notification = new Notification("Bisq", "Notification"); messageBuilder.setNotification(notification); messageBuilder.putData("encrypted", encryptedMessage); messageBuilder.setToken(apsTokenHex); if (useSound) messageBuilder.putData("sound", "default"); Message message = messageBuilder.build(); try { FirebaseMessaging firebaseMessaging = FirebaseMessaging.getInstance(); firebaseMessaging.send(message); return SUCCESS; } catch (FirebaseMessagingException e) { log.error(e.toString()); e.printStackTrace(); return "Error: " + e.toString(); } }
Example 2
Source File: FirebaseMessagingService.java From zhcet-web with Apache License 2.0 | 5 votes |
@Autowired public FirebaseMessagingService(FirebaseService firebaseService, MessagingTokenDetachService messagingTokenDetachService) { this.firebaseService = firebaseService; this.messagingTokenDetachService = messagingTokenDetachService; boolean canSendMessage = firebaseService.canProceed(); String color = canSendMessage ? ConsoleColors.GREEN : ConsoleColors.RED; log.info(ConsoleHelper.color(color, "CONFIG (Firebase): Firebase Messaging Running : {}"), canSendMessage); if (canSendMessage) { firebaseMessaging = FirebaseMessaging.getInstance(); } else { firebaseMessaging = null; } }
Example 3
Source File: MainActivity.java From snippets-android with Apache License 2.0 | 5 votes |
public void sendUpstream() { final String SENDER_ID = "YOUR_SENDER_ID"; final int messageId = 0; // Increment for each // [START fcm_send_upstream] FirebaseMessaging fm = FirebaseMessaging.getInstance(); fm.send(new RemoteMessage.Builder(SENDER_ID + "@fcm.googleapis.com") .setMessageId(Integer.toString(messageId)) .addData("my_message", "Hello World") .addData("my_action","SAY_HELLO") .build()); // [END fcm_send_upstream] }
Example 4
Source File: FIRMessagingModule.java From react-native-fcm with MIT License | 5 votes |
@ReactMethod public void send(String senderId, ReadableMap payload) throws Exception { FirebaseMessaging fm = FirebaseMessaging.getInstance(); RemoteMessage.Builder message = new RemoteMessage.Builder(senderId + "@gcm.googleapis.com") .setMessageId(UUID.randomUUID().toString()); ReadableMapKeySetIterator iterator = payload.keySetIterator(); while (iterator.hasNextKey()) { String key = iterator.nextKey(); String value = getStringFromReadableMap(payload, key); message.addData(key, value); } fm.send(message.build()); }
Example 5
Source File: GcmActivity.java From xDrip with GNU General Public License v3.0 | 5 votes |
private static void fmSend(Bundle data) { final FirebaseMessaging fm = FirebaseMessaging.getInstance(); if (senderid != null) { fm.send(new RemoteMessage.Builder(senderid + "@gcm.googleapis.com") .setMessageId(Integer.toString(msgId.incrementAndGet())) .setData(JoH.bundleToMap(data)) .build()); } else { Log.wtf(TAG, "senderid is null"); } }
Example 6
Source File: GcmActivity.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
private static void fmSend(Bundle data) { final FirebaseMessaging fm = FirebaseMessaging.getInstance(); if (senderid != null) { fm.send(new RemoteMessage.Builder(senderid + "@gcm.googleapis.com") .setMessageId(Integer.toString(msgId.incrementAndGet())) .setData(JoH.bundleToMap(data)) .build()); } else { Log.wtf(TAG, "senderid is null"); } }
Example 7
Source File: FirestackCloudMessaging.java From react-native-firestack with MIT License | 5 votes |
@ReactMethod public void send(String senderId, String messageId, String messageType, ReadableMap params, final Callback callback) { FirebaseMessaging fm = FirebaseMessaging.getInstance(); RemoteMessage.Builder remoteMessage = new RemoteMessage.Builder(senderId); remoteMessage.setMessageId(messageId); remoteMessage.setMessageType(messageType); ReadableMapKeySetIterator iterator = params.keySetIterator(); while (iterator.hasNextKey()) { String key = iterator.nextKey(); ReadableType type = params.getType(key); if (type == ReadableType.String) { remoteMessage.addData(key, params.getString(key)); Log.d(TAG, "Firebase send: " + key); Log.d(TAG, "Firebase send: " + params.getString(key)); } } try { fm.send(remoteMessage.build()); WritableMap res = Arguments.createMap(); res.putString("status", "success"); callback.invoke(null, res); } catch(Exception e) { Log.e(TAG, "Error sending message", e); WritableMap error = Arguments.createMap(); error.putString("code", e.toString()); error.putString("message", e.toString()); callback.invoke(error); } }
Example 8
Source File: AeroGearFCMPushRegistrar.java From aerogear-android-push with Apache License 2.0 | 4 votes |
@Override public FirebaseMessaging get(Object... context) { return FirebaseMessaging.getInstance(); }