mirror of
https://github.com/status-im/status-react.git
synced 2025-01-23 01:09:49 +00:00
[ISSUE #2287] Push Notifications: Use status-go NotifyUsers
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
fad47500bb
commit
a4bc752e77
@ -404,8 +404,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void notify(final String token, final Callback callback) {
|
public void notifyUsers(final String message, final String payloadJSON, final String tokensJSON, final Callback callback) {
|
||||||
Log.d(TAG, "notify");
|
Log.d(TAG, "notifyUsers");
|
||||||
if (!checkAvailability()) {
|
if (!checkAvailability()) {
|
||||||
callback.invoke(false);
|
callback.invoke(false);
|
||||||
return;
|
return;
|
||||||
@ -414,7 +414,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
Thread thread = new Thread() {
|
Thread thread = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String res = Statusgo.Notify(token);
|
String res = Statusgo.NotifyUsers(message, payloadJSON, tokensJSON);
|
||||||
|
|
||||||
callback.invoke(res);
|
callback.invoke(res);
|
||||||
}
|
}
|
||||||
|
@ -276,14 +276,16 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
#pragma mark - Notify method
|
#pragma mark - NotifyUsers method
|
||||||
//////////////////////////////////////////////////////////////////// notify
|
//////////////////////////////////////////////////////////////////// notifyUsers
|
||||||
RCT_EXPORT_METHOD(notify:(NSString *)token
|
RCT_EXPORT_METHOD(notifyUsers:(NSString *)message
|
||||||
|
payloadJSON:(NSString *)payloadJSON
|
||||||
|
tokensJSON:(NSString *)tokensJSON
|
||||||
callback:(RCTResponseSenderBlock)callback) {
|
callback:(RCTResponseSenderBlock)callback) {
|
||||||
char * result = Notify((char *) [token UTF8String]);
|
char * result = NotifyUsers((char *) [message UTF8String], (char *) [payloadJSON UTF8String], (char *) [tokensJSON UTF8String]);
|
||||||
callback(@[[NSString stringWithUTF8String: result]]);
|
callback(@[[NSString stringWithUTF8String: result]]);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
NSLog(@"Notify() method called");
|
NSLog(@"NotifyUsers() method called");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,11 @@
|
|||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:send-notification
|
:send-notification
|
||||||
(fn [fcm-token]
|
(fn [{:keys [message payload tokens]}]
|
||||||
(log/debug "send-notification fcm-token: " fcm-token)
|
(let [payload-json (types/clj->json payload)
|
||||||
(status/notify fcm-token #(log/debug "send-notification cb result: " %))))
|
tokens-json (types/clj->json tokens)]
|
||||||
|
(log/debug "send-notification message: " message " payload-json: " payload-json " tokens-json: " tokens-json)
|
||||||
|
(status/notify-users {:message message :payload payload-json :tokens tokens-json} #(log/debug "send-notification cb result: " %)))))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:send-group-message
|
:send-group-message
|
||||||
|
@ -186,7 +186,9 @@
|
|||||||
|
|
||||||
:else
|
:else
|
||||||
(merge {:send-message (assoc-in options [:message :to] chat-id)}
|
(merge {:send-message (assoc-in options [:message :to] chat-id)}
|
||||||
(when-not command) {:send-notification fcm-token}))))))
|
(when fcm-token {:send-notification {:message "message"
|
||||||
|
:payload {:title "Status" :body "You have a new message"}
|
||||||
|
:tokens [fcm-token]}})))))))
|
||||||
|
|
||||||
(defn- prepare-message [params chat]
|
(defn- prepare-message [params chat]
|
||||||
(let [{:keys [chat-id identity message-text]} params
|
(let [{:keys [chat-id identity message-text]} params
|
||||||
|
@ -84,8 +84,8 @@
|
|||||||
(defn should-move-to-internal-storage? [callback]
|
(defn should-move-to-internal-storage? [callback]
|
||||||
(module-interface/-should-move-to-internal-storage? rns-module callback))
|
(module-interface/-should-move-to-internal-storage? rns-module callback))
|
||||||
|
|
||||||
(defn notify [token callback]
|
(defn notify-users [{:keys [message payload tokens] :as m} callback]
|
||||||
(module-interface/-notify rns-module token callback))
|
(module-interface/-notify-users rns-module m callback))
|
||||||
|
|
||||||
(defn add-peer [enode callback]
|
(defn add-peer [enode callback]
|
||||||
(module-interface/-add-peer rns-module enode callback))
|
(module-interface/-add-peer rns-module enode callback))
|
||||||
|
@ -103,9 +103,9 @@
|
|||||||
true)
|
true)
|
||||||
false))))))
|
false))))))
|
||||||
|
|
||||||
(defn notify [token on-result]
|
(defn notify-users [{:keys [message payload tokens] :as m} on-result]
|
||||||
(when status
|
(when status
|
||||||
(call-module #(.notify status token on-result))))
|
(call-module #(.notifyUsers status message payload tokens on-result))))
|
||||||
|
|
||||||
(defn add-peer [enode on-result]
|
(defn add-peer [enode on-result]
|
||||||
(when status
|
(when status
|
||||||
@ -259,8 +259,8 @@
|
|||||||
(call-function! params))
|
(call-function! params))
|
||||||
(-call-web3 [this payload callback]
|
(-call-web3 [this payload callback]
|
||||||
(call-web3 payload callback))
|
(call-web3 payload callback))
|
||||||
(-notify [this token callback]
|
(-notify-users [this {:keys [message payload tokens] :as m} callback]
|
||||||
(notify token callback))
|
(notify-users m callback))
|
||||||
(-add-peer [this enode callback]
|
(-add-peer [this enode callback]
|
||||||
(add-peer enode callback))
|
(add-peer enode callback))
|
||||||
|
|
||||||
|
@ -58,6 +58,6 @@
|
|||||||
(impl/module-initialized!))
|
(impl/module-initialized!))
|
||||||
(-should-move-to-internal-storage? [this callback]
|
(-should-move-to-internal-storage? [this callback]
|
||||||
(impl/should-move-to-internal-storage? callback))
|
(impl/should-move-to-internal-storage? callback))
|
||||||
(-notify [this token callback])
|
(-notify-users [this {:keys [message payload tokens] :as m} callback])
|
||||||
(-add-peer [this enode callback])
|
(-add-peer [this enode callback])
|
||||||
(-close-application [this]))
|
(-close-application [this]))
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
(-call-web3 [this payload callback])
|
(-call-web3 [this payload callback])
|
||||||
(-module-initialized! [this])
|
(-module-initialized! [this])
|
||||||
(-should-move-to-internal-storage? [this callback])
|
(-should-move-to-internal-storage? [this callback])
|
||||||
(-notify [this token callback])
|
(-notify-users [this {:keys [message payload tokens] :as m} callback])
|
||||||
(-add-peer [this enode callback])
|
(-add-peer [this enode callback])
|
||||||
(-close-application [this]))
|
(-close-application [this]))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user