Skip to content

Commit

Permalink
New version 1.0.7 - add ttl and priority to the fcm message
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtAcht committed May 4, 2022
1 parent f888e08 commit c609954
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -4,7 +4,7 @@ Clojure wrap for Firebase Cloud Messaging that allows You to send push notificat
### Installation
Leiningen coordinates:
```clj
[clj-push-notifications "1.0.6"]
[clj-push-notifications "1.0.7"]
```
### Example of usage:
First get Your credentials (google-services.json file) from Firebase console, and add them to Your project path (or some config file):
Expand Down
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject clj-push-notifications "1.0.6"
(defproject clj-push-notifications "1.0.7"
:description "Firebase cloud messaging client."
:url "https://github.com/spinneyio/clj-push-notifications"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down
10 changes: 7 additions & 3 deletions src/clj_push_notifications/core.clj
@@ -1,12 +1,11 @@
(ns clj-push-notifications.core
(:import
java.io.FileInputStream
java.io.ByteArrayInputStream
(com.google.firebase FirebaseOptions FirebaseOptions$Builder FirebaseApp)
com.google.auth.oauth2.GoogleCredentials
(com.google.firebase.messaging FirebaseMessaging Message MulticastMessage
Notification AndroidConfig AndroidNotification
ApnsConfig Aps)))
AndroidConfig$Priority ApnsConfig Aps)))

(defn- string-to-stream [string]
(-> string
Expand Down Expand Up @@ -70,7 +69,12 @@
message))

(defn- get-message [builder data]
(reduce (fn [builder [k v]] (.putData builder k v)) builder data))
(let [android-config (doto (AndroidConfig/builder)
(.setTtl 0)
(.setPriority AndroidConfig$Priority/HIGH))
builded-android-config (.build android-config)
builder-with-android-config (.setAndroidConfig builder builded-android-config)]
(.putAllData builder-with-android-config data)))

(defn send-notification [{:keys [token title message badges custom-field custom-data type]}]
(let [custom-field (or custom-field "")
Expand Down

0 comments on commit c609954

Please sign in to comment.