Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format android getScheduledLocalNotifications return object to match …
…iOS return object
  • Loading branch information
lukebars committed Jun 8, 2020
commit a74d91984635a7c503136eb58a9f8a6549cca16b
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import androidx.core.app.NotificationCompat;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableArray;
Expand All @@ -37,6 +36,7 @@
import org.json.JSONArray;
import org.json.JSONException;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
Expand Down Expand Up @@ -731,10 +731,27 @@ public WritableArray getScheduledLocalNotifications() {
WritableArray scheduled = Arguments.createArray();

Map<String, ?> scheduledNotifications = scheduledNotificationsPersistence.getAll();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ");

for (Map.Entry<String, ?> entry : scheduledNotifications.entrySet()) {
try {
RNPushNotificationAttributes notification = fromJson(entry.getValue().toString());
WritableMap notificationMap = Arguments.makeNativeMap(notification.toBundle());
WritableMap notificationMap = Arguments.createMap();

long fireDateTimestamp = (long) notification.getFireDate();
Date date = new java.util.Date(fireDateTimestamp);
String fireDate = formatter.format(date);

notificationMap.putString("alertTitle", notification.getTitle());
notificationMap.putString("alertBody", notification.getMessage());
notificationMap.putString("alertAction", notification.getActions());
notificationMap.putString("applicationIconBadgeNumber", notification.getNumber());
notificationMap.putString("fireDate", fireDate);
notificationMap.putString("id", notification.getId());
notificationMap.putBoolean("remote", false);
notificationMap.putString("repeatInterval", notification.getRepeatType());
notificationMap.putString("soundName", notification.getSound());


scheduled.pushMap(notificationMap);
} catch (JSONException e) {
Expand All @@ -743,7 +760,6 @@ public WritableArray getScheduledLocalNotifications() {
}

return scheduled;

}

public void cancelAllScheduledNotifications() {
Expand Down