[ISSUE #2287] Push Notifications: Use status-go NotifyUsers

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Pedro Pombeiro 2018-01-04 11:50:14 +01:00 committed by Andrey Shovkoplyas
parent fad47500bb
commit a4bc752e77
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
8 changed files with 26 additions and 20 deletions

View File

@ -404,8 +404,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
}
@ReactMethod
public void notify(final String token, final Callback callback) {
Log.d(TAG, "notify");
public void notifyUsers(final String message, final String payloadJSON, final String tokensJSON, final Callback callback) {
Log.d(TAG, "notifyUsers");
if (!checkAvailability()) {
callback.invoke(false);
return;
@ -414,7 +414,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
Thread thread = new Thread() {
@Override
public void run() {
String res = Statusgo.Notify(token);
String res = Statusgo.NotifyUsers(message, payloadJSON, tokensJSON);
callback.invoke(res);
}

View File

@ -276,14 +276,16 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password
}
////////////////////////////////////////////////////////////////////
#pragma mark - Notify method
//////////////////////////////////////////////////////////////////// notify
RCT_EXPORT_METHOD(notify:(NSString *)token
#pragma mark - NotifyUsers method
//////////////////////////////////////////////////////////////////// notifyUsers
RCT_EXPORT_METHOD(notifyUsers:(NSString *)message
payloadJSON:(NSString *)payloadJSON
tokensJSON:(NSString *)tokensJSON
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]]);
#if DEBUG
NSLog(@"Notify() method called");
NSLog(@"NotifyUsers() method called");
#endif
}

View File

@ -10,9 +10,11 @@
(re-frame/reg-fx
:send-notification
(fn [fcm-token]
(log/debug "send-notification fcm-token: " fcm-token)
(status/notify fcm-token #(log/debug "send-notification cb result: " %))))
(fn [{:keys [message payload tokens]}]
(let [payload-json (types/clj->json payload)
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
:send-group-message

View File

@ -186,7 +186,9 @@
:else
(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]
(let [{:keys [chat-id identity message-text]} params

View File

@ -84,8 +84,8 @@
(defn should-move-to-internal-storage? [callback]
(module-interface/-should-move-to-internal-storage? rns-module callback))
(defn notify [token callback]
(module-interface/-notify rns-module token callback))
(defn notify-users [{:keys [message payload tokens] :as m} callback]
(module-interface/-notify-users rns-module m callback))
(defn add-peer [enode callback]
(module-interface/-add-peer rns-module enode callback))

View File

@ -103,9 +103,9 @@
true)
false))))))
(defn notify [token on-result]
(defn notify-users [{:keys [message payload tokens] :as m} on-result]
(when status
(call-module #(.notify status token on-result))))
(call-module #(.notifyUsers status message payload tokens on-result))))
(defn add-peer [enode on-result]
(when status
@ -259,8 +259,8 @@
(call-function! params))
(-call-web3 [this payload callback]
(call-web3 payload callback))
(-notify [this token callback]
(notify token callback))
(-notify-users [this {:keys [message payload tokens] :as m} callback]
(notify-users m callback))
(-add-peer [this enode callback]
(add-peer enode callback))

View File

@ -58,6 +58,6 @@
(impl/module-initialized!))
(-should-move-to-internal-storage? [this 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])
(-close-application [this]))

View File

@ -18,7 +18,7 @@
(-call-web3 [this payload callback])
(-module-initialized! [this])
(-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])
(-close-application [this]))