Last active
December 17, 2020 17:53
-
-
Save alinz/8ecc33066a8975f8e1d65740814a76f4 to your computer and use it in GitHub Desktop.
A react-native-notifications patch for getting scheduled local notification working in Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java | |
index f9c858b..94ea188 100644 | |
--- a/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java | |
+++ b/node_modules/react-native-notifications/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java | |
@@ -2,8 +2,8 @@ | |
package com.wix.reactnativenotifications; | |
import android.content.Context; | |
-import android.support.annotation.NonNull; | |
-import android.support.v4.app.NotificationManagerCompat; | |
+import androidx.annotation.NonNull; | |
+import androidx.core.app.NotificationManagerCompat; | |
public abstract class NotificationManagerCompatFacade { | |
public static NotificationManagerCompat from(@NonNull Context context) { | |
diff --git a/node_modules/react-native-notifications/lib/android/app/.gitignore b/node_modules/react-native-notifications/lib/android/app/.gitignore | |
new file mode 100644 | |
index 0000000..65d12b9 | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/android/app/.gitignore | |
@@ -0,0 +1,2 @@ | |
+/build | |
+google-services.json | |
\ No newline at end of file | |
diff --git a/node_modules/react-native-notifications/lib/android/app/build.gradle b/node_modules/react-native-notifications/lib/android/app/build.gradle | |
index dacd22f..cab2b7f 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/build.gradle | |
+++ b/node_modules/react-native-notifications/lib/android/app/build.gradle | |
@@ -1,25 +1,6 @@ | |
import groovy.json.JsonSlurper | |
apply plugin: 'com.android.library' | |
-apply plugin: 'kotlin-android' | |
-apply plugin: 'kotlin-android-extensions' | |
- | |
-def safeExtGet(prop, fallback) { | |
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | |
-} | |
- | |
-def DEFAULT_COMPILE_SDK_VERSION = 29 | |
-def DEFAULT_MIN_SDK_VERSION = 21 | |
-def DEFAULT_KOTLIN_VERSION = "1.3.61" | |
-def DEFAULT_KOTLIN_STDLIB_VERSION = "kotlin-stdlib-jdk8" | |
-def DEFAULT_FIREBASE_MESSAGING_VERSION = "20.2.0" | |
- | |
-def androidSdkVersion = safeExtGet('androidSdkVersion', DEFAULT_COMPILE_SDK_VERSION) | |
-def androidMinSdkVersion = safeExtGet('androidMinSdkVersion', DEFAULT_MIN_SDK_VERSION) | |
-def androidTargetSdkVersion = safeExtGet('targetSdkVersion', DEFAULT_COMPILE_SDK_VERSION) | |
-def kotlinVersion = safeExtGet('kotlinVersion', DEFAULT_KOTLIN_VERSION) | |
-def kotlinStdlib = safeExtGet('kotlinStdlib', DEFAULT_KOTLIN_STDLIB_VERSION) | |
-def firebaseVersion = safeExtGet('firebaseVersion', DEFAULT_FIREBASE_MESSAGING_VERSION) | |
Object findReactNativePackageJson() { | |
def searchPath = 'node_modules/react-native/package.json' | |
@@ -47,26 +28,17 @@ String resolveFlavor() { | |
} | |
} | |
- | |
android { | |
- compileSdkVersion androidSdkVersion | |
+ compileSdkVersion 28 | |
+ buildToolsVersion '28.0.3' | |
+ | |
defaultConfig { | |
- minSdkVersion androidMinSdkVersion | |
- targetSdkVersion androidTargetSdkVersion | |
+ minSdkVersion 16 | |
+ targetSdkVersion 27 | |
versionCode 1 | |
versionName "1.0" | |
- ndk { | |
- abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' | |
- } | |
- } | |
- compileOptions { | |
- sourceCompatibility JavaVersion.VERSION_1_8 | |
- targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
- dexOptions { | |
- javaMaxHeapSize "4g" | |
- } | |
buildTypes { | |
release { | |
minifyEnabled false | |
@@ -77,25 +49,6 @@ android { | |
} | |
} | |
- | |
- flavorDimensions "RNNotifications.reactNativeVersion" | |
- productFlavors { | |
- reactNative59 { | |
- dimension "RNNotifications.reactNativeVersion" | |
- } | |
- reactNative60 { | |
- dimension "RNNotifications.reactNativeVersion" | |
- } | |
- } | |
- | |
- def flavor = resolveFlavor() | |
- variantFilter { variant -> | |
- def names = variant.flavors*.name | |
- if (!names.contains(flavor)) { | |
- setIgnore(true) | |
- } | |
- } | |
- | |
testOptions { | |
unitTests.all { t -> | |
reports { | |
@@ -119,17 +72,34 @@ android { | |
includeAndroidResources = true | |
} | |
} | |
+ | |
+ flavorDimensions "RNNotifications.reactNativeVersion" | |
+ productFlavors { | |
+ reactNative59 { | |
+ dimension "RNNotifications.reactNativeVersion" | |
+ } | |
+ reactNative60 { | |
+ dimension "RNNotifications.reactNativeVersion" | |
+ } | |
+ } | |
+ | |
+ def flavor = resolveFlavor() | |
+ variantFilter { variant -> | |
+ def names = variant.flavors*.name | |
+ if (!names.contains(flavor)) { | |
+ setIgnore(true) | |
+ } | |
+ } | |
} | |
dependencies { | |
- implementation "org.jetbrains.kotlin:$kotlinStdlib:$kotlinVersion" | |
- implementation "com.google.firebase:firebase-messaging:$firebaseVersion" | |
+ implementation "com.google.firebase:firebase-messaging:17.3.0" | |
implementation 'com.facebook.react:react-native:+' | |
// tests | |
testImplementation 'junit:junit:4.12' | |
- testImplementation "org.robolectric:robolectric:4.3" | |
- testImplementation "org.assertj:assertj-core:3.8.0" | |
- testImplementation "com.squareup.assertj:assertj-android:1.1.1" | |
- testImplementation "org.mockito:mockito-core:2.28.2" | |
+ testImplementation 'org.robolectric:robolectric:4.3' | |
+ testImplementation 'org.assertj:assertj-core:3.8.0' | |
+ testImplementation 'com.squareup.assertj:assertj-android:1.1.1' | |
+ testImplementation 'org.mockito:mockito-core:2.25.1' | |
} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml b/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml | |
index abd988a..87963e8 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml | |
@@ -20,8 +20,13 @@ | |
<service | |
android:name=".fcm.FcmInstanceIdRefreshHandlerService" | |
- android:exported="false" | |
- android:permission="android.permission.BIND_JOB_SERVICE" /> | |
+ android:exported="false" /> | |
+ | |
+ <receiver android:name=".core.notification.ScheduledNotification" > | |
+ <intent-filter> | |
+ <action android:name="PushLocalNotification" /> | |
+ </intent-filter> | |
+ </receiver> | |
</application> | |
</manifest> | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java | |
index db9eaba..72b02b8 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java | |
@@ -7,6 +7,7 @@ import android.content.Intent; | |
import android.os.Bundle; | |
import android.util.Log; | |
+import com.facebook.react.BuildConfig; | |
import com.facebook.react.bridge.ActivityEventListener; | |
import com.facebook.react.bridge.Arguments; | |
import com.facebook.react.bridge.Promise; | |
@@ -24,6 +25,7 @@ import com.wix.reactnativenotifications.core.notification.IPushNotification; | |
import com.wix.reactnativenotifications.core.notification.NotificationChannel; | |
import com.wix.reactnativenotifications.core.notification.PushNotification; | |
import com.wix.reactnativenotifications.core.notification.PushNotificationProps; | |
+import com.wix.reactnativenotifications.core.notification.ScheduledNotification; | |
import com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer; | |
import com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer; | |
import com.wix.reactnativenotifications.fcm.FcmInstanceIdRefreshHandlerService; | |
@@ -32,6 +34,8 @@ import static com.wix.reactnativenotifications.Defs.LOGTAG; | |
public class RNNotificationsModule extends ReactContextBaseJavaModule implements ActivityEventListener { | |
+ | |
+ | |
public RNNotificationsModule(Application application, ReactApplicationContext reactContext) { | |
super(reactContext); | |
if (AppLifecycleFacadeHolder.get() instanceof ReactAppLifecycleFacade) { | |
@@ -39,6 +43,8 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements | |
} | |
reactContext.addActivityEventListener(this); | |
+ | |
+ | |
} | |
@Override | |
@@ -99,16 +105,28 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements | |
public void postLocalNotification(ReadableMap notificationPropsMap, int notificationId) { | |
if(BuildConfig.DEBUG) Log.d(LOGTAG, "Native method invocation: postLocalNotification"); | |
final Bundle notificationProps = Arguments.toBundle(notificationPropsMap); | |
- final IPushNotification pushNotification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationProps); | |
- pushNotification.onPostRequest(notificationId); | |
+ long firedate= (long) notificationProps.getDouble("fireDate"); | |
+ String channelID=notificationProps.getString("channelID"); | |
+ if( firedate!=0){ | |
+ ScheduledNotification scheduledNotification=new ScheduledNotification(); | |
+ scheduledNotification.scheduleNotification(getReactApplicationContext().getApplicationContext(),notificationProps,firedate,notificationId); | |
+ }else { | |
+ final IPushNotification pushNotification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationProps); | |
+ pushNotification.onPostRequest(notificationId,channelID); | |
+ } | |
} | |
@ReactMethod | |
public void cancelLocalNotification(int notificationId) { | |
- IPushNotificationsDrawer notificationsDrawer = PushNotificationsDrawer.get(getReactApplicationContext().getApplicationContext()); | |
- notificationsDrawer.onNotificationClearRequest(notificationId); | |
+ ScheduledNotification scheduledNotification=new ScheduledNotification(); | |
+ scheduledNotification.cancelScheduledNotification(getReactApplicationContext().getApplicationContext(),notificationId); | |
} | |
+ @ReactMethod | |
+ public void cancelAllLocalNotifications() { | |
+ ScheduledNotification scheduledNotification=new ScheduledNotification(); | |
+ scheduledNotification.cancelAllScheduledNotifications(getReactApplicationContext().getApplicationContext()); | |
+ } | |
@ReactMethod | |
public void setCategories(ReadableArray categories) { | |
@@ -144,6 +162,6 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements | |
final Context appContext = getReactApplicationContext().getApplicationContext(); | |
final Intent tokenFetchIntent = new Intent(appContext, FcmInstanceIdRefreshHandlerService.class); | |
tokenFetchIntent.putExtra(extraFlag, true); | |
- FcmInstanceIdRefreshHandlerService.enqueueWork(appContext, tokenFetchIntent); | |
+ appContext.startService(tokenFetchIntent); | |
} | |
} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java | |
index 4c8a581..5a75a8b 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java | |
@@ -22,9 +22,7 @@ public class NotificationIntentAdapter { | |
public static boolean canHandleIntent(Intent intent) { | |
if (intent != null) { | |
Bundle notificationData = intent.getExtras(); | |
- if (notificationData != null && | |
- (intent.hasExtra(PUSH_NOTIFICATION_EXTRA_NAME) || | |
- notificationData.getString("google.message_id", null) != null)) { | |
+ if (notificationData != null && intent.hasExtra(PUSH_NOTIFICATION_EXTRA_NAME)) { | |
return true; | |
} | |
} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java | |
index 0d70024..e34c774 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java | |
@@ -22,9 +22,10 @@ public interface IPushNotification { | |
* Handle a request to post this notification. | |
* | |
* @param notificationId (optional) The specific ID to associated with the notification. | |
+ * @param channelID (optional) The specific channel ID to associated with the notification. | |
* @return The ID effectively assigned to the notification (Auto-assigned if not specified as a parameter). | |
*/ | |
- int onPostRequest(Integer notificationId); | |
+ int onPostRequest(Integer notificationId,String channelID); | |
PushNotificationProps asProps(); | |
} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/NotificationChannel.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/NotificationChannel.java | |
index f026280..74732b7 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/NotificationChannel.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/NotificationChannel.java | |
@@ -17,6 +17,7 @@ public class NotificationChannel implements INotificationChannel { | |
protected NotificationChannel(Context context, Bundle bundle) { | |
mContext = context; | |
+ | |
mNotificationChannelProps = createProps(bundle); | |
} | |
@@ -30,6 +31,7 @@ public class NotificationChannel implements INotificationChannel { | |
@Override | |
public void setNotificationChannel() { | |
+ | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { | |
return; | |
} | |
@@ -68,6 +70,7 @@ public class NotificationChannel implements INotificationChannel { | |
final NotificationManager notificationManager = (NotificationManager) mContext | |
.getSystemService(Context.NOTIFICATION_SERVICE); | |
+ notificationManager.deleteNotificationChannel(mNotificationChannelProps.getChannelId()); | |
notificationManager.createNotificationChannel(channel); | |
} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java | |
index 507dd42..0da557e 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java | |
@@ -60,7 +60,7 @@ public class PushNotification implements IPushNotification { | |
@Override | |
public void onReceived() throws InvalidNotificationException { | |
if (!mAppLifecycleFacade.isAppVisible()) { | |
- postNotification(null); | |
+ postNotification((Notification) null,null); | |
} | |
notifyReceivedToJS(); | |
} | |
@@ -68,11 +68,12 @@ public class PushNotification implements IPushNotification { | |
@Override | |
public void onOpened() { | |
digestNotification(); | |
+ clearAllNotifications(); | |
} | |
@Override | |
- public int onPostRequest(Integer notificationId) { | |
- return postNotification(notificationId); | |
+ public int onPostRequest(Integer notificationId,String channelID) { | |
+ return postNotification(notificationId,channelID); | |
} | |
@Override | |
@@ -80,9 +81,9 @@ public class PushNotification implements IPushNotification { | |
return mNotificationProps.copy(); | |
} | |
- protected int postNotification(Integer notificationId) { | |
+ protected int postNotification(Integer notificationId,String channelID) { | |
final PendingIntent pendingIntent = getCTAPendingIntent(); | |
- final Notification notification = buildNotification(pendingIntent); | |
+ final Notification notification = buildNotification(pendingIntent,channelID); | |
return postNotification(notification, notificationId); | |
} | |
@@ -92,7 +93,6 @@ public class PushNotification implements IPushNotification { | |
launchOrResumeApp(); | |
return; | |
} | |
- | |
final ReactContext reactContext = mAppLifecycleFacade.getRunningReactContext(); | |
if (reactContext.getCurrentActivity() == null) { | |
setAsInitialNotification(); | |
@@ -100,8 +100,6 @@ public class PushNotification implements IPushNotification { | |
if (mAppLifecycleFacade.isAppVisible()) { | |
dispatchImmediately(); | |
- } else if (mAppLifecycleFacade.isAppDestroyed()) { | |
- launchOrResumeApp(); | |
} else { | |
dispatchUponVisibility(); | |
} | |
@@ -136,11 +134,11 @@ public class PushNotification implements IPushNotification { | |
return NotificationIntentAdapter.createPendingNotificationIntent(mContext, cta, mNotificationProps); | |
} | |
- protected Notification buildNotification(PendingIntent intent) { | |
- return getNotificationBuilder(intent).build(); | |
+ protected Notification buildNotification(PendingIntent intent,String channelID) { | |
+ return getNotificationBuilder(intent,channelID).build(); | |
} | |
- protected Notification.Builder getNotificationBuilder(PendingIntent intent) { | |
+ protected Notification.Builder getNotificationBuilder(PendingIntent intent,String channelID) { | |
String CHANNEL_ID = "channel_01"; | |
String CHANNEL_NAME = "Channel Name"; | |
@@ -155,17 +153,23 @@ public class PushNotification implements IPushNotification { | |
setUpIcon(notification); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
- NotificationChannel channel = new NotificationChannel(CHANNEL_ID, | |
- CHANNEL_NAME, | |
- NotificationManager.IMPORTANCE_DEFAULT); | |
- final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); | |
- notificationManager.createNotificationChannel(channel); | |
- notification.setChannelId(CHANNEL_ID); | |
- } | |
+ if(channelID==null){ | |
+ NotificationChannel channel = new NotificationChannel(CHANNEL_ID, | |
+ CHANNEL_NAME, | |
+ NotificationManager.IMPORTANCE_DEFAULT); | |
+ final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); | |
+ notificationManager.createNotificationChannel(channel); | |
+ notification.setChannelId(CHANNEL_ID); | |
+ }else{ | |
+ notification.setChannelId(channelID); | |
+ } | |
+ | |
+ } | |
return notification; | |
} | |
+ | |
private void setUpIcon(Notification.Builder notification) { | |
int iconResId = getAppResourceId("notification_icon", "drawable"); | |
if (iconResId != 0) { | |
@@ -196,6 +200,11 @@ public class PushNotification implements IPushNotification { | |
notificationManager.notify(id, notification); | |
} | |
+ protected void clearAllNotifications() { | |
+ final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); | |
+ notificationManager.cancelAll(); | |
+ } | |
+ | |
protected int createNotificationId(Notification notification) { | |
return (int) System.nanoTime(); | |
} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationProps.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationProps.java | |
index a8545c3..a7db031 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationProps.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationProps.java | |
@@ -23,7 +23,7 @@ public class PushNotificationProps { | |
} | |
public boolean isFirebaseBackgroundPayload() { | |
- return mBundle.containsKey("google.message_id"); | |
+ return mBundle.containsKey("google.message_id") && !mBundle.containsKey("title"); | |
} | |
@Override | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/ScheduledNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/ScheduledNotification.java | |
new file mode 100644 | |
index 0000000..8ef8c4b | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/ScheduledNotification.java | |
@@ -0,0 +1,134 @@ | |
+package com.wix.reactnativenotifications.core.notification; | |
+ | |
+import android.app.AlarmManager; | |
+import android.app.PendingIntent; | |
+import android.content.BroadcastReceiver; | |
+import android.content.Context; | |
+import android.content.Intent; | |
+import android.content.SharedPreferences; | |
+import android.os.Build; | |
+import android.os.Bundle; | |
+import android.util.Log; | |
+ | |
+ | |
+import com.wix.reactnativenotifications.core.utils.BundleJSONConverter; | |
+ | |
+import org.json.JSONException; | |
+import org.json.JSONObject; | |
+ | |
+import java.util.ArrayList; | |
+import java.util.Map; | |
+ | |
+ | |
+ | |
+public class ScheduledNotification extends BroadcastReceiver { | |
+ public static String NOTIFICATION = "notification" ; | |
+ public static String NOTIFICATION_ID = "notification-id" ; | |
+ private static final String SCHEDULED_PREFERENCES_KEY = "RNFNotifications"; | |
+ private SharedPreferences preferences; | |
+ private static final String TAG = "ScheduledNotification"; | |
+ private static final String PUSH_LOCAL_NOTIFICATION_ACTION="PushLocalNotification"; | |
+ | |
+ | |
+ | |
+ public void scheduleNotification (Context context,Bundle notificationBundle , long fireDate, int notificationID) { | |
+ Intent notificationIntent = new Intent( context, ScheduledNotification.class ) ; | |
+ notificationIntent.putExtra( NOTIFICATION , notificationBundle) ; | |
+ notificationIntent.putExtra( NOTIFICATION_ID , notificationID) ; | |
+ notificationIntent.setAction(PUSH_LOCAL_NOTIFICATION_ACTION); | |
+ | |
+ PendingIntent pendingIntent = PendingIntent. getBroadcast ( context, notificationID, notificationIntent , PendingIntent. FLAG_UPDATE_CURRENT ) ; | |
+ | |
+ AlarmManager alarmManager =( AlarmManager)context.getSystemService(Context.ALARM_SERVICE); | |
+ assert alarmManager != null; | |
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
+ alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP , fireDate , pendingIntent); | |
+ }else{ | |
+ alarmManager.set(AlarmManager.RTC_WAKEUP , fireDate , pendingIntent); | |
+ } | |
+ | |
+ | |
+ JSONObject json = null; | |
+ try { | |
+ json = BundleJSONConverter.convertToJSON(notificationBundle); | |
+ this.preferences = context.getSharedPreferences(SCHEDULED_PREFERENCES_KEY, Context.MODE_PRIVATE); | |
+ preferences | |
+ .edit() | |
+ .putString(String.valueOf(notificationID), json.toString()) | |
+ .apply(); | |
+ } catch (JSONException e) { | |
+ e.printStackTrace(); | |
+ Log.e(TAG, "Failed to store notification"); | |
+ } | |
+ } | |
+ | |
+ @Override | |
+ public void onReceive(Context context, Intent intent) { | |
+ if(intent.getAction().equals(PUSH_LOCAL_NOTIFICATION_ACTION)){ | |
+ Bundle notificationProps = intent.getBundleExtra(NOTIFICATION); | |
+ int notificationId = intent.getIntExtra( NOTIFICATION_ID , 0 ) ; | |
+ String channelID=notificationProps.getString("channelID"); | |
+ final IPushNotification pushNotification = PushNotification.get(context, notificationProps); | |
+ pushNotification.onPostRequest(notificationId,channelID); | |
+ }else if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){ | |
+ reScheduleAllNotifications(context); | |
+ } | |
+ | |
+ } | |
+ | |
+ public void cancelScheduledNotification(Context context,int notificationID){ | |
+ Intent notificationIntent = new Intent( context, ScheduledNotification.class ) ; | |
+ // notificationIntent.putExtra( NOTIFICATION_ID , notificationID) ; | |
+ notificationIntent.setAction(PUSH_LOCAL_NOTIFICATION_ACTION); | |
+ | |
+ PendingIntent pendingIntent = PendingIntent. getBroadcast ( context, notificationID, notificationIntent , PendingIntent. FLAG_UPDATE_CURRENT ) ; | |
+ | |
+ AlarmManager alarmManager =( AlarmManager)context.getSystemService(Context.ALARM_SERVICE); | |
+ assert alarmManager != null; | |
+ alarmManager.cancel(pendingIntent); | |
+ this.preferences = context.getSharedPreferences(SCHEDULED_PREFERENCES_KEY, Context.MODE_PRIVATE); | |
+ preferences | |
+ .edit() | |
+ .remove(String.valueOf(notificationID)) | |
+ .apply(); | |
+ } | |
+ | |
+ public void cancelAllScheduledNotifications( Context context) { | |
+ try { | |
+ this.preferences = context.getSharedPreferences(SCHEDULED_PREFERENCES_KEY, Context.MODE_PRIVATE); | |
+ Map<String, ?> notifications = preferences.getAll(); | |
+ | |
+ for (String notificationId : notifications.keySet()) { | |
+ cancelScheduledNotification(context,Integer.parseInt(notificationId)); | |
+ } | |
+ preferences | |
+ .edit() | |
+ .clear() | |
+ .apply(); | |
+ } catch (SecurityException e) { | |
+ // TODO: Identify what these situations are | |
+ // In some devices/situations cancelAllLocalNotifications can throw a SecurityException. | |
+ Log.e(TAG, e.getMessage()); | |
+ | |
+ } | |
+ } | |
+ | |
+ void reScheduleAllNotifications(Context context) { | |
+ ArrayList<Bundle> array = new ArrayList<>(); | |
+ | |
+ this.preferences = context.getSharedPreferences(SCHEDULED_PREFERENCES_KEY, Context.MODE_PRIVATE); | |
+ | |
+ Map<String, ?> notifications = preferences.getAll(); | |
+ | |
+ for (String notificationId : notifications.keySet()) { | |
+ try { | |
+ JSONObject json = new JSONObject((String) notifications.get(notificationId)); | |
+ Bundle bundle = BundleJSONConverter.convertToBundle(json); | |
+ scheduleNotification(context,bundle, bundle.getLong("fireDate"),Integer.parseInt(notificationId)); | |
+ } catch (JSONException e) { | |
+ Log.e(TAG, e.getMessage()); | |
+ } | |
+ } | |
+ } | |
+ | |
+} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/utils/BundleJSONConverter.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/utils/BundleJSONConverter.java | |
new file mode 100644 | |
index 0000000..1d5c975 | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/utils/BundleJSONConverter.java | |
@@ -0,0 +1,191 @@ | |
+package com.wix.reactnativenotifications.core.utils; | |
+ | |
+import android.os.Bundle; | |
+import org.json.JSONArray; | |
+import org.json.JSONException; | |
+import org.json.JSONObject; | |
+ | |
+import java.util.*; | |
+ | |
+/** | |
+ * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | |
+ * | |
+ * You are hereby granted a non-exclusive, worldwide, royalty-free license to use, | |
+ * copy, modify, and distribute this software in source code or binary form for use | |
+ * in connection with the web services and APIs provided by Facebook. | |
+ * | |
+ * As with any software that integrates with the Facebook platform, your use of | |
+ * this software is subject to the Facebook Developer Principles and Policies | |
+ * [http://developers.facebook.com/policy/]. This copyright notice shall be | |
+ * included in all copies or substantial portions of the software. | |
+ * | |
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
+ */ | |
+public class BundleJSONConverter { | |
+ private static final Map<Class<?>, Setter> SETTERS = new HashMap<>(); | |
+ | |
+ static { | |
+ SETTERS.put(Boolean.class, new Setter() { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { | |
+ bundle.putBoolean(key, (Boolean) value); | |
+ } | |
+ | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException { | |
+ json.put(key, value); | |
+ } | |
+ }); | |
+ SETTERS.put(Integer.class, new Setter() { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { | |
+ bundle.putInt(key, (Integer) value); | |
+ } | |
+ | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException { | |
+ json.put(key, value); | |
+ } | |
+ }); | |
+ SETTERS.put(Long.class, new Setter() { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { | |
+ bundle.putLong(key, (Long) value); | |
+ } | |
+ | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException { | |
+ json.put(key, value); | |
+ } | |
+ }); | |
+ SETTERS.put(Double.class, new Setter() { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { | |
+ bundle.putDouble(key, (Double) value); | |
+ } | |
+ | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException { | |
+ json.put(key, value); | |
+ } | |
+ }); | |
+ SETTERS.put(String.class, new Setter() { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { | |
+ bundle.putString(key, (String) value); | |
+ } | |
+ | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException { | |
+ json.put(key, value); | |
+ } | |
+ }); | |
+ SETTERS.put(String[].class, new Setter() { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { | |
+ throw new IllegalArgumentException("Unexpected type from JSON"); | |
+ } | |
+ | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException { | |
+ JSONArray jsonArray = new JSONArray(); | |
+ for (String stringValue : (String[])value) { | |
+ jsonArray.put(stringValue); | |
+ } | |
+ json.put(key, jsonArray); | |
+ } | |
+ }); | |
+ | |
+ SETTERS.put(JSONArray.class, new Setter() { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException { | |
+ JSONArray jsonArray = (JSONArray)value; | |
+ ArrayList<String> stringArrayList = new ArrayList<String>(); | |
+ // Empty list, can't even figure out the type, assume an ArrayList<String> | |
+ if (jsonArray.length() == 0) { | |
+ bundle.putStringArrayList(key, stringArrayList); | |
+ return; | |
+ } | |
+ | |
+ // Only strings are supported for now | |
+ for (int i = 0; i < jsonArray.length(); i++) { | |
+ Object current = jsonArray.get(i); | |
+ if (current instanceof String) { | |
+ stringArrayList.add((String)current); | |
+ } else { | |
+ throw new IllegalArgumentException("Unexpected type in an array: " + current.getClass()); | |
+ } | |
+ } | |
+ bundle.putStringArrayList(key, stringArrayList); | |
+ } | |
+ | |
+ @Override | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException { | |
+ throw new IllegalArgumentException("JSONArray's are not supported in bundles."); | |
+ } | |
+ }); | |
+ } | |
+ | |
+ public interface Setter { | |
+ public void setOnBundle(Bundle bundle, String key, Object value) throws JSONException; | |
+ public void setOnJSON(JSONObject json, String key, Object value) throws JSONException; | |
+ } | |
+ | |
+ public static JSONObject convertToJSON(Bundle bundle) throws JSONException { | |
+ JSONObject json = new JSONObject(); | |
+ | |
+ for(String key : bundle.keySet()) { | |
+ Object value = bundle.get(key); | |
+ if (value == null) { | |
+ // Null is not supported. | |
+ continue; | |
+ } | |
+ | |
+ // Special case List<String> as getClass would not work, since List is an interface | |
+ if (value instanceof List<?>) { | |
+ JSONArray jsonArray = new JSONArray(); | |
+ @SuppressWarnings("unchecked") | |
+ List<String> listValue = (List<String>)value; | |
+ for (String stringValue : listValue) { | |
+ jsonArray.put(stringValue); | |
+ } | |
+ json.put(key, jsonArray); | |
+ continue; | |
+ } | |
+ | |
+ // Special case Bundle as it's one way, on the return it will be JSONObject | |
+ if (value instanceof Bundle) { | |
+ json.put(key, convertToJSON((Bundle)value)); | |
+ continue; | |
+ } | |
+ | |
+ Setter setter = SETTERS.get(value.getClass()); | |
+ if (setter == null) { | |
+ throw new IllegalArgumentException("Unsupported type: " + value.getClass()); | |
+ } | |
+ setter.setOnJSON(json, key, value); | |
+ } | |
+ | |
+ return json; | |
+ } | |
+ | |
+ public static Bundle convertToBundle(JSONObject jsonObject) throws JSONException { | |
+ Bundle bundle = new Bundle(); | |
+ @SuppressWarnings("unchecked") | |
+ Iterator<String> jsonIterator = jsonObject.keys(); | |
+ while (jsonIterator.hasNext()) { | |
+ String key = jsonIterator.next(); | |
+ Object value = jsonObject.get(key); | |
+ if (value == null || value == JSONObject.NULL) { | |
+ // Null is not supported. | |
+ continue; | |
+ } | |
+ | |
+ // Special case JSONObject as it's one way, on the return it would be Bundle. | |
+ if (value instanceof JSONObject) { | |
+ bundle.putBundle(key, convertToBundle((JSONObject)value)); | |
+ continue; | |
+ } | |
+ | |
+ Setter setter = SETTERS.get(value.getClass()); | |
+ if (setter == null) { | |
+ throw new IllegalArgumentException("Unsupported type: " + value.getClass()); | |
+ } | |
+ setter.setOnBundle(bundle, key, value); | |
+ } | |
+ | |
+ return bundle; | |
+ } | |
+} | |
\ No newline at end of file | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java | |
index 972ac36..dd2cc9a 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java | |
@@ -1,22 +1,19 @@ | |
package com.wix.reactnativenotifications.fcm; | |
-import androidx.annotation.NonNull; | |
-import androidx.core.app.JobIntentService; | |
-import android.content.Context; | |
+import android.app.IntentService; | |
import android.content.Intent; | |
-public class FcmInstanceIdRefreshHandlerService extends JobIntentService { | |
+public class FcmInstanceIdRefreshHandlerService extends IntentService { | |
public static String EXTRA_IS_APP_INIT = "isAppInit"; | |
public static String EXTRA_MANUAL_REFRESH = "doManualRefresh"; | |
- public static final int JOB_ID = 2400; | |
- public static void enqueueWork(Context context, Intent work) { | |
- enqueueWork(context, FcmInstanceIdRefreshHandlerService.class, JOB_ID, work); | |
+ public FcmInstanceIdRefreshHandlerService() { | |
+ super(FcmInstanceIdRefreshHandlerService.class.getSimpleName()); | |
} | |
@Override | |
- protected void onHandleWork(@NonNull Intent intent) { | |
+ protected void onHandleIntent(Intent intent) { | |
IFcmToken fcmToken = FcmToken.get(this); | |
if (fcmToken == null) { | |
return; | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java | |
index 09bcce7..3a70095 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java | |
@@ -4,14 +4,13 @@ import android.content.Context; | |
import android.os.Bundle; | |
import android.util.Log; | |
+import com.facebook.react.BuildConfig; | |
import com.facebook.react.ReactApplication; | |
import com.facebook.react.ReactInstanceManager; | |
import com.facebook.react.bridge.ReactContext; | |
-import com.facebook.react.modules.core.DeviceEventManagerModule; | |
import com.google.android.gms.tasks.OnSuccessListener; | |
import com.google.firebase.iid.FirebaseInstanceId; | |
import com.google.firebase.iid.InstanceIdResult; | |
-import com.wix.reactnativenotifications.BuildConfig; | |
import com.wix.reactnativenotifications.core.JsIOHelper; | |
import static com.wix.reactnativenotifications.Defs.LOGTAG; | |
@@ -75,14 +74,11 @@ public class FcmToken implements IFcmToken { | |
} | |
protected void refreshToken() { | |
- FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() { | |
+ FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( new OnSuccessListener<InstanceIdResult>() { | |
@Override | |
public void onSuccess(InstanceIdResult instanceIdResult) { | |
sToken = instanceIdResult.getToken(); | |
- if (mAppContext instanceof IFcmTokenListenerApplication) { | |
- ((IFcmTokenListenerApplication) mAppContext).onNewFCMToken(sToken); | |
- } | |
- if (BuildConfig.DEBUG) Log.i(LOGTAG, "FCM has a new token" + "=" + sToken); | |
+ if(BuildConfig.DEBUG) Log.i(LOGTAG, "FCM has a new token" + "=" + sToken); | |
sendTokenToJS(); | |
} | |
}); | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/IFcmTokenListenerApplication.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/IFcmTokenListenerApplication.java | |
deleted file mode 100644 | |
index 7dc85e5..0000000 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/IFcmTokenListenerApplication.java | |
+++ /dev/null | |
@@ -1,9 +0,0 @@ | |
-package com.wix.reactnativenotifications.fcm; | |
- | |
-/** | |
- * API for Applications that want to listen new FCM tokens | |
- * whenever its ready. | |
- */ | |
-public interface IFcmTokenListenerApplication { | |
- void onNewFCMToken(String token); | |
-} | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java b/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java | |
index f9c858b..94ea188 100644 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java | |
+++ b/node_modules/react-native-notifications/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java | |
@@ -2,8 +2,8 @@ | |
package com.wix.reactnativenotifications; | |
import android.content.Context; | |
-import android.support.annotation.NonNull; | |
-import android.support.v4.app.NotificationManagerCompat; | |
+import androidx.annotation.NonNull; | |
+import androidx.core.app.NotificationManagerCompat; | |
public abstract class NotificationManagerCompatFacade { | |
public static NotificationManagerCompat from(@NonNull Context context) { | |
diff --git a/node_modules/react-native-notifications/lib/android/app/src/test/resources/robolectric.properties b/node_modules/react-native-notifications/lib/android/app/src/test/resources/robolectric.properties | |
deleted file mode 100644 | |
index 89a6c8b..0000000 | |
--- a/node_modules/react-native-notifications/lib/android/app/src/test/resources/robolectric.properties | |
+++ /dev/null | |
@@ -1 +0,0 @@ | |
-sdk=28 | |
\ No newline at end of file | |
diff --git a/node_modules/react-native-notifications/lib/android/build.gradle b/node_modules/react-native-notifications/lib/android/build.gradle | |
index 1773622..ec02bf7 100644 | |
--- a/node_modules/react-native-notifications/lib/android/build.gradle | |
+++ b/node_modules/react-native-notifications/lib/android/build.gradle | |
@@ -1,14 +1,6 @@ | |
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
-import groovy.json.JsonSlurper | |
buildscript { | |
- ext{ | |
- androidGradlePluginVersion = '4.0.0' | |
- kotlinVersion = "1.3.61" | |
- googleServices = "4.3.3" | |
- androidSdkVersion = 29 | |
- } | |
- | |
repositories { | |
mavenLocal() | |
mavenCentral() | |
@@ -16,9 +8,10 @@ buildscript { | |
jcenter() | |
} | |
dependencies { | |
- classpath "com.android.tools.build:gradle:$androidGradlePluginVersion" | |
- classpath "com.google.gms:google-services:$googleServices" | |
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" | |
+ classpath 'com.android.tools.build:gradle:3.5.2' | |
+ classpath 'com.google.gms:google-services:4.0.0' | |
+ // NOTE: Do not place your application dependencies here; they belong | |
+ // in the individual module build.gradle files | |
} | |
} | |
@@ -34,18 +27,3 @@ allprojects { | |
} | |
} | |
} | |
-subprojects { | |
- afterEvaluate { project -> | |
- if ((project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library'))) { | |
- android { | |
- compileSdkVersion rootProject.ext.androidSdkVersion | |
- } | |
- } | |
- if (project.hasProperty('defaultConfig')) { | |
- defaultConfig { | |
- minSdkVersion rootProject.ext.androidMinSdkVersion | |
- targetSdkVersion rootProject.ext.androidSdkVersion | |
- } | |
- } | |
- } | |
-} | |
\ No newline at end of file | |
diff --git a/node_modules/react-native-notifications/lib/android/gradle.properties b/node_modules/react-native-notifications/lib/android/gradle.properties | |
index ccb748f..1d3591c 100644 | |
--- a/node_modules/react-native-notifications/lib/android/gradle.properties | |
+++ b/node_modules/react-native-notifications/lib/android/gradle.properties | |
@@ -16,6 +16,3 @@ | |
# This option should only be used with decoupled projects. More details, visit | |
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | |
# org.gradle.parallel=true | |
\ No newline at end of file | |
- | |
-android.useAndroidX=true | |
-android.enableJetifier=true | |
\ No newline at end of file | |
diff --git a/node_modules/react-native-notifications/lib/android/gradle/wrapper/gradle-wrapper.properties b/node_modules/react-native-notifications/lib/android/gradle/wrapper/gradle-wrapper.properties | |
index a476594..5108c78 100644 | |
--- a/node_modules/react-native-notifications/lib/android/gradle/wrapper/gradle-wrapper.properties | |
+++ b/node_modules/react-native-notifications/lib/android/gradle/wrapper/gradle-wrapper.properties | |
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME | |
distributionPath=wrapper/dists | |
zipStoreBase=GRADLE_USER_HOME | |
zipStorePath=wrapper/dists | |
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip | |
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip | |
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts b/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts | |
index 7b2b3b1..6530bfa 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts | |
@@ -2,10 +2,11 @@ export declare class Notification { | |
identifier: string; | |
payload: any; | |
constructor(payload: object); | |
- get title(): string; | |
- get body(): string; | |
- get sound(): string; | |
- get badge(): number; | |
- get type(): string; | |
- get thread(): string; | |
+ readonly title: string; | |
+ readonly body: string; | |
+ readonly sound: string; | |
+ readonly badge: number; | |
+ readonly type: string; | |
+ readonly thread: string; | |
+ readonly fireDate: number; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/Notification.js b/node_modules/react-native-notifications/lib/dist/DTO/Notification.js | |
index ad7fc1a..b55198b 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/DTO/Notification.js | |
+++ b/node_modules/react-native-notifications/lib/dist/DTO/Notification.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.Notification = void 0; | |
class Notification { | |
constructor(payload) { | |
this.payload = payload; | |
@@ -24,5 +23,8 @@ class Notification { | |
get thread() { | |
return this.payload.thread; | |
} | |
+ get fireDate() { | |
+ return this.payload.fireDate || 0; | |
+ } | |
} | |
exports.Notification = Notification; | |
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.d.ts b/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.d.ts | |
index 8bdcb9b..56aa70d 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.d.ts | |
@@ -1,7 +1,7 @@ | |
import { Notification } from './Notification'; | |
export declare class NotificationAndroid extends Notification { | |
constructor(payload: object); | |
- get title(): string; | |
- get body(): string; | |
- get sound(): string; | |
+ readonly title: string; | |
+ readonly body: string; | |
+ readonly sound: string; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.js b/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.js | |
index 9dec9f7..94a842e 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.js | |
+++ b/node_modules/react-native-notifications/lib/dist/DTO/NotificationAndroid.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationAndroid = void 0; | |
const Notification_1 = require("./Notification"); | |
class NotificationAndroid extends Notification_1.Notification { | |
constructor(payload) { | |
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/NotificationFactory.js b/node_modules/react-native-notifications/lib/dist/DTO/NotificationFactory.js | |
index 1c40cba..d8d95cf 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/DTO/NotificationFactory.js | |
+++ b/node_modules/react-native-notifications/lib/dist/DTO/NotificationFactory.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationFactory = void 0; | |
const Notification_1 = require("./Notification"); | |
const NotificationIOS_1 = require("./NotificationIOS"); | |
const NotificationAndroid_1 = require("./NotificationAndroid"); | |
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.d.ts b/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.d.ts | |
index ed2616e..2933ec2 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.d.ts | |
@@ -2,11 +2,11 @@ import { Notification } from './Notification'; | |
export declare class NotificationIOS extends Notification { | |
identifier: string; | |
constructor(payload: object); | |
- get aps(): any; | |
- get alert(): any; | |
- get title(): string; | |
- get body(): string; | |
- get sound(): string; | |
- get badge(): number; | |
- get thread(): string; | |
+ readonly aps: any; | |
+ readonly alert: any; | |
+ readonly title: string; | |
+ readonly body: string; | |
+ readonly sound: string; | |
+ readonly badge: number; | |
+ readonly thread: string; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.js b/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.js | |
index 6950994..944b97d 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.js | |
+++ b/node_modules/react-native-notifications/lib/dist/DTO/NotificationIOS.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationIOS = void 0; | |
const Notification_1 = require("./Notification"); | |
const _ = require("lodash"); | |
class NotificationIOS extends Notification_1.Notification { | |
diff --git a/node_modules/react-native-notifications/lib/dist/Notifications.d.ts b/node_modules/react-native-notifications/lib/dist/Notifications.d.ts | |
index 34e8170..354666b 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/Notifications.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/Notifications.d.ts | |
@@ -35,7 +35,8 @@ export declare class NotificationsRoot { | |
/** | |
* cancelLocalNotification | |
*/ | |
- cancelLocalNotification(notificationId: string): void; | |
+ cancelLocalNotification(notificationId: number): void; | |
+ cancelAllLocalNotifications(): void; | |
/** | |
* removeAllDeliveredNotifications | |
*/ | |
@@ -55,6 +56,6 @@ export declare class NotificationsRoot { | |
/** | |
* ios/android getters | |
*/ | |
- get ios(): NotificationsIOS; | |
- get android(): NotificationsAndroid; | |
+ readonly ios: NotificationsIOS; | |
+ readonly android: NotificationsAndroid; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/Notifications.js b/node_modules/react-native-notifications/lib/dist/Notifications.js | |
index 15eea09..9697f3d 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/Notifications.js | |
+++ b/node_modules/react-native-notifications/lib/dist/Notifications.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationsRoot = void 0; | |
const NativeCommandsSender_1 = require("./adapters/NativeCommandsSender"); | |
const NativeEventsReceiver_1 = require("./adapters/NativeEventsReceiver"); | |
const Commands_1 = require("./commands/Commands"); | |
@@ -20,7 +19,7 @@ class NotificationsRoot { | |
this.uniqueIdProvider = new UniqueIdProvider_1.UniqueIdProvider(); | |
this.commands = new Commands_1.Commands(this.nativeCommandsSender, this.uniqueIdProvider, this.notificationFactory); | |
this.eventsRegistry = new EventsRegistry_1.EventsRegistry(this.nativeEventsReceiver, this.completionCallbackWrapper); | |
- this.eventsRegistryIOS = new EventsRegistryIOS_1.EventsRegistryIOS(this.nativeEventsReceiver, this.completionCallbackWrapper); | |
+ this.eventsRegistryIOS = new EventsRegistryIOS_1.EventsRegistryIOS(this.nativeEventsReceiver); | |
this._ios = new NotificationsIOS_1.NotificationsIOS(this.commands, this.eventsRegistryIOS); | |
this._android = new NotificationsAndroid_1.NotificationsAndroid(this.commands); | |
} | |
@@ -55,6 +54,9 @@ class NotificationsRoot { | |
cancelLocalNotification(notificationId) { | |
return this.commands.cancelLocalNotification(notificationId); | |
} | |
+ cancelAllLocalNotifications() { | |
+ this.commands.cancelAllLocalNotifications(); | |
+ } | |
/** | |
* removeAllDeliveredNotifications | |
*/ | |
diff --git a/node_modules/react-native-notifications/lib/dist/NotificationsAndroid.js b/node_modules/react-native-notifications/lib/dist/NotificationsAndroid.js | |
index 4628495..a596b4f 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/NotificationsAndroid.js | |
+++ b/node_modules/react-native-notifications/lib/dist/NotificationsAndroid.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationsAndroid = void 0; | |
const react_native_1 = require("react-native"); | |
class NotificationsAndroid { | |
constructor(commands) { | |
diff --git a/node_modules/react-native-notifications/lib/dist/NotificationsIOS.js b/node_modules/react-native-notifications/lib/dist/NotificationsIOS.js | |
index 8724b5c..b3acedf 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/NotificationsIOS.js | |
+++ b/node_modules/react-native-notifications/lib/dist/NotificationsIOS.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationsIOS = void 0; | |
const react_native_1 = require("react-native"); | |
class NotificationsIOS { | |
constructor(commands, eventsRegistry) { | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.d.ts b/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.d.ts | |
index 01e6f83..43efb2c 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.d.ts | |
@@ -7,5 +7,6 @@ export declare class CompletionCallbackWrapper { | |
wrapReceivedBackgroundCallback(callback: Function): (notification: Notification) => void; | |
wrapReceivedForegroundCallback(callback: Function): (notification: Notification) => void; | |
private wrapReceivedAndInvoke; | |
- wrapOpenedCallback(callback: Function): (notification: object, actionResponse?: NotificationActionResponse) => void; | |
+ wrapOpenedCallback(callback: Function): (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void; | |
+ private applicationIsVisible; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.js b/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.js | |
index f601e6f..751e817 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.js | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/CompletionCallbackWrapper.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.CompletionCallbackWrapper = void 0; | |
const react_native_1 = require("react-native"); | |
class CompletionCallbackWrapper { | |
constructor(nativeCommandsSender) { | |
@@ -8,30 +7,28 @@ class CompletionCallbackWrapper { | |
} | |
wrapReceivedBackgroundCallback(callback) { | |
return (notification) => { | |
- this.wrapReceivedAndInvoke(callback, notification, true); | |
+ if (!this.applicationIsVisible()) { | |
+ this.wrapReceivedAndInvoke(callback, notification); | |
+ } | |
}; | |
} | |
wrapReceivedForegroundCallback(callback) { | |
return (notification) => { | |
- this.wrapReceivedAndInvoke(callback, notification, false); | |
+ if (this.applicationIsVisible()) { | |
+ this.wrapReceivedAndInvoke(callback, notification); | |
+ } | |
}; | |
} | |
- wrapReceivedAndInvoke(callback, notification, background) { | |
+ wrapReceivedAndInvoke(callback, notification) { | |
const completion = (response) => { | |
if (react_native_1.Platform.OS === 'ios') { | |
- const identifier = notification.identifier; | |
- if (background) { | |
- this.nativeCommandsSender.finishHandlingBackgroundAction(identifier, response); | |
- } | |
- else { | |
- this.nativeCommandsSender.finishPresentingNotification(identifier, response); | |
- } | |
+ this.nativeCommandsSender.finishPresentingNotification(notification.identifier, response); | |
} | |
}; | |
callback(notification, completion); | |
} | |
wrapOpenedCallback(callback) { | |
- return (notification, actionResponse) => { | |
+ return (notification, _completion, actionResponse) => { | |
const completion = () => { | |
if (react_native_1.Platform.OS === 'ios') { | |
this.nativeCommandsSender.finishHandlingAction(notification.identifier); | |
@@ -40,5 +37,8 @@ class CompletionCallbackWrapper { | |
callback(notification, completion, actionResponse); | |
}; | |
} | |
+ applicationIsVisible() { | |
+ return react_native_1.AppState.currentState !== 'background'; | |
+ } | |
} | |
exports.CompletionCallbackWrapper = CompletionCallbackWrapper; | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.d.ts b/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.d.ts | |
index afb92a0..e7083ee 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.d.ts | |
@@ -15,7 +15,7 @@ export declare class NativeCommandsSender { | |
setCategories(categories: [NotificationCategory?]): void; | |
getBadgeCount(): Promise<number>; | |
setBadgeCount(count: number): void; | |
- cancelLocalNotification(notificationId: string): void; | |
+ cancelLocalNotification(notificationId: number): void; | |
cancelAllLocalNotifications(): void; | |
isRegisteredForRemoteNotifications(): Promise<any>; | |
checkPermissions(): Promise<NotificationPermissions>; | |
@@ -25,5 +25,4 @@ export declare class NativeCommandsSender { | |
finishPresentingNotification(notificationId: string, notificationCompletion: NotificationCompletion): void; | |
finishHandlingAction(notificationId: string): void; | |
setNotificationChannel(notificationChannel: NotificationChannel): void; | |
- finishHandlingBackgroundAction(notificationId: string, backgroundFetchResult: string): void; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.js b/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.js | |
index c853996..6498bb2 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.js | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NativeCommandsSender = void 0; | |
const react_native_1 = require("react-native"); | |
class NativeCommandsSender { | |
constructor() { | |
@@ -63,8 +62,5 @@ class NativeCommandsSender { | |
setNotificationChannel(notificationChannel) { | |
this.nativeCommandsModule.setNotificationChannel(notificationChannel); | |
} | |
- finishHandlingBackgroundAction(notificationId, backgroundFetchResult) { | |
- this.nativeCommandsModule.finishHandlingBackgroundAction(notificationId, backgroundFetchResult); | |
- } | |
} | |
exports.NativeCommandsSender = NativeCommandsSender; | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.mock.js b/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.mock.js | |
index 5055e6f..0d9cc78 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.mock.js | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/NativeCommandsSender.mock.js | |
@@ -1,4 +1,3 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NativeCommandsSender = void 0; | |
exports.NativeCommandsSender = jest.genMockFromModule('./NativeCommandsSender').NativeCommandsSender; | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.d.ts b/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.d.ts | |
index 43df13e..b1a4955 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.d.ts | |
@@ -10,8 +10,7 @@ export declare class NativeEventsReceiver { | |
registerRemoteNotificationsRegistered(callback: (event: Registered) => void): EmitterSubscription; | |
registerPushKitRegistered(callback: (event: RegisteredPushKit) => void): EmitterSubscription; | |
registerNotificationReceived(callback: (notification: Notification) => void): EmitterSubscription; | |
- registerNotificationReceivedBackground(callback: (notification: Notification) => void): EmitterSubscription; | |
registerPushKitNotificationReceived(callback: (event: object) => void): EmitterSubscription; | |
- registerNotificationOpened(callback: (notification: Notification, actionResponse?: NotificationActionResponse) => void): EmitterSubscription; | |
+ registerNotificationOpened(callback: (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void): EmitterSubscription; | |
registerRemoteNotificationsRegistrationFailed(callback: (event: RegistrationError) => void): EmitterSubscription; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.js b/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.js | |
index e95f973..fbd31ac 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.js | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NativeEventsReceiver = void 0; | |
const react_native_1 = require("react-native"); | |
const NotificationActionResponse_1 = require("../interfaces/NotificationActionResponse"); | |
class NativeEventsReceiver { | |
@@ -19,18 +18,13 @@ class NativeEventsReceiver { | |
callback(this.notificationFactory.fromPayload(payload)); | |
}); | |
} | |
- registerNotificationReceivedBackground(callback) { | |
- return this.emitter.addListener('notificationReceivedBackground', (payload) => { | |
- callback(this.notificationFactory.fromPayload(payload)); | |
- }); | |
- } | |
registerPushKitNotificationReceived(callback) { | |
return this.emitter.addListener('pushKitNotificationReceived', callback); | |
} | |
registerNotificationOpened(callback) { | |
- return this.emitter.addListener('notificationOpened', (response) => { | |
+ return this.emitter.addListener('notificationOpened', (response, completion) => { | |
const action = response.action ? new NotificationActionResponse_1.NotificationActionResponse(response.action) : undefined; | |
- callback(this.notificationFactory.fromPayload(response.notification), action); | |
+ callback(this.notificationFactory.fromPayload(response.notification), completion, action); | |
}); | |
} | |
registerRemoteNotificationsRegistrationFailed(callback) { | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.mock.js b/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.mock.js | |
index e939c9b..1f634fa 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.mock.js | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/NativeEventsReceiver.mock.js | |
@@ -1,4 +1,3 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NativeEventsReceiver = void 0; | |
exports.NativeEventsReceiver = jest.genMockFromModule('./NativeEventsReceiver').NativeEventsReceiver; | |
diff --git a/node_modules/react-native-notifications/lib/dist/adapters/UniqueIdProvider.js b/node_modules/react-native-notifications/lib/dist/adapters/UniqueIdProvider.js | |
index 6a4dd18..069faf6 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/adapters/UniqueIdProvider.js | |
+++ b/node_modules/react-native-notifications/lib/dist/adapters/UniqueIdProvider.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.UniqueIdProvider = void 0; | |
const _ = require("lodash"); | |
class UniqueIdProvider { | |
generate() { | |
diff --git a/node_modules/react-native-notifications/lib/dist/commands/Commands.d.ts b/node_modules/react-native-notifications/lib/dist/commands/Commands.d.ts | |
index c98b6e9..c698dba 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/commands/Commands.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/commands/Commands.d.ts | |
@@ -18,7 +18,7 @@ export declare class Commands { | |
setCategories(categories: [NotificationCategory?]): void; | |
getBadgeCount(): Promise<number>; | |
setBadgeCount(count: number): void; | |
- cancelLocalNotification(notificationId: string): void; | |
+ cancelLocalNotification(notificationId: number): void; | |
cancelAllLocalNotifications(): void; | |
isRegisteredForRemoteNotifications(): Promise<boolean>; | |
checkPermissions(): Promise<NotificationPermissions>; | |
diff --git a/node_modules/react-native-notifications/lib/dist/commands/Commands.js b/node_modules/react-native-notifications/lib/dist/commands/Commands.js | |
index eb1eb41..6a23b18 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/commands/Commands.js | |
+++ b/node_modules/react-native-notifications/lib/dist/commands/Commands.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.Commands = void 0; | |
class Commands { | |
constructor(nativeCommandsSender, uniqueIdProvider, notificationFactory) { | |
this.nativeCommandsSender = nativeCommandsSender; | |
diff --git a/node_modules/react-native-notifications/lib/dist/commands/Commands.test.js b/node_modules/react-native-notifications/lib/dist/commands/Commands.test.js | |
index 315d28a..644cd89 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/commands/Commands.test.js | |
+++ b/node_modules/react-native-notifications/lib/dist/commands/Commands.test.js | |
@@ -116,8 +116,8 @@ describe('Commands', () => { | |
}); | |
describe('cancelLocalNotification', () => { | |
it('sends to native', () => { | |
- uut.cancelLocalNotification("notificationId"); | |
- ts_mockito_1.verify(mockedNativeCommandsSender.cancelLocalNotification("notificationId")).called(); | |
+ uut.cancelLocalNotification(1); | |
+ ts_mockito_1.verify(mockedNativeCommandsSender.cancelLocalNotification(1)).called(); | |
}); | |
}); | |
describe('cancelAllLocalNotifications', () => { | |
diff --git a/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.d.ts b/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.d.ts | |
index 4208946..4bab81a 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.d.ts | |
@@ -4,14 +4,14 @@ import { Registered, RegistrationError } from '../interfaces/NotificationEvents' | |
import { NotificationActionResponse } from '../interfaces/NotificationActionResponse'; | |
import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper'; | |
import { Notification } from '../DTO/Notification'; | |
-import { NotificationCompletion, NotificationBackgroundFetchResult } from '../interfaces/NotificationCompletion'; | |
+import { NotificationCompletion } from '../interfaces/NotificationCompletion'; | |
export declare class EventsRegistry { | |
private nativeEventsReceiver; | |
private completionCallbackWrapper; | |
constructor(nativeEventsReceiver: NativeEventsReceiver, completionCallbackWrapper: CompletionCallbackWrapper); | |
registerRemoteNotificationsRegistered(callback: (event: Registered) => void): EmitterSubscription; | |
registerNotificationReceivedForeground(callback: (notification: Notification, completion: (response: NotificationCompletion) => void) => void): EmitterSubscription; | |
- registerNotificationReceivedBackground(callback: (notification: Notification, completion: (response: NotificationBackgroundFetchResult) => void) => void): EmitterSubscription; | |
+ registerNotificationReceivedBackground(callback: (notification: Notification, completion: (response: NotificationCompletion) => void) => void): EmitterSubscription; | |
registerNotificationOpened(callback: (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void): EmitterSubscription; | |
registerRemoteNotificationsRegistrationFailed(callback: (event: RegistrationError) => void): EmitterSubscription; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.js b/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.js | |
index f87454c..7921469 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.js | |
+++ b/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.EventsRegistry = void 0; | |
class EventsRegistry { | |
constructor(nativeEventsReceiver, completionCallbackWrapper) { | |
this.nativeEventsReceiver = nativeEventsReceiver; | |
@@ -13,7 +12,7 @@ class EventsRegistry { | |
return this.nativeEventsReceiver.registerNotificationReceived(this.completionCallbackWrapper.wrapReceivedForegroundCallback(callback)); | |
} | |
registerNotificationReceivedBackground(callback) { | |
- return this.nativeEventsReceiver.registerNotificationReceivedBackground(this.completionCallbackWrapper.wrapReceivedBackgroundCallback(callback)); | |
+ return this.nativeEventsReceiver.registerNotificationReceived(this.completionCallbackWrapper.wrapReceivedBackgroundCallback(callback)); | |
} | |
registerNotificationOpened(callback) { | |
return this.nativeEventsReceiver.registerNotificationOpened(this.completionCallbackWrapper.wrapOpenedCallback(callback)); | |
diff --git a/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.test.js b/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.test.js | |
index 5609f7f..60302e1 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.test.js | |
+++ b/node_modules/react-native-notifications/lib/dist/events/EventsRegistry.test.js | |
@@ -6,7 +6,6 @@ const Notification_1 = require("../DTO/Notification"); | |
const CompletionCallbackWrapper_1 = require("../adapters/CompletionCallbackWrapper"); | |
const NativeCommandsSender_mock_1 = require("../adapters/NativeCommandsSender.mock"); | |
const react_native_1 = require("react-native"); | |
-const NotificationCompletion_1 = require("../interfaces/NotificationCompletion"); | |
describe('EventsRegistry', () => { | |
let uut; | |
const mockNativeEventsReceiver = new NativeEventsReceiver_mock_1.NativeEventsReceiver(); | |
@@ -72,14 +71,14 @@ describe('EventsRegistry', () => { | |
it('delegates to nativeEventsReceiver', () => { | |
const cb = jest.fn(); | |
uut.registerNotificationReceivedBackground(cb); | |
- expect(mockNativeEventsReceiver.registerNotificationReceivedBackground).toHaveBeenCalledTimes(1); | |
- expect(mockNativeEventsReceiver.registerNotificationReceivedBackground).toHaveBeenCalledWith(expect.any(Function)); | |
+ expect(mockNativeEventsReceiver.registerNotificationReceived).toHaveBeenCalledTimes(1); | |
+ expect(mockNativeEventsReceiver.registerNotificationReceived).toHaveBeenCalledWith(expect.any(Function)); | |
}); | |
it('should wrap callback with completion block', () => { | |
const wrappedCallback = jest.fn(); | |
const notification = new Notification_1.Notification({ identifier: 'identifier' }); | |
uut.registerNotificationReceivedBackground(wrappedCallback); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(notification); | |
expect(wrappedCallback).toBeCalledWith(notification, expect.any(Function)); | |
expect(wrappedCallback).toBeCalledTimes(1); | |
@@ -89,29 +88,29 @@ describe('EventsRegistry', () => { | |
uut.registerNotificationReceivedBackground((notification) => { | |
expect(notification).toEqual(expectedNotification); | |
}); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(expectedNotification); | |
}); | |
- it('should invoke finishHandlingBackgroundAction', () => { | |
+ it('should invoke finishPresentingNotification', () => { | |
const notification = new Notification_1.Notification({ identifier: 'notificationId' }); | |
- const response = NotificationCompletion_1.NotificationBackgroundFetchResult.NO_DATA; | |
+ const response = { alert: true }; | |
uut.registerNotificationReceivedBackground((notification, completion) => { | |
completion(response); | |
- expect(mockNativeCommandsSender.finishHandlingBackgroundAction).toBeCalledWith(notification.identifier, response); | |
+ expect(mockNativeCommandsSender.finishPresentingNotification).toBeCalledWith(notification.identifier, response); | |
}); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(notification); | |
}); | |
- it('should not invoke finishHandlingBackgroundAction on Android', () => { | |
+ it('should not invoke finishPresentingNotification on Android', () => { | |
react_native_1.Platform.OS = 'android'; | |
const expectedNotification = new Notification_1.Notification({ identifier: 'notificationId' }); | |
- const response = NotificationCompletion_1.NotificationBackgroundFetchResult.NO_DATA; | |
+ const response = { alert: true }; | |
uut.registerNotificationReceivedBackground((notification, completion) => { | |
completion(response); | |
expect(expectedNotification).toEqual(notification); | |
- expect(mockNativeCommandsSender.finishHandlingBackgroundAction).toBeCalledTimes(0); | |
+ expect(mockNativeCommandsSender.finishPresentingNotification).toBeCalledTimes(0); | |
}); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(expectedNotification); | |
}); | |
}); | |
@@ -125,15 +124,11 @@ describe('EventsRegistry', () => { | |
it('should wrap callback with completion block', () => { | |
const wrappedCallback = jest.fn(); | |
const notification = new Notification_1.Notification({ identifier: 'identifier' }); | |
- const response = { | |
- notification, | |
- identifier: 'responseId', | |
- action: { identifier: 'actionIdentifier', text: 'userText' }, | |
- }; | |
+ const response = { notification, identifier: 'responseId' }; | |
uut.registerNotificationOpened(wrappedCallback); | |
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0]; | |
- call(response.notification, response.action); | |
- expect(wrappedCallback).toBeCalledWith(response.notification, expect.any(Function), response.action); | |
+ call(response); | |
+ expect(wrappedCallback).toBeCalledWith(response, expect.any(Function), undefined); //JMC: ActionResponse | |
expect(wrappedCallback).toBeCalledTimes(1); | |
}); | |
it('should wrap callback with completion block', () => { | |
diff --git a/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.d.ts b/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.d.ts | |
index 9986698..0c05155 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.d.ts | |
@@ -1,11 +1,9 @@ | |
import { EmitterSubscription } from 'react-native'; | |
import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver'; | |
import { RegisteredPushKit } from '../interfaces/NotificationEvents'; | |
-import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper'; | |
export declare class EventsRegistryIOS { | |
private nativeEventsReceiver; | |
- private completionCallbackWrapper; | |
- constructor(nativeEventsReceiver: NativeEventsReceiver, completionCallbackWrapper: CompletionCallbackWrapper); | |
+ constructor(nativeEventsReceiver: NativeEventsReceiver); | |
registerPushKitRegistered(callback: (event: RegisteredPushKit) => void): EmitterSubscription; | |
- registerPushKitNotificationReceived(callback: (event: object, completion: () => void) => void): EmitterSubscription; | |
+ registerPushKitNotificationReceived(callback: (event: object) => void): EmitterSubscription; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.js b/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.js | |
index 7f69fb0..bd69563 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.js | |
+++ b/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.js | |
@@ -1,16 +1,14 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.EventsRegistryIOS = void 0; | |
class EventsRegistryIOS { | |
- constructor(nativeEventsReceiver, completionCallbackWrapper) { | |
+ constructor(nativeEventsReceiver) { | |
this.nativeEventsReceiver = nativeEventsReceiver; | |
- this.completionCallbackWrapper = completionCallbackWrapper; | |
} | |
registerPushKitRegistered(callback) { | |
return this.nativeEventsReceiver.registerPushKitRegistered(callback); | |
} | |
registerPushKitNotificationReceived(callback) { | |
- return this.nativeEventsReceiver.registerPushKitNotificationReceived(this.completionCallbackWrapper.wrapOpenedCallback(callback)); | |
+ return this.nativeEventsReceiver.registerPushKitNotificationReceived(callback); | |
} | |
} | |
exports.EventsRegistryIOS = EventsRegistryIOS; | |
diff --git a/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.test.js b/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.test.js | |
index 40e5272..2e2b58b 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.test.js | |
+++ b/node_modules/react-native-notifications/lib/dist/events/EventsRegistryIOS.test.js | |
@@ -1,16 +1,12 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
const EventsRegistryIOS_1 = require("./EventsRegistryIOS"); | |
-const CompletionCallbackWrapper_1 = require("../adapters/CompletionCallbackWrapper"); | |
-const NativeCommandsSender_mock_1 = require("../adapters/NativeCommandsSender.mock"); | |
const NativeEventsReceiver_mock_1 = require("../adapters/NativeEventsReceiver.mock"); | |
describe('EventsRegistryIOS', () => { | |
let uut; | |
const mockNativeEventsReceiver = new NativeEventsReceiver_mock_1.NativeEventsReceiver(); | |
- const mockNativeCommandsSender = new NativeCommandsSender_mock_1.NativeCommandsSender(); | |
- const completionCallbackWrapper = new CompletionCallbackWrapper_1.CompletionCallbackWrapper(mockNativeCommandsSender); | |
beforeEach(() => { | |
- uut = new EventsRegistryIOS_1.EventsRegistryIOS(mockNativeEventsReceiver, completionCallbackWrapper); | |
+ uut = new EventsRegistryIOS_1.EventsRegistryIOS(mockNativeEventsReceiver); | |
}); | |
it('delegates registerPushKitRegistered to nativeEventsReceiver', () => { | |
const cb = jest.fn(); | |
@@ -22,24 +18,6 @@ describe('EventsRegistryIOS', () => { | |
const cb = jest.fn(); | |
uut.registerPushKitNotificationReceived(cb); | |
expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledTimes(1); | |
- expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledWith(expect.any(Function)); | |
- }); | |
- it('should wrap callback with completion block', () => { | |
- const expectedNotification = { identifier: 'notificationId' }; | |
- uut.registerPushKitNotificationReceived((notification) => { | |
- expect(notification).toEqual(expectedNotification); | |
- }); | |
- const call = mockNativeEventsReceiver.registerPushKitNotificationReceived.mock.calls[0][0]; | |
- call(expectedNotification); | |
- }); | |
- it('should invoke finishPresentingNotification', () => { | |
- const expectedNotification = { identifier: 'notificationId' }; | |
- uut.registerPushKitNotificationReceived((notification, completion) => { | |
- completion(); | |
- expect(notification).toEqual(expectedNotification); | |
- expect(mockNativeCommandsSender.finishHandlingAction).toBeCalledWith('notificationId'); | |
- }); | |
- const call = mockNativeEventsReceiver.registerPushKitNotificationReceived.mock.calls[0][0]; | |
- call(expectedNotification); | |
+ expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledWith(cb); | |
}); | |
}); | |
diff --git a/node_modules/react-native-notifications/lib/dist/index.d.ts b/node_modules/react-native-notifications/lib/dist/index.d.ts | |
index 0c3e563..7e8925c 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/index.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/index.d.ts | |
@@ -4,4 +4,3 @@ export * from './interfaces/EventSubscription'; | |
export * from './DTO/Notification'; | |
export * from './interfaces/NotificationEvents'; | |
export * from './interfaces/NotificationCategory'; | |
-export * from './interfaces/NotificationCompletion'; | |
diff --git a/node_modules/react-native-notifications/lib/dist/index.js b/node_modules/react-native-notifications/lib/dist/index.js | |
index 279c5d6..15fee9b 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/index.js | |
+++ b/node_modules/react-native-notifications/lib/dist/index.js | |
@@ -1,12 +1,8 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.Notifications = void 0; | |
const tslib_1 = require("tslib"); | |
const Notifications_1 = require("./Notifications"); | |
const notificationsSingleton = new Notifications_1.NotificationsRoot(); | |
exports.Notifications = notificationsSingleton; | |
-tslib_1.__exportStar(require("./interfaces/EventSubscription"), exports); | |
tslib_1.__exportStar(require("./DTO/Notification"), exports); | |
-tslib_1.__exportStar(require("./interfaces/NotificationEvents"), exports); | |
tslib_1.__exportStar(require("./interfaces/NotificationCategory"), exports); | |
-tslib_1.__exportStar(require("./interfaces/NotificationCompletion"), exports); | |
diff --git a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationActionResponse.js b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationActionResponse.js | |
index 6a973c7..9945720 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationActionResponse.js | |
+++ b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationActionResponse.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationActionResponse = void 0; | |
class NotificationActionResponse { | |
constructor(response) { | |
this.identifier = response.identifier; | |
diff --git a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.js b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.js | |
index a429c14..ed67a56 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.js | |
+++ b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationAction = exports.NotificationCategory = void 0; | |
class NotificationCategory { | |
constructor(identifier, actions) { | |
this.identifier = identifier; | |
diff --git a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationChannel.js b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationChannel.js | |
index 4953bba..b3ec293 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationChannel.js | |
+++ b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationChannel.js | |
@@ -1,6 +1,5 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationChannel = void 0; | |
class NotificationChannel { | |
constructor(channelId, name, importance, description, enableLights, enableVibration, groupId, lightColor, showBadge, soundFile, vibrationPattern) { | |
this.channelId = channelId; | |
diff --git a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.d.ts b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.d.ts | |
index dab2953..8256e3d 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.d.ts | |
+++ b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.d.ts | |
@@ -3,8 +3,3 @@ export interface NotificationCompletion { | |
alert?: boolean; | |
sound?: boolean; | |
} | |
-export declare enum NotificationBackgroundFetchResult { | |
- NEW_DATA = "newData", | |
- NO_DATA = "noData", | |
- FAILED = "failed" | |
-} | |
diff --git a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.js b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.js | |
index 270de65..c8ad2e5 100644 | |
--- a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.js | |
+++ b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCompletion.js | |
@@ -1,9 +1,2 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-exports.NotificationBackgroundFetchResult = void 0; | |
-var NotificationBackgroundFetchResult; | |
-(function (NotificationBackgroundFetchResult) { | |
- NotificationBackgroundFetchResult["NEW_DATA"] = "newData"; | |
- NotificationBackgroundFetchResult["NO_DATA"] = "noData"; | |
- NotificationBackgroundFetchResult["FAILED"] = "failed"; | |
-})(NotificationBackgroundFetchResult = exports.NotificationBackgroundFetchResult || (exports.NotificationBackgroundFetchResult = {})); | |
diff --git a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h | |
index 8b2c269..13445ee 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h | |
@@ -20,11 +20,3 @@ | |
@interface RCTConvert (UNNotificationPresentationOptions) | |
+ (UNNotificationPresentationOptions)UNNotificationPresentationOptions:(id)json; | |
@end | |
- | |
-@interface RCTConvert (UIBackgroundFetchResult) | |
-+ (UIBackgroundFetchResult)UIBackgroundFetchResult:(NSString *)result; | |
-@end | |
- | |
-@interface RCTConvert (NSDictionary) | |
-+ (NSDictionary *)NotificationUserInfo:(NSDictionary *)userInfo withIdentifier:(NSString *)identifier; | |
-@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.m b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.m | |
index 375046f..b9a744b 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.m | |
@@ -117,15 +117,6 @@ + (NSDictionary *)UNNotificationPayload:(UNNotification *)notification { | |
@end | |
-@implementation RCTConvert (NSDictionary) | |
-+ (NSDictionary *)NotificationUserInfo:(NSDictionary *)userInfo withIdentifier:(NSString *)identifier { | |
- NSMutableDictionary *formattedNotification = [NSMutableDictionary dictionary]; | |
- formattedNotification[@"identifier"] = identifier; | |
- [formattedNotification addEntriesFromDictionary:[NSDictionary dictionaryWithDictionary:RCTNullIfNil(RCTJSONClean(userInfo))]]; | |
- return formattedNotification; | |
-} | |
-@end | |
- | |
@implementation RCTConvert (UNNotificationPresentationOptions) | |
+ (UNNotificationPresentationOptions)UNNotificationPresentationOptions:(id)json { | |
@@ -144,17 +135,3 @@ + (UNNotificationPresentationOptions)UNNotificationPresentationOptions:(id)json | |
} | |
@end | |
- | |
-@implementation RCTConvert (UIBackgroundFetchResult) | |
- | |
-+ (UIBackgroundFetchResult)UIBackgroundFetchResult:(NSString *)backgroundFetchResult { | |
- UIBackgroundFetchResult result = UIBackgroundFetchResultNoData; | |
- if ([@"newData" isEqualToString:backgroundFetchResult]) { | |
- result = UIBackgroundFetchResultNewData; | |
- } else if ([@"failed" isEqualToString:backgroundFetchResult]) { | |
- result = UIBackgroundFetchResultFailed; | |
- } | |
- return result; | |
-} | |
- | |
-@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNBridgeModule.m b/node_modules/react-native-notifications/lib/ios/RNBridgeModule.m | |
index 918c6f5..14cf64f 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNBridgeModule.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNBridgeModule.m | |
@@ -56,10 +56,6 @@ - (dispatch_queue_t)methodQueue { | |
[_commandsHandler finishPresentingNotification:completionKey presentingOptions:presentingOptions]; | |
} | |
-RCT_EXPORT_METHOD(finishHandlingBackgroundAction:(NSString *)completionKey backgroundFetchResult:(NSString *)backgroundFetchResult) { | |
- [_commandsHandler finishHandlingBackgroundAction:completionKey backgroundFetchResult:backgroundFetchResult]; | |
-} | |
- | |
RCT_EXPORT_METHOD(abandonPermissions) { | |
[_commandsHandler abandonPermissions]; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.h b/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.h | |
index 2f9743f..c378ffb 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.h | |
@@ -15,8 +15,6 @@ | |
- (void)finishPresentingNotification:(NSString *)completionKey presentingOptions:(NSDictionary *)presentingOptions; | |
-- (void)finishHandlingBackgroundAction:(NSString *)completionKey backgroundFetchResult:(NSString *)backgroundFetchResult; | |
- | |
- (void)abandonPermissions; | |
- (void)registerPushKit; | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.m b/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.m | |
index 96f36fe..f823793 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNCommandsHandler.m | |
@@ -33,10 +33,6 @@ - (void)finishPresentingNotification:(NSString *)completionKey presentingOptions | |
[[RNNotificationsStore sharedInstance] completePresentation:completionKey withPresentationOptions:[RCTConvert UNNotificationPresentationOptions:presentingOptions]]; | |
} | |
-- (void)finishHandlingBackgroundAction:(NSString *)completionKey backgroundFetchResult:(NSString *)backgroundFetchResult { | |
- [[RNNotificationsStore sharedInstance] completeBackgroundAction:completionKey withBackgroundFetchResult:[RCTConvert UIBackgroundFetchResult:backgroundFetchResult]]; | |
-} | |
- | |
- (void)abandonPermissions { | |
[[UIApplication sharedApplication] unregisterForRemoteNotifications]; | |
} | |
@@ -51,9 +47,7 @@ - (void)getBadgeCount:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBl | |
} | |
- (void)setBadgeCount:(int)count { | |
- dispatch_async(dispatch_get_main_queue(), ^{ | |
- [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count]; | |
- }); | |
+ [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count]; | |
} | |
- (void)postLocalNotification:(NSDictionary *)notification withId:(NSNumber *)notificationId { | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNEventEmitter.h b/node_modules/react-native-notifications/lib/ios/RNEventEmitter.h | |
index 4b129f0..691cf03 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNEventEmitter.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RNEventEmitter.h | |
@@ -4,7 +4,6 @@ static NSString* const RNRegistered = @"remoteNotificationsRegi | |
static NSString* const RNRegistrationFailed = @"remoteNotificationsRegistrationFailed"; | |
static NSString* const RNPushKitRegistered = @"pushKitRegistered"; | |
static NSString* const RNNotificationReceived = @"notificationReceived"; | |
-static NSString* const RNNotificationReceivedBackground = @"notificationReceivedBackground"; | |
static NSString* const RNNotificationOpened = @"notificationOpened"; | |
static NSString* const RNPushKitNotificationReceived = @"pushKitNotificationReceived"; | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNEventEmitter.m b/node_modules/react-native-notifications/lib/ios/RNEventEmitter.m | |
index e4fa4ce..c6d7a70 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNEventEmitter.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNEventEmitter.m | |
@@ -9,7 +9,6 @@ @implementation RNEventEmitter | |
RNRegistrationFailed, | |
RNPushKitRegistered, | |
RNNotificationReceived, | |
- RNNotificationReceivedBackground, | |
RNNotificationOpened, | |
RNPushKitNotificationReceived]; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h b/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h | |
index a07c6e9..ce16fc6 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h | |
@@ -12,6 +12,5 @@ | |
- (void)didReceiveForegroundNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler; | |
- (void)didReceiveNotificationResponse:(UNNotificationResponse *)notificationResponse completionHandler:(void (^)(void))completionHandler; | |
-- (void)didReceiveBackgroundNotification:(NSDictionary *)userInfo withCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; | |
@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.m b/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.m | |
index 5c8dd0b..db5e7fe 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.m | |
@@ -33,27 +33,4 @@ - (void)didReceiveNotificationResponse:(UNNotificationResponse *)response comple | |
[RNEventEmitter sendEvent:RNNotificationOpened body:[RNNotificationParser parseNotificationResponse:response]]; | |
} | |
-- (void)didReceiveBackgroundNotification:(NSDictionary *)userInfo withCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { | |
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
- NSString *uuid = [[NSUUID UUID] UUIDString]; | |
- __block BOOL completionHandlerCalled = NO; | |
- dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); | |
- [_store setBackgroundActionCompletionHandler:^(UIBackgroundFetchResult result) { | |
- dispatch_async(dispatch_get_main_queue(), ^{ | |
- completionHandler(result); | |
- }); | |
- completionHandlerCalled = YES; | |
- dispatch_semaphore_signal(semaphore); | |
- } withCompletionKey:uuid]; | |
- [RNEventEmitter sendEvent:RNNotificationReceivedBackground body:[RNNotificationParser parseNotificationUserInfo:userInfo withIdentifier:uuid]]; | |
- // Allow 25 seconds for this to process. If not finished call the callback with failed. | |
- dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 25 * NSEC_PER_SEC)); | |
- if (!completionHandlerCalled) { | |
- dispatch_async(dispatch_get_main_queue(), ^{ | |
- completionHandler(UIBackgroundFetchResultFailed); | |
- }); | |
- } | |
- }); | |
-} | |
- | |
@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h b/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h | |
index 7aa2bfb..6397d20 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h | |
@@ -5,6 +5,5 @@ | |
+ (NSDictionary *)parseNotificationResponse:(UNNotificationResponse *)response; | |
+ (NSDictionary *)parseNotification:(UNNotification *)notification; | |
-+ (NSDictionary *)parseNotificationUserInfo:(NSDictionary *)userInfo withIdentifier:(NSString *)identifier; | |
@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationParser.m b/node_modules/react-native-notifications/lib/ios/RNNotificationParser.m | |
index 62f3043..6800f05 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationParser.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationParser.m | |
@@ -7,10 +7,6 @@ + (NSDictionary *)parseNotification:(UNNotification *)notification { | |
return [RCTConvert UNNotificationPayload:notification]; | |
} | |
-+ (NSDictionary *)parseNotificationUserInfo:(NSDictionary *)userInfo withIdentifier:(NSString *)identifier { | |
- return [RCTConvert NotificationUserInfo:userInfo withIdentifier:(NSString *)identifier]; | |
-} | |
- | |
+ (NSDictionary *)parseNotificationResponse:(UNNotificationResponse *)response { | |
NSDictionary* responseDict = @{@"notification": [RCTConvert UNNotificationPayload:response.notification], @"identifier": response.notification.request.identifier, @"action": [self parseNotificationResponseAction:response]}; | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotifications.h b/node_modules/react-native-notifications/lib/ios/RNNotifications.h | |
index 33491fc..5e0a093 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotifications.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotifications.h | |
@@ -1,6 +1,6 @@ | |
-#import <UIKit/UIKit.h> | |
+@import UIKit; | |
#import <PushKit/PushKit.h> | |
-#import <UserNotifications/UserNotifications.h> | |
+@import UserNotifications; | |
@interface RNNotifications : NSObject | |
@@ -9,8 +9,6 @@ | |
+ (void)startMonitorNotifications; | |
+ (void)startMonitorPushKitNotifications; | |
-+ (void)didReceiveBackgroundNotification:(NSDictionary *)userInfo withCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; | |
- | |
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(id)deviceToken; | |
+ (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotifications.m b/node_modules/react-native-notifications/lib/ios/RNNotifications.m | |
index 84c9efd..9404319 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotifications.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotifications.m | |
@@ -10,7 +10,6 @@ @implementation RNNotifications { | |
RNPushKit* _pushKit; | |
RNNotificationCenterListener* _notificationCenterListener; | |
RNNotificationEventHandler* _notificationEventHandler; | |
- RNNotificationsStore* _store; | |
RNPushKitEventHandler* _pushKitEventHandler; | |
RNEventEmitter* _eventEmitter; | |
RNNotificationCenterMulticast* _notificationCenterMulticast; | |
@@ -18,8 +17,7 @@ @implementation RNNotifications { | |
- (instancetype)init { | |
self = [super init]; | |
- _store = [RNNotificationsStore new]; | |
- _notificationEventHandler = [[RNNotificationEventHandler alloc] initWithStore:_store]; | |
+ _notificationEventHandler = [[RNNotificationEventHandler alloc] initWithStore:[RNNotificationsStore new]]; | |
return self; | |
} | |
@@ -41,10 +39,6 @@ + (void)startMonitorPushKitNotifications { | |
[[self sharedInstance] startMonitorPushKitNotifications]; | |
} | |
-+ (void)didReceiveBackgroundNotification:(NSDictionary *)userInfo withCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { | |
- [[self sharedInstance] didReceiveBackgroundNotification:userInfo withCompletionHandler:completionHandler]; | |
-} | |
- | |
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(id)deviceToken { | |
[[self sharedInstance] didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; | |
} | |
@@ -71,14 +65,10 @@ - (void)startMonitorNotifications { | |
} | |
- (void)startMonitorPushKitNotifications { | |
- _pushKitEventHandler = [[RNPushKitEventHandler alloc] initWithStore:_store]; | |
+ _pushKitEventHandler = [RNPushKitEventHandler new]; | |
_pushKit = [[RNPushKit alloc] initWithEventHandler:_pushKitEventHandler]; | |
} | |
-- (void)didReceiveBackgroundNotification:(NSDictionary *)userInfo withCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { | |
- [_notificationEventHandler didReceiveBackgroundNotification:userInfo withCompletionHandler:completionHandler]; | |
-} | |
- | |
- (void)didRegisterForRemoteNotificationsWithDeviceToken:(id)deviceToken { | |
[_notificationEventHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; | |
} | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h b/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h | |
index 4f8a171..312a210 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h | |
@@ -1,5 +1,4 @@ | |
#import <Foundation/Foundation.h> | |
-#import <UIKit/UIKit.h> | |
@import UserNotifications; | |
@interface RNNotificationsStore : NSObject | |
@@ -10,10 +9,8 @@ | |
- (void)completeAction:(NSString *)completionKey; | |
- (void)completePresentation:(NSString *)completionKey withPresentationOptions:(UNNotificationPresentationOptions)presentationOptions; | |
-- (void)completeBackgroundAction:(NSString *)completionKey withBackgroundFetchResult:(UIBackgroundFetchResult)backgroundFetchResult; | |
- (void)setActionCompletionHandler:(void (^)(void))completionHandler withCompletionKey:(NSString *)completionKey; | |
- (void)setPresentationCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler withCompletionKey:(NSString *)completionKey; | |
-- (void)setBackgroundActionCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler withCompletionKey:(NSString *)completionKey; | |
- (void (^)(void))getActionCompletionHandler:(NSString *)key; | |
- (void (^)(UNNotificationPresentationOptions))getPresentationCompletionHandler:(NSString *)key; | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.m b/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.m | |
index 95c5050..d5e953a 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.m | |
@@ -3,7 +3,6 @@ | |
@implementation RNNotificationsStore | |
NSMutableDictionary* _actionCompletionHandlers; | |
NSMutableDictionary* _presentationCompletionHandlers; | |
-NSMutableDictionary* _backgroundActionCompletionHandlers; | |
+ (instancetype)sharedInstance { | |
static RNNotificationsStore *sharedInstance = nil; | |
@@ -19,7 +18,6 @@ - (instancetype)init { | |
self = [super init]; | |
_actionCompletionHandlers = [NSMutableDictionary new]; | |
_presentationCompletionHandlers = [NSMutableDictionary new]; | |
- _backgroundActionCompletionHandlers = [NSMutableDictionary new]; | |
return self; | |
} | |
@@ -31,10 +29,6 @@ - (void)setPresentationCompletionHandler:(void (^)(UNNotificationPresentationOpt | |
_presentationCompletionHandlers[completionKey] = completionHandler; | |
} | |
-- (void)setBackgroundActionCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler withCompletionKey:(NSString *)completionKey { | |
- _backgroundActionCompletionHandlers[completionKey] = completionHandler; | |
-} | |
- | |
- (void (^)(void))getActionCompletionHandler:(NSString *)key { | |
return _actionCompletionHandlers[key]; | |
} | |
@@ -59,12 +53,4 @@ - (void)completePresentation:(NSString *)completionKey withPresentationOptions:( | |
} | |
} | |
-- (void)completeBackgroundAction:(NSString *)completionKey withBackgroundFetchResult:(UIBackgroundFetchResult)backgroundFetchResult { | |
- void (^completionHandler)() = (void (^)(UIBackgroundFetchResult))[_backgroundActionCompletionHandlers valueForKey:completionKey]; | |
- if (completionHandler) { | |
- completionHandler(backgroundFetchResult); | |
- [_backgroundActionCompletionHandlers removeObjectForKey:completionKey]; | |
- } | |
-} | |
- | |
@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/Info.plist b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/Info.plist | |
new file mode 100644 | |
index 0000000..6c40a6c | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/Info.plist | |
@@ -0,0 +1,22 @@ | |
+<?xml version="1.0" encoding="UTF-8"?> | |
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
+<plist version="1.0"> | |
+<dict> | |
+ <key>CFBundleDevelopmentRegion</key> | |
+ <string>$(DEVELOPMENT_LANGUAGE)</string> | |
+ <key>CFBundleExecutable</key> | |
+ <string>$(EXECUTABLE_NAME)</string> | |
+ <key>CFBundleIdentifier</key> | |
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | |
+ <key>CFBundleInfoDictionaryVersion</key> | |
+ <string>6.0</string> | |
+ <key>CFBundleName</key> | |
+ <string>$(PRODUCT_NAME)</string> | |
+ <key>CFBundlePackageType</key> | |
+ <string>BNDL</string> | |
+ <key>CFBundleShortVersionString</key> | |
+ <string>1.0</string> | |
+ <key>CFBundleVersion</key> | |
+ <string>1</string> | |
+</dict> | |
+</plist> | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/Integration/RNBridgeModuleIntegrationTest.m b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/Integration/RNBridgeModuleIntegrationTest.m | |
new file mode 100644 | |
index 0000000..b76da81 | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/Integration/RNBridgeModuleIntegrationTest.m | |
@@ -0,0 +1,25 @@ | |
+#import <XCTest/XCTest.h> | |
+#import "RNBridgeModule.h" | |
+#import <OCMock/OCMock.h> | |
+ | |
+@interface RNBridgeModuleIntegrationTest : XCTestCase | |
+ | |
+@property (nonatomic, strong) RNBridgeModule* bridgeModule; | |
+ | |
+@end | |
+ | |
+@implementation RNBridgeModuleIntegrationTest | |
+ | |
+- (void)setUp { | |
+ | |
+} | |
+ | |
+- (void)tearDown { | |
+ | |
+} | |
+ | |
+- (void)testRequestPermissionsWithCategories { | |
+ | |
+} | |
+ | |
+@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationEventHandlerTests.m b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationEventHandlerTests.m | |
new file mode 100644 | |
index 0000000..919226f | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationEventHandlerTests.m | |
@@ -0,0 +1,116 @@ | |
+#import <XCTest/XCTest.h> | |
+#import <OCMock/OCMock.h> | |
+#import "RNNotificationEventHandler.h" | |
+#import "RNNotificationUtils.h" | |
+ | |
+@interface RNNotificationEventHandlerTests : XCTestCase | |
+@property (nonatomic, retain) RNNotificationEventHandler* uut; | |
+@property (nonatomic, retain) RNNotificationsStore* store; | |
+@property (nonatomic, retain) id mockedNotificationCenter; | |
+@end | |
+ | |
+@implementation RNNotificationEventHandlerTests | |
+ | |
+- (void)setUp { | |
+ _store = [RNNotificationsStore sharedInstance]; | |
+ _uut = [[RNNotificationEventHandler alloc] initWithStore:_store]; | |
+ | |
+ _mockedNotificationCenter = [OCMockObject partialMockForObject:[NSNotificationCenter new]]; | |
+ [[[[[OCMockObject niceMockForClass:NSNotificationCenter.class] stub] classMethod] andReturn:_mockedNotificationCenter] defaultCenter]; | |
+} | |
+ | |
+- (void)testDidRegisterForRemoteNotifications_ShouldEmitEventWithDeviceTokenDataString { | |
+ NSData* deviceToken = [@"740f4707 bebcf74f 9b7c25d4 8e335894 5f6aa01d a5ddb387 462c7eaf 61bb78ad" dataUsingEncoding:NSUTF32StringEncoding]; | |
+ [[_mockedNotificationCenter expect] postNotificationName:RNRegistered object:[OCMArg any] userInfo:[OCMArg checkWithBlock:^BOOL(id obj) { | |
+ return ([[obj objectForKey:@"deviceToken"] isEqualToString:[RNNotificationUtils deviceTokenToString:deviceToken]]); | |
+ }]]; | |
+ [_uut didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; | |
+ [_mockedNotificationCenter verify]; | |
+} | |
+ | |
+- (void)testDidRegisterForRemoteNotifications_ShouldEmitEventWithDeviceTokenString { | |
+ NSString* deviceToken = @"740f4707 bebcf74f 9b7c25d4 8e335894 5f6aa01d a5ddb387 462c7eaf 61bb78ad"; | |
+ [[_mockedNotificationCenter expect] postNotificationName:RNRegistered object:[OCMArg any] userInfo:[OCMArg checkWithBlock:^BOOL(id obj) { | |
+ return ([[obj objectForKey:@"deviceToken"] isEqualToString:deviceToken]); | |
+ }]]; | |
+ [_uut didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; | |
+ [_mockedNotificationCenter verify]; | |
+} | |
+ | |
+- (void)testDidFailToRegisterForRemoteNotifications_ShouldEmitEvent { | |
+ NSError* error = [NSError errorWithDomain:@"domain" code:1 userInfo:nil]; | |
+ [[_mockedNotificationCenter expect] postNotificationName:RNRegistrationFailed object:[OCMArg any] userInfo:[OCMArg checkWithBlock:^BOOL(id obj) { | |
+ return ([[obj valueForKey:@"code"] isEqualToNumber:@(1)] && | |
+ [[obj valueForKey:@"domain"] isEqualToString:@"domain"]); | |
+ }]]; | |
+ | |
+ [_uut didFailToRegisterForRemoteNotificationsWithError:error]; | |
+ [_mockedNotificationCenter verify]; | |
+} | |
+ | |
+- (void)testDidReceiveForegroundNotification_ShouldSaveCompletionBlockToStore { | |
+ UNNotification* notification = [self createNotificationWithIdentifier:@"id" andUserInfo:@{}]; | |
+ void (^testBlock)(UNNotificationPresentationOptions) = ^void(UNNotificationPresentationOptions options) {}; | |
+ | |
+ [_uut didReceiveForegroundNotification:notification withCompletionHandler:testBlock]; | |
+ XCTAssertEqual([_store getPresentationCompletionHandler:@"id"], testBlock); | |
+} | |
+ | |
+- (void)testDidReceiveForegroundNotification_ShouldEmitEvent { | |
+ UNNotification* notification = [self createNotificationWithIdentifier:@"id" andUserInfo:@{@"extraKey": @"extraValue"}]; | |
+ void (^testBlock)(UNNotificationPresentationOptions) = ^void(UNNotificationPresentationOptions options) {}; | |
+ | |
+ [[_mockedNotificationCenter expect] postNotificationName:RNNotificationReceived object:[OCMArg any] userInfo:[OCMArg checkWithBlock:^BOOL(id obj) { | |
+ return ([[obj valueForKey:@"identifier"] isEqualToString:@"id"] && | |
+ [[obj valueForKey:@"extraKey"] isEqualToString:@"extraValue"]); | |
+ }]]; | |
+ [_uut didReceiveForegroundNotification:notification withCompletionHandler:testBlock]; | |
+ [_mockedNotificationCenter verify]; | |
+} | |
+ | |
+- (void)testDidReceiveNotificationResponse_ShouldEmitEvent { | |
+ UNNotification* notification = [self createNotificationWithIdentifier:@"id" andUserInfo:@{@"extraKey": @"extraValue"}]; | |
+ UNNotificationResponse* response = [self createNotificationResponseWithIdentifier:@"actionId" andNotification:notification]; | |
+ void (^testBlock)(void) = ^void() {}; | |
+ | |
+ [[_mockedNotificationCenter expect] postNotificationName:RNNotificationOpened object:[OCMArg any] userInfo:[OCMArg checkWithBlock:^BOOL(id response) { | |
+ NSDictionary* notification = response[@"notification"]; | |
+ NSDictionary* action = response[@"action"]; | |
+ return ([[notification valueForKey:@"identifier"] isEqualToString:@"id"] && | |
+ [[notification valueForKey:@"extraKey"] isEqualToString:@"extraValue"] && [action[@"identifier"] isEqualToString:@"actionId"]); | |
+ }]]; | |
+ [_uut didReceiveNotificationResponse:response completionHandler:testBlock]; | |
+ [_mockedNotificationCenter verify]; | |
+} | |
+ | |
+- (void)testDidReceiveNotificationResponse_ShouldSaveCompletionBlockToStore { | |
+ UNNotification* notification = [self createNotificationWithIdentifier:@"id" andUserInfo:@{@"extraKey": @"extraValue"}]; | |
+ UNNotificationResponse* response = [self createNotificationResponseWithIdentifier:@"id" andNotification:notification]; | |
+ void (^testBlock)(void) = ^void() {}; | |
+ | |
+ [_uut didReceiveNotificationResponse:response completionHandler:testBlock]; | |
+ XCTAssertEqual([_store getActionCompletionHandler:@"id"], testBlock); | |
+} | |
+ | |
+- (UNNotification *)createNotificationWithIdentifier:(NSString *)identifier andUserInfo:(NSDictionary *)userInfo { | |
+ UNNotification* notification = [OCMockObject niceMockForClass:[UNNotification class]]; | |
+ UNNotificationContent* content = [OCMockObject niceMockForClass:[UNNotificationContent class]]; | |
+ OCMStub([content userInfo]).andReturn(userInfo); | |
+ UNNotificationRequest* request = [OCMockObject partialMockForObject:[UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil]]; | |
+ OCMStub(notification.request).andReturn(request); | |
+ OCMStub(request.content).andReturn(content); | |
+ | |
+ return notification; | |
+} | |
+ | |
+- (UNNotificationResponse *)createNotificationResponseWithIdentifier:(NSString *)identifier andNotification:(UNNotification *)notification { | |
+ UNNotificationResponse* notificationResponse = [OCMockObject niceMockForClass:[UNNotificationResponse class]]; | |
+ OCMStub(notificationResponse.actionIdentifier).andReturn(identifier); | |
+ OCMStub(notificationResponse.notification).andReturn(notification); | |
+ | |
+ return notificationResponse; | |
+} | |
+ | |
+ | |
+ | |
+@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationsStoreTests.m b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationsStoreTests.m | |
new file mode 100644 | |
index 0000000..a3ea4bb | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationsStoreTests.m | |
@@ -0,0 +1,69 @@ | |
+#import <XCTest/XCTest.h> | |
+#import <OCMock/OCMock.h> | |
+#import "RNNotificationsStore.h" | |
+ | |
+@interface RNNotificationsStoreTests : XCTestCase | |
+@property (nonatomic, retain) RNNotificationsStore* store; | |
+@end | |
+ | |
+@implementation RNNotificationsStoreTests | |
+ | |
+- (void)setUp { | |
+ _store = [RNNotificationsStore sharedInstance]; | |
+} | |
+ | |
+- (void)testSetActionCompletionHandler_ShouldStoreBlock { | |
+ void (^testBlock)(void) = ^void() {}; | |
+ [_store setActionCompletionHandler:testBlock withCompletionKey:@"actionTestBlock"]; | |
+ XCTAssertEqual(testBlock, [_store getActionCompletionHandler:@"actionTestBlock"]); | |
+} | |
+ | |
+- (void)testCompleteAction_ShouldInvokeBlock { | |
+ __block BOOL blockInvoked = NO; | |
+ void (^testBlock)(void) = ^void() { | |
+ blockInvoked = YES; | |
+ }; | |
+ [_store setActionCompletionHandler:testBlock withCompletionKey:@"actionTestBlock"]; | |
+ [_store completeAction:@"actionTestBlock"]; | |
+ XCTAssertTrue(blockInvoked); | |
+} | |
+ | |
+- (void)testCompleteAction_ShouldRemoveBlock { | |
+ __block BOOL blockInvoked = NO; | |
+ void (^testBlock)(void) = ^void() { | |
+ blockInvoked = YES; | |
+ }; | |
+ [_store setActionCompletionHandler:testBlock withCompletionKey:@"actionTestBlock"]; | |
+ [_store completeAction:@"actionTestBlock"]; | |
+ XCTAssertNil([_store getActionCompletionHandler:@"actionTestBlock"]); | |
+} | |
+ | |
+ | |
+- (void)testSetPersentationCompletionHandler_ShouldStoreBlock { | |
+ void (^testBlock)(UNNotificationPresentationOptions) = ^void(UNNotificationPresentationOptions options) {}; | |
+ [_store setPresentationCompletionHandler:testBlock withCompletionKey:@"presentationTestBlock"]; | |
+ XCTAssertEqual(testBlock, [_store getPresentationCompletionHandler:@"presentationTestBlock"]); | |
+} | |
+ | |
+- (void)testCompletePresentation_ShouldInvokeBlockWithParams { | |
+ __block UNNotificationPresentationOptions presentationOptions; | |
+ void (^testBlock)(UNNotificationPresentationOptions) = ^void(UNNotificationPresentationOptions options) { | |
+ presentationOptions = options; | |
+ }; | |
+ [_store setPresentationCompletionHandler:testBlock withCompletionKey:@"presentationTestBlock"]; | |
+ [_store completePresentation:@"presentationTestBlock" withPresentationOptions:UNNotificationPresentationOptionAlert]; | |
+ XCTAssertEqual(presentationOptions, UNNotificationPresentationOptionAlert); | |
+} | |
+ | |
+- (void)testCompletePresentation_ShouldRemoveBlock { | |
+ __block UNNotificationPresentationOptions presentationOptions; | |
+ void (^testBlock)(UNNotificationPresentationOptions) = ^void(UNNotificationPresentationOptions options) { | |
+ presentationOptions = options; | |
+ }; | |
+ [_store setPresentationCompletionHandler:testBlock withCompletionKey:@"presentationTestBlock"]; | |
+ [_store completePresentation:@"presentationTestBlock" withPresentationOptions:UNNotificationPresentationOptionAlert]; | |
+ XCTAssertNil([_store getPresentationCompletionHandler:@"presentationTestBlock"]); | |
+} | |
+ | |
+ | |
+@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationsTests.m b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationsTests.m | |
new file mode 100644 | |
index 0000000..bfb9fa6 | |
--- /dev/null | |
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsTests/RNNotificationsTests.m | |
@@ -0,0 +1,37 @@ | |
+// | |
+// RNNotificationsTests.m | |
+// RNNotificationsTests | |
+// | |
+// Created by Yogev Ben David on 06/07/2019. | |
+// Copyright © 2019 Facebook. All rights reserved. | |
+// | |
+ | |
+#import <XCTest/XCTest.h> | |
+ | |
+@interface RNNotificationsTests : XCTestCase | |
+ | |
+@end | |
+ | |
+@implementation RNNotificationsTests | |
+ | |
+- (void)setUp { | |
+ // Put setup code here. This method is called before the invocation of each test method in the class. | |
+} | |
+ | |
+- (void)tearDown { | |
+ // Put teardown code here. This method is called after the invocation of each test method in the class. | |
+} | |
+ | |
+- (void)testExample { | |
+ // This is an example of a functional test case. | |
+ // Use XCTAssert and related functions to verify your tests produce the correct results. | |
+} | |
+ | |
+- (void)testPerformanceExample { | |
+ // This is an example of a performance test case. | |
+ [self measureBlock:^{ | |
+ // Put the code you want to measure the time of here. | |
+ }]; | |
+} | |
+ | |
+@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.h b/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.h | |
index 5d72a2b..e627cd2 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.h | |
+++ b/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.h | |
@@ -3,10 +3,8 @@ | |
@interface RNPushKitEventHandler : RNNotificationEventHandler | |
-- (instancetype)initWithStore:(RNNotificationsStore *)store; | |
- | |
- (void)registeredWithToken:(NSString *)token; | |
-- (void)didReceiveIncomingPushWithPayload:(NSDictionary *)payload withCompletionHandler:(void (^)(void))completion; | |
+- (void)didReceiveIncomingPushWithPayload:(NSDictionary *)payload; | |
@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.m b/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.m | |
index 94fa99b..2e2c99e 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNPushKitEventHandler.m | |
@@ -1,28 +1,14 @@ | |
#import "RNPushKitEventHandler.h" | |
#import "RNEventEmitter.h" | |
-@implementation RNPushKitEventHandler { | |
- RNNotificationsStore* _store; | |
-} | |
- | |
-- (instancetype)initWithStore:(RNNotificationsStore *)store { | |
- self = [super init]; | |
- _store = store; | |
- return self; | |
-} | |
+@implementation RNPushKitEventHandler | |
- (void)registeredWithToken:(NSString *)token { | |
[RNEventEmitter sendEvent:RNPushKitRegistered body:@{@"pushKitToken": token}]; | |
} | |
-- (void)didReceiveIncomingPushWithPayload:(NSDictionary *)payload withCompletionHandler:(void (^)(void))completionHandler { | |
- NSString *identifier = [[NSUUID UUID] UUIDString]; | |
- | |
- NSMutableDictionary *notification = [payload mutableCopy]; | |
- notification[@"identifier"] = identifier; | |
- | |
- [_store setActionCompletionHandler:completionHandler withCompletionKey:identifier]; | |
- [RNEventEmitter sendEvent:RNPushKitNotificationReceived body:payload]; | |
+- (void)didReceiveIncomingPushWithPayload:(NSDictionary *)payload { | |
+ [RNEventEmitter sendEvent:RNPushKitNotificationReceived body:payload]; | |
} | |
@end | |
diff --git a/node_modules/react-native-notifications/lib/ios/RNPushKitEventListener.m b/node_modules/react-native-notifications/lib/ios/RNPushKitEventListener.m | |
index f3d8936..88d7a88 100644 | |
--- a/node_modules/react-native-notifications/lib/ios/RNPushKitEventListener.m | |
+++ b/node_modules/react-native-notifications/lib/ios/RNPushKitEventListener.m | |
@@ -19,10 +19,8 @@ - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPush | |
[_pushKitEventHandler registeredWithToken:[RNNotificationUtils deviceTokenToString:credentials.token]]; | |
} | |
-- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload | |
- forType:(PKPushType)type | |
- withCompletionHandler:(void (^)(void))completionHandler { | |
- [_pushKitEventHandler didReceiveIncomingPushWithPayload:payload.dictionaryPayload withCompletionHandler:completionHandler]; | |
+- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type { | |
+ [_pushKitEventHandler didReceiveIncomingPushWithPayload:payload.dictionaryPayload]; | |
} | |
@end | |
diff --git a/node_modules/react-native-notifications/lib/src/DTO/Notification.ts b/node_modules/react-native-notifications/lib/src/DTO/Notification.ts | |
index 4111689..9e656ca 100644 | |
--- a/node_modules/react-native-notifications/lib/src/DTO/Notification.ts | |
+++ b/node_modules/react-native-notifications/lib/src/DTO/Notification.ts | |
@@ -30,4 +30,8 @@ export class Notification { | |
get thread(): string { | |
return this.payload.thread; | |
} | |
+ | |
+ get fireDate(): number { | |
+ return this.payload.fireDate || 0 | |
+ } | |
} | |
diff --git a/node_modules/react-native-notifications/lib/src/Notifications.ts b/node_modules/react-native-notifications/lib/src/Notifications.ts | |
index 44956df..738debc 100644 | |
--- a/node_modules/react-native-notifications/lib/src/Notifications.ts | |
+++ b/node_modules/react-native-notifications/lib/src/Notifications.ts | |
@@ -37,7 +37,7 @@ export class NotificationsRoot { | |
this.notificationFactory | |
); | |
this.eventsRegistry = new EventsRegistry(this.nativeEventsReceiver, this.completionCallbackWrapper); | |
- this.eventsRegistryIOS = new EventsRegistryIOS(this.nativeEventsReceiver, this.completionCallbackWrapper); | |
+ this.eventsRegistryIOS = new EventsRegistryIOS(this.nativeEventsReceiver); | |
this._ios = new NotificationsIOS(this.commands, this.eventsRegistryIOS); | |
this._android = new NotificationsAndroid(this.commands); | |
@@ -75,10 +75,14 @@ export class NotificationsRoot { | |
/** | |
* cancelLocalNotification | |
*/ | |
- public cancelLocalNotification(notificationId: string) { | |
+ public cancelLocalNotification(notificationId: number) { | |
return this.commands.cancelLocalNotification(notificationId); | |
} | |
+ public cancelAllLocalNotifications() { | |
+ this.commands.cancelAllLocalNotifications(); | |
+ } | |
+ | |
/** | |
* removeAllDeliveredNotifications | |
*/ | |
diff --git a/node_modules/react-native-notifications/lib/src/adapters/CompletionCallbackWrapper.ts b/node_modules/react-native-notifications/lib/src/adapters/CompletionCallbackWrapper.ts | |
index 92e5aea..2fff368 100644 | |
--- a/node_modules/react-native-notifications/lib/src/adapters/CompletionCallbackWrapper.ts | |
+++ b/node_modules/react-native-notifications/lib/src/adapters/CompletionCallbackWrapper.ts | |
@@ -1,6 +1,6 @@ | |
import { NativeCommandsSender } from './NativeCommandsSender'; | |
-import { NotificationCompletion, NotificationBackgroundFetchResult } from '../interfaces/NotificationCompletion'; | |
-import { Platform } from 'react-native'; | |
+import { NotificationCompletion } from '../interfaces/NotificationCompletion'; | |
+import { Platform, AppState } from 'react-native'; | |
import {NotificationIOS} from "../DTO/NotificationIOS"; | |
import {Notification} from ".."; | |
import { NotificationActionResponse } from '../interfaces/NotificationActionResponse'; | |
@@ -12,40 +12,43 @@ export class CompletionCallbackWrapper { | |
public wrapReceivedBackgroundCallback(callback: Function): (notification: Notification) => void { | |
return (notification) => { | |
- this.wrapReceivedAndInvoke(callback, notification, true); | |
+ if (!this.applicationIsVisible()) { | |
+ this.wrapReceivedAndInvoke(callback, notification); | |
+ } | |
} | |
} | |
public wrapReceivedForegroundCallback(callback: Function): (notification: Notification) => void { | |
return (notification) => { | |
- this.wrapReceivedAndInvoke(callback, notification, false); | |
+ if (this.applicationIsVisible()) { | |
+ this.wrapReceivedAndInvoke(callback, notification); | |
+ } | |
} | |
} | |
- private wrapReceivedAndInvoke(callback: Function, notification: Notification, background: boolean) { | |
- const completion = (response: NotificationCompletion | NotificationBackgroundFetchResult) => { | |
+ private wrapReceivedAndInvoke(callback: Function, notification: Notification) { | |
+ const completion = (response: NotificationCompletion) => { | |
if (Platform.OS === 'ios') { | |
- const identifier = (notification as unknown as NotificationIOS).identifier; | |
- if (background) { | |
- this.nativeCommandsSender.finishHandlingBackgroundAction(identifier, response as NotificationBackgroundFetchResult); | |
- } else { | |
- this.nativeCommandsSender.finishPresentingNotification(identifier, response as NotificationCompletion); | |
- } | |
+ this.nativeCommandsSender.finishPresentingNotification((notification as unknown as NotificationIOS).identifier, response); | |
} | |
}; | |
callback(notification, completion); | |
} | |
- public wrapOpenedCallback(callback: Function): (notification: object, actionResponse?: NotificationActionResponse) => void { | |
- return (notification, actionResponse) => { | |
+ public wrapOpenedCallback(callback: Function): (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void { | |
+ return (notification, _completion, actionResponse) => { | |
const completion = () => { | |
if (Platform.OS === 'ios') { | |
- this.nativeCommandsSender.finishHandlingAction((notification as NotificationIOS).identifier); | |
+ this.nativeCommandsSender.finishHandlingAction((notification as unknown as NotificationIOS).identifier); | |
} | |
}; | |
callback(notification, completion, actionResponse); | |
} | |
} | |
+ | |
+ private applicationIsVisible(): Boolean { | |
+ return AppState.currentState !== 'background'; | |
+ } | |
} | |
diff --git a/node_modules/react-native-notifications/lib/src/adapters/NativeCommandsSender.ts b/node_modules/react-native-notifications/lib/src/adapters/NativeCommandsSender.ts | |
index 9c6da11..e8bc5c5 100644 | |
--- a/node_modules/react-native-notifications/lib/src/adapters/NativeCommandsSender.ts | |
+++ b/node_modules/react-native-notifications/lib/src/adapters/NativeCommandsSender.ts | |
@@ -14,7 +14,7 @@ interface NativeCommandsModule { | |
registerPushKit(): void; | |
getBadgeCount(): Promise<number>; | |
setBadgeCount(count: number): void; | |
- cancelLocalNotification(notificationId: string): void; | |
+ cancelLocalNotification(notificationId: number): void; | |
cancelAllLocalNotifications(): void; | |
isRegisteredForRemoteNotifications(): Promise<boolean>; | |
checkPermissions(): Promise<NotificationPermissions>; | |
@@ -25,7 +25,6 @@ interface NativeCommandsModule { | |
finishPresentingNotification(notificationId: string, callback: NotificationCompletion): void; | |
finishHandlingAction(notificationId: string): void; | |
setNotificationChannel(notificationChannel: NotificationChannel): void; | |
- finishHandlingBackgroundAction(notificationId: string, backgroundFetchResult: string): void; | |
} | |
export class NativeCommandsSender { | |
@@ -70,7 +69,7 @@ export class NativeCommandsSender { | |
this.nativeCommandsModule.setBadgeCount(count); | |
} | |
- cancelLocalNotification(notificationId: string) { | |
+ cancelLocalNotification(notificationId: number) { | |
this.nativeCommandsModule.cancelLocalNotification(notificationId); | |
} | |
@@ -109,8 +108,4 @@ export class NativeCommandsSender { | |
setNotificationChannel(notificationChannel: NotificationChannel) { | |
this.nativeCommandsModule.setNotificationChannel(notificationChannel); | |
} | |
- | |
- finishHandlingBackgroundAction(notificationId: string, backgroundFetchResult: string): void { | |
- this.nativeCommandsModule.finishHandlingBackgroundAction(notificationId, backgroundFetchResult); | |
- } | |
} | |
diff --git a/node_modules/react-native-notifications/lib/src/adapters/NativeEventsReceiver.ts b/node_modules/react-native-notifications/lib/src/adapters/NativeEventsReceiver.ts | |
index ec00497..a7109e6 100644 | |
--- a/node_modules/react-native-notifications/lib/src/adapters/NativeEventsReceiver.ts | |
+++ b/node_modules/react-native-notifications/lib/src/adapters/NativeEventsReceiver.ts | |
@@ -1,6 +1,6 @@ | |
import { NativeModules, NativeEventEmitter, EventEmitter, EmitterSubscription } from 'react-native'; | |
import { | |
- Registered, RegistrationError, RegisteredPushKit, NotificationResponse | |
+ Registered, RegistrationError, RegisteredPushKit | |
} from '../interfaces/NotificationEvents'; | |
import { Notification } from '../DTO/Notification'; | |
import { NotificationActionResponse } from '../interfaces/NotificationActionResponse'; | |
@@ -26,20 +26,14 @@ export class NativeEventsReceiver { | |
}); | |
} | |
- public registerNotificationReceivedBackground(callback: (notification: Notification) => void): EmitterSubscription { | |
- return this.emitter.addListener('notificationReceivedBackground', (payload) => { | |
- callback(this.notificationFactory.fromPayload(payload)); | |
- }); | |
- } | |
- | |
public registerPushKitNotificationReceived(callback: (event: object) => void): EmitterSubscription { | |
return this.emitter.addListener('pushKitNotificationReceived', callback); | |
} | |
- public registerNotificationOpened(callback: (notification: Notification, actionResponse?: NotificationActionResponse) => void): EmitterSubscription { | |
- return this.emitter.addListener('notificationOpened', (response: NotificationResponse) => { | |
- const action = response.action ? new NotificationActionResponse(response.action) : undefined; | |
- callback(this.notificationFactory.fromPayload(response.notification), action); | |
+ public registerNotificationOpened(callback: (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void): EmitterSubscription { | |
+ return this.emitter.addListener('notificationOpened', (response, completion) => { | |
+ const action = response.action ? new NotificationActionResponse(response.action) : undefined | |
+ callback(this.notificationFactory.fromPayload(response.notification), completion, action); | |
}); | |
} | |
diff --git a/node_modules/react-native-notifications/lib/src/commands/Commands.test.ts b/node_modules/react-native-notifications/lib/src/commands/Commands.test.ts | |
index a80d0ca..3f9e190 100644 | |
--- a/node_modules/react-native-notifications/lib/src/commands/Commands.test.ts | |
+++ b/node_modules/react-native-notifications/lib/src/commands/Commands.test.ts | |
@@ -8,9 +8,9 @@ import { UniqueIdProvider } from '../adapters/UniqueIdProvider'; | |
import { NotificationCategory } from '../interfaces/NotificationCategory'; | |
import { NotificationPermissions } from '../interfaces/NotificationPermissions'; | |
import { NotificationFactory } from '../DTO/NotificationFactory'; | |
-import {NotificationAndroid} from "../DTO/NotificationAndroid"; | |
-import {Platform} from "react-native"; | |
-import {NotificationIOS} from "../DTO/NotificationIOS"; | |
+import { NotificationAndroid } from "../DTO/NotificationAndroid"; | |
+import { Platform } from "react-native"; | |
+import { NotificationIOS } from "../DTO/NotificationIOS"; | |
describe('Commands', () => { | |
let uut: Commands; | |
@@ -38,9 +38,9 @@ describe('Commands', () => { | |
it('Android - returns a promise with the initial notification', async () => { | |
Platform.OS = 'android'; | |
- const expectedNotification: Notification = new NotificationAndroid({'google.message_id': 'id'}); | |
+ const expectedNotification: Notification = new NotificationAndroid({ 'google.message_id': 'id' }); | |
when(mockedNativeCommandsSender.getInitialNotification()).thenResolve( | |
- {'google.message_id': 'id'} | |
+ { 'google.message_id': 'id' } | |
); | |
const result = await uut.getInitialNotification(); | |
expect(result).toEqual(expectedNotification); | |
@@ -55,9 +55,9 @@ describe('Commands', () => { | |
it('iOS - returns a promise with the initial notification', async () => { | |
Platform.OS = 'ios'; | |
- const expectedNotification: Notification = new NotificationIOS({identifier: 'id'}); | |
+ const expectedNotification: Notification = new NotificationIOS({ identifier: 'id' }); | |
when(mockedNativeCommandsSender.getInitialNotification()).thenResolve( | |
- {identifier: 'id'} | |
+ { identifier: 'id' } | |
); | |
const result = await uut.getInitialNotification(); | |
expect(result).toEqual(expectedNotification); | |
@@ -86,7 +86,7 @@ describe('Commands', () => { | |
}); | |
it('sends to native with categories', () => { | |
- const category: NotificationCategory = {identifier: 'id', actions: []}; | |
+ const category: NotificationCategory = { identifier: 'id', actions: [] }; | |
const categoriesArray: [NotificationCategory] = [category]; | |
uut.setCategories(categoriesArray); | |
verify(mockedNativeCommandsSender.setCategories(categoriesArray)).called(); | |
@@ -102,26 +102,26 @@ describe('Commands', () => { | |
describe('postLocalNotification', () => { | |
it('sends to native', () => { | |
- const notification: Notification = new Notification({identifier: 'id'}); | |
+ const notification: Notification = new Notification({ identifier: 'id' }); | |
uut.postLocalNotification(notification); | |
verify(mockedNativeCommandsSender.postLocalNotification(notification, anyNumber())).called(); | |
}); | |
it('generates unique identifier', () => { | |
- const notification: Notification = new Notification({identifier: 'id'}); | |
+ const notification: Notification = new Notification({ identifier: 'id' }); | |
uut.postLocalNotification(notification); | |
verify(mockedNativeCommandsSender.postLocalNotification(notification, anyNumber())).called(); | |
}); | |
it('use passed notification id', () => { | |
- const notification: Notification = new Notification({identifier: 'id'}); | |
+ const notification: Notification = new Notification({ identifier: 'id' }); | |
const passedId: number = 2; | |
uut.postLocalNotification(notification, passedId); | |
verify(mockedNativeCommandsSender.postLocalNotification(notification, passedId)).called(); | |
}); | |
it('return notification id', () => { | |
- const notification: Notification = new Notification({identifier: 'id'}); | |
+ const notification: Notification = new Notification({ identifier: 'id' }); | |
const notificationId: number = 2; | |
const response = uut.postLocalNotification(notification, notificationId); | |
expect(response).toEqual(notificationId); | |
@@ -144,8 +144,8 @@ describe('Commands', () => { | |
describe('cancelLocalNotification', () => { | |
it('sends to native', () => { | |
- uut.cancelLocalNotification("notificationId"); | |
- verify(mockedNativeCommandsSender.cancelLocalNotification("notificationId")).called(); | |
+ uut.cancelLocalNotification(1); | |
+ verify(mockedNativeCommandsSender.cancelLocalNotification(1)).called(); | |
}); | |
}); | |
@@ -187,7 +187,7 @@ describe('Commands', () => { | |
}); | |
it('return negative response from native', async () => { | |
- const expectedPermissions: NotificationPermissions = {badge: false, alert: true, sound: false}; | |
+ const expectedPermissions: NotificationPermissions = { badge: false, alert: true, sound: false }; | |
when(mockedNativeCommandsSender.checkPermissions()).thenResolve( | |
expectedPermissions | |
); | |
diff --git a/node_modules/react-native-notifications/lib/src/commands/Commands.ts b/node_modules/react-native-notifications/lib/src/commands/Commands.ts | |
index 46fb267..f32f071 100644 | |
--- a/node_modules/react-native-notifications/lib/src/commands/Commands.ts | |
+++ b/node_modules/react-native-notifications/lib/src/commands/Commands.ts | |
@@ -56,7 +56,7 @@ export class Commands { | |
this.nativeCommandsSender.setBadgeCount(count); | |
} | |
- public cancelLocalNotification(notificationId: string) { | |
+ public cancelLocalNotification(notificationId: number) { | |
this.nativeCommandsSender.cancelLocalNotification(notificationId); | |
} | |
diff --git a/node_modules/react-native-notifications/lib/src/events/EventsRegistry.test.ts b/node_modules/react-native-notifications/lib/src/events/EventsRegistry.test.ts | |
index 8320e41..a4e5b22 100644 | |
--- a/node_modules/react-native-notifications/lib/src/events/EventsRegistry.test.ts | |
+++ b/node_modules/react-native-notifications/lib/src/events/EventsRegistry.test.ts | |
@@ -5,7 +5,7 @@ import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper | |
import { NativeCommandsSender } from '../adapters/NativeCommandsSender.mock'; | |
import { NotificationResponse } from '../interfaces/NotificationEvents'; | |
import { Platform, AppState } from 'react-native'; | |
-import { NotificationCompletion, NotificationBackgroundFetchResult } from '../interfaces/NotificationCompletion'; | |
+import { NotificationCompletion } from '../interfaces/NotificationCompletion'; | |
describe('EventsRegistry', () => { | |
let uut: EventsRegistry; | |
@@ -91,8 +91,8 @@ describe('EventsRegistry', () => { | |
uut.registerNotificationReceivedBackground(cb); | |
- expect(mockNativeEventsReceiver.registerNotificationReceivedBackground).toHaveBeenCalledTimes(1); | |
- expect(mockNativeEventsReceiver.registerNotificationReceivedBackground).toHaveBeenCalledWith(expect.any(Function)); | |
+ expect(mockNativeEventsReceiver.registerNotificationReceived).toHaveBeenCalledTimes(1); | |
+ expect(mockNativeEventsReceiver.registerNotificationReceived).toHaveBeenCalledWith(expect.any(Function)); | |
}); | |
it('should wrap callback with completion block', () => { | |
@@ -100,7 +100,7 @@ describe('EventsRegistry', () => { | |
const notification: Notification = new Notification({identifier: 'identifier'}); | |
uut.registerNotificationReceivedBackground(wrappedCallback); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(notification); | |
expect(wrappedCallback).toBeCalledWith(notification, expect.any(Function)); | |
@@ -113,34 +113,34 @@ describe('EventsRegistry', () => { | |
uut.registerNotificationReceivedBackground((notification) => { | |
expect(notification).toEqual(expectedNotification); | |
}); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(expectedNotification); | |
}); | |
- it('should invoke finishHandlingBackgroundAction', () => { | |
+ it('should invoke finishPresentingNotification', () => { | |
const notification: Notification = new Notification({identifier: 'notificationId'}); | |
- const response = NotificationBackgroundFetchResult.NO_DATA; | |
+ const response: NotificationCompletion = {alert: true} | |
uut.registerNotificationReceivedBackground((notification, completion) => { | |
completion(response); | |
- expect(mockNativeCommandsSender.finishHandlingBackgroundAction).toBeCalledWith(notification.identifier, response); | |
+ expect(mockNativeCommandsSender.finishPresentingNotification).toBeCalledWith(notification.identifier, response); | |
}); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(notification); | |
}); | |
- it('should not invoke finishHandlingBackgroundAction on Android', () => { | |
+ it('should not invoke finishPresentingNotification on Android', () => { | |
Platform.OS = 'android'; | |
const expectedNotification: Notification = new Notification({identifier: 'notificationId'}); | |
- const response = NotificationBackgroundFetchResult.NO_DATA; | |
+ const response: NotificationCompletion = {alert: true} | |
uut.registerNotificationReceivedBackground((notification, completion) => { | |
completion(response); | |
expect(expectedNotification).toEqual(notification); | |
- expect(mockNativeCommandsSender.finishHandlingBackgroundAction).toBeCalledTimes(0); | |
+ expect(mockNativeCommandsSender.finishPresentingNotification).toBeCalledTimes(0); | |
}); | |
- const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0]; | |
+ const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0]; | |
call(expectedNotification); | |
}); | |
}); | |
@@ -158,17 +158,13 @@ describe('EventsRegistry', () => { | |
it('should wrap callback with completion block', () => { | |
const wrappedCallback = jest.fn(); | |
const notification: Notification = new Notification({identifier: 'identifier'}); | |
- const response: NotificationResponse = { | |
- notification, | |
- identifier: 'responseId', | |
- action: { identifier: 'actionIdentifier', text: 'userText' }, | |
- }; | |
+ const response: NotificationResponse = {notification, identifier: 'responseId'}; | |
uut.registerNotificationOpened(wrappedCallback); | |
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0]; | |
- call(response.notification, response.action); | |
+ call(response); | |
- expect(wrappedCallback).toBeCalledWith(response.notification, expect.any(Function), response.action); | |
+ expect(wrappedCallback).toBeCalledWith(response, expect.any(Function), undefined); //JMC: ActionResponse | |
expect(wrappedCallback).toBeCalledTimes(1); | |
}); | |
diff --git a/node_modules/react-native-notifications/lib/src/events/EventsRegistry.ts b/node_modules/react-native-notifications/lib/src/events/EventsRegistry.ts | |
index a62af18..158bb61 100644 | |
--- a/node_modules/react-native-notifications/lib/src/events/EventsRegistry.ts | |
+++ b/node_modules/react-native-notifications/lib/src/events/EventsRegistry.ts | |
@@ -7,7 +7,7 @@ import { | |
import { NotificationActionResponse } from '../interfaces/NotificationActionResponse'; | |
import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper'; | |
import { Notification } from '../DTO/Notification'; | |
-import { NotificationCompletion, NotificationBackgroundFetchResult } from '../interfaces/NotificationCompletion'; | |
+import { NotificationCompletion } from '../interfaces/NotificationCompletion'; | |
export class EventsRegistry { | |
constructor( | |
@@ -23,8 +23,8 @@ export class EventsRegistry { | |
return this.nativeEventsReceiver.registerNotificationReceived(this.completionCallbackWrapper.wrapReceivedForegroundCallback(callback)); | |
} | |
- public registerNotificationReceivedBackground(callback: (notification: Notification, completion: (response: NotificationBackgroundFetchResult) => void) => void): EmitterSubscription { | |
- return this.nativeEventsReceiver.registerNotificationReceivedBackground(this.completionCallbackWrapper.wrapReceivedBackgroundCallback(callback)); | |
+ public registerNotificationReceivedBackground(callback: (notification: Notification, completion: (response: NotificationCompletion) => void) => void): EmitterSubscription { | |
+ return this.nativeEventsReceiver.registerNotificationReceived(this.completionCallbackWrapper.wrapReceivedBackgroundCallback(callback)); | |
} | |
public registerNotificationOpened(callback: (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void): EmitterSubscription { | |
diff --git a/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.test.ts b/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.test.ts | |
index 44a6a06..51be841 100644 | |
--- a/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.test.ts | |
+++ b/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.test.ts | |
@@ -1,16 +1,12 @@ | |
import { EventsRegistryIOS } from './EventsRegistryIOS'; | |
-import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper'; | |
-import { NativeCommandsSender } from '../adapters/NativeCommandsSender.mock'; | |
import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver.mock'; | |
describe('EventsRegistryIOS', () => { | |
let uut: EventsRegistryIOS; | |
const mockNativeEventsReceiver = new NativeEventsReceiver(); | |
- const mockNativeCommandsSender = new NativeCommandsSender(); | |
- const completionCallbackWrapper = new CompletionCallbackWrapper(mockNativeCommandsSender); | |
beforeEach(() => { | |
- uut = new EventsRegistryIOS(mockNativeEventsReceiver, completionCallbackWrapper); | |
+ uut = new EventsRegistryIOS(mockNativeEventsReceiver); | |
}); | |
it('delegates registerPushKitRegistered to nativeEventsReceiver', () => { | |
@@ -23,37 +19,7 @@ describe('EventsRegistryIOS', () => { | |
it('delegates registerPushKitNotificationReceived to nativeEventsReceiver', () => { | |
const cb = jest.fn(); | |
uut.registerPushKitNotificationReceived(cb); | |
- | |
expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledTimes(1); | |
- expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledWith(expect.any(Function)); | |
- | |
- }); | |
- | |
- it('should wrap callback with completion block', () => { | |
- const expectedNotification = { identifier: 'notificationId' } | |
- | |
- uut.registerPushKitNotificationReceived((notification) => { | |
- expect(notification).toEqual(expectedNotification); | |
- }); | |
- | |
- const call = mockNativeEventsReceiver.registerPushKitNotificationReceived.mock.calls[0][0]; | |
- | |
- call(expectedNotification); | |
- }); | |
- | |
- it('should invoke finishPresentingNotification', () => { | |
- const expectedNotification = { identifier: 'notificationId' }; | |
- | |
- uut.registerPushKitNotificationReceived((notification, completion) => { | |
- completion(); | |
- | |
- expect(notification).toEqual(expectedNotification); | |
- | |
- expect(mockNativeCommandsSender.finishHandlingAction).toBeCalledWith('notificationId'); | |
- }); | |
- | |
- const call = mockNativeEventsReceiver.registerPushKitNotificationReceived.mock.calls[0][0]; | |
- | |
- call(expectedNotification); | |
+ expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledWith(cb); | |
}); | |
}); | |
diff --git a/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.ts b/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.ts | |
index c3f7c52..4ea49fe 100644 | |
--- a/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.ts | |
+++ b/node_modules/react-native-notifications/lib/src/events/EventsRegistryIOS.ts | |
@@ -3,19 +3,17 @@ import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver'; | |
import { | |
RegisteredPushKit | |
} from '../interfaces/NotificationEvents'; | |
-import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper'; | |
export class EventsRegistryIOS { | |
constructor( | |
- private nativeEventsReceiver: NativeEventsReceiver, | |
- private completionCallbackWrapper: CompletionCallbackWrapper) | |
+ private nativeEventsReceiver: NativeEventsReceiver) | |
{} | |
public registerPushKitRegistered(callback: (event: RegisteredPushKit) => void): EmitterSubscription { | |
return this.nativeEventsReceiver.registerPushKitRegistered(callback); | |
} | |
- public registerPushKitNotificationReceived(callback: (event: object, completion: () => void) => void): EmitterSubscription { | |
- return this.nativeEventsReceiver.registerPushKitNotificationReceived(this.completionCallbackWrapper.wrapOpenedCallback(callback)); | |
+ public registerPushKitNotificationReceived(callback: (event: object) => void): EmitterSubscription { | |
+ return this.nativeEventsReceiver.registerPushKitNotificationReceived(callback); | |
} | |
} | |
diff --git a/node_modules/react-native-notifications/lib/src/index.ts b/node_modules/react-native-notifications/lib/src/index.ts | |
index 8d794eb..583fe0c 100644 | |
--- a/node_modules/react-native-notifications/lib/src/index.ts | |
+++ b/node_modules/react-native-notifications/lib/src/index.ts | |
@@ -1,4 +1,5 @@ | |
import { NotificationsRoot } from './Notifications'; | |
+ | |
const notificationsSingleton = new NotificationsRoot(); | |
export const Notifications = notificationsSingleton; | |
@@ -6,4 +7,3 @@ export * from './interfaces/EventSubscription'; | |
export * from './DTO/Notification'; | |
export * from './interfaces/NotificationEvents'; | |
export * from './interfaces/NotificationCategory'; | |
-export * from './interfaces/NotificationCompletion'; | |
diff --git a/node_modules/react-native-notifications/lib/src/interfaces/NotificationCompletion.ts b/node_modules/react-native-notifications/lib/src/interfaces/NotificationCompletion.ts | |
index 17df69d..e34fcfd 100644 | |
--- a/node_modules/react-native-notifications/lib/src/interfaces/NotificationCompletion.ts | |
+++ b/node_modules/react-native-notifications/lib/src/interfaces/NotificationCompletion.ts | |
@@ -3,9 +3,3 @@ export interface NotificationCompletion { | |
alert?: boolean; | |
sound?: boolean; | |
} | |
- | |
-export enum NotificationBackgroundFetchResult { | |
- NEW_DATA = "newData", | |
- NO_DATA = "noData", | |
- FAILED = "failed", | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This patch requires
fireDate
to be number. For example for future data: