@imatis/react-native-notifications 4.3.1-imatis.23 → 4.3.1-imatis.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/JsIOHelper.java +4 -0
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +17 -3
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationProps.java +8 -0
- package/package.json +1 -1
- package/react-native.config.js +0 -1
- package/lib/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
- package/lib/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/lib/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
- package/lib/android/.gradle/6.1.1/fileContent/fileContent.lock +0 -0
- package/lib/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
- package/lib/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/lib/android/.gradle/6.1.1/fileHashes/resourceHashesCache.bin +0 -0
- package/lib/android/.gradle/6.1.1/gc.properties +0 -0
- package/lib/android/.gradle/6.1.1/javaCompile/classAnalysis.bin +0 -0
- package/lib/android/.gradle/6.1.1/javaCompile/jarAnalysis.bin +0 -0
- package/lib/android/.gradle/6.1.1/javaCompile/javaCompile.lock +0 -0
- package/lib/android/.gradle/6.1.1/javaCompile/taskHistory.bin +0 -0
- package/lib/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/lib/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/lib/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/lib/android/.gradle/checksums/checksums.lock +0 -0
- package/lib/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/lib/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/lib/android/.gradle/vcs-1/gc.properties +0 -0
- package/lib/android/local.properties +0 -8
- package/lib/dist/DTO/Notification.d.ts +0 -11
- package/lib/dist/DTO/Notification.js +0 -28
- package/lib/dist/DTO/Notification.test.d.ts +0 -1
- package/lib/dist/DTO/Notification.test.js +0 -52
- package/lib/dist/DTO/NotificationAndroid.d.ts +0 -7
- package/lib/dist/DTO/NotificationAndroid.js +0 -20
- package/lib/dist/DTO/NotificationAndroid.test.d.ts +0 -1
- package/lib/dist/DTO/NotificationAndroid.test.js +0 -25
- package/lib/dist/DTO/NotificationFactory.d.ts +0 -4
- package/lib/dist/DTO/NotificationFactory.js +0 -18
- package/lib/dist/DTO/NotificationIOS.d.ts +0 -12
- package/lib/dist/DTO/NotificationIOS.js +0 -40
- package/lib/dist/DTO/NotificationIOS.test.d.ts +0 -1
- package/lib/dist/DTO/NotificationIOS.test.js +0 -58
- package/lib/dist/Notifications.d.ts +0 -65
- package/lib/dist/Notifications.js +0 -98
- package/lib/dist/NotificationsAndroid.d.ts +0 -14
- package/lib/dist/NotificationsAndroid.js +0 -32
- package/lib/dist/NotificationsIOS.d.ts +0 -51
- package/lib/dist/NotificationsIOS.js +0 -83
- package/lib/dist/adapters/CompletionCallbackWrapper.d.ts +0 -11
- package/lib/dist/adapters/CompletionCallbackWrapper.js +0 -44
- package/lib/dist/adapters/NativeCommandsSender.d.ts +0 -31
- package/lib/dist/adapters/NativeCommandsSender.js +0 -73
- package/lib/dist/adapters/NativeCommandsSender.mock.d.ts +0 -1
- package/lib/dist/adapters/NativeCommandsSender.mock.js +0 -4
- package/lib/dist/adapters/NativeEventsReceiver.d.ts +0 -19
- package/lib/dist/adapters/NativeEventsReceiver.js +0 -46
- package/lib/dist/adapters/NativeEventsReceiver.mock.d.ts +0 -1
- package/lib/dist/adapters/NativeEventsReceiver.mock.js +0 -4
- package/lib/dist/adapters/UniqueIdProvider.d.ts +0 -3
- package/lib/dist/adapters/UniqueIdProvider.js +0 -10
- package/lib/dist/commands/Commands.d.ts +0 -32
- package/lib/dist/commands/Commands.js +0 -79
- package/lib/dist/commands/Commands.test.d.ts +0 -1
- package/lib/dist/commands/Commands.test.js +0 -201
- package/lib/dist/events/EventsRegistry.d.ts +0 -18
- package/lib/dist/events/EventsRegistry.js +0 -28
- package/lib/dist/events/EventsRegistry.test.d.ts +0 -1
- package/lib/dist/events/EventsRegistry.test.js +0 -182
- package/lib/dist/events/EventsRegistryIOS.d.ts +0 -12
- package/lib/dist/events/EventsRegistryIOS.js +0 -19
- package/lib/dist/events/EventsRegistryIOS.test.d.ts +0 -1
- package/lib/dist/events/EventsRegistryIOS.test.js +0 -51
- package/lib/dist/index.d.ts +0 -7
- package/lib/dist/index.js +0 -12
- package/lib/dist/interfaces/EventSubscription.d.ts +0 -3
- package/lib/dist/interfaces/EventSubscription.js +0 -2
- package/lib/dist/interfaces/NotificationActionResponse.d.ts +0 -5
- package/lib/dist/interfaces/NotificationActionResponse.js +0 -10
- package/lib/dist/interfaces/NotificationCategory.d.ts +0 -18
- package/lib/dist/interfaces/NotificationCategory.js +0 -20
- package/lib/dist/interfaces/NotificationChannel.d.ts +0 -14
- package/lib/dist/interfaces/NotificationChannel.js +0 -2
- package/lib/dist/interfaces/NotificationCompletion.d.ts +0 -10
- package/lib/dist/interfaces/NotificationCompletion.js +0 -9
- package/lib/dist/interfaces/NotificationEvents.d.ts +0 -18
- package/lib/dist/interfaces/NotificationEvents.js +0 -2
- package/lib/dist/interfaces/NotificationPermissions.d.ts +0 -14
- package/lib/dist/interfaces/NotificationPermissions.js +0 -2
|
@@ -17,6 +17,10 @@ public class JsIOHelper {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
public boolean sendEventToJS(String eventName, WritableMap data, ReactContext reactContext) {
|
|
20
|
+
if(!reactContext.hasActiveCatalystInstance()) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
if (reactContext != null) {
|
|
21
25
|
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
|
|
22
26
|
return true;
|
|
@@ -15,6 +15,8 @@ import android.net.Uri;
|
|
|
15
15
|
import android.os.Build;
|
|
16
16
|
import android.os.Bundle;
|
|
17
17
|
import android.os.PowerManager;
|
|
18
|
+
import android.os.VibrationEffect;
|
|
19
|
+
import android.os.Vibrator;
|
|
18
20
|
import android.util.Log;
|
|
19
21
|
|
|
20
22
|
import com.facebook.react.bridge.ReactContext;
|
|
@@ -214,7 +216,7 @@ public class PushNotification implements IPushNotification {
|
|
|
214
216
|
Log.d(LOGTAG, e.getMessage());
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
if(mNotificationProps.getCriticalAlert()){
|
|
219
|
+
if(mNotificationProps.getCriticalAlert() || mNotificationProps.getOverridemute()){
|
|
218
220
|
try {
|
|
219
221
|
MediaPlayer mMediaPlayer = new MediaPlayer();
|
|
220
222
|
mMediaPlayer.setDataSource(mContext.getApplicationContext(), soundUri);
|
|
@@ -227,6 +229,18 @@ public class PushNotification implements IPushNotification {
|
|
|
227
229
|
mMediaPlayer.start();
|
|
228
230
|
}
|
|
229
231
|
});
|
|
232
|
+
|
|
233
|
+
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
|
|
234
|
+
// Vibrate with wave form
|
|
235
|
+
long[] timings = new long[] { 50, 50, 50, 50, 50, 100, 350, 25, 25, 25, 25, 200 };
|
|
236
|
+
int[] amplitudes = new int[] { 33, 51, 75, 113, 170, 255, 0, 38, 62, 100, 160, 255 };
|
|
237
|
+
int repeatIndex = -1; // Do not repeat.
|
|
238
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
239
|
+
v.vibrate(VibrationEffect.createWaveform(timings, amplitudes, repeatIndex));
|
|
240
|
+
} else {
|
|
241
|
+
//deprecated in API 26
|
|
242
|
+
v.vibrate(3000);
|
|
243
|
+
}
|
|
230
244
|
} catch (Exception e) {
|
|
231
245
|
Log.d(LOGTAG, e.getMessage());
|
|
232
246
|
}
|
|
@@ -248,7 +262,7 @@ public class PushNotification implements IPushNotification {
|
|
|
248
262
|
|
|
249
263
|
private void setUpIconColor(Notification.Builder notification) {
|
|
250
264
|
int colorResID = getAppResourceId("colorAccent", "color");
|
|
251
|
-
if (colorResID != 0
|
|
265
|
+
if (colorResID != 0) {
|
|
252
266
|
int color = mContext.getResources().getColor(colorResID);
|
|
253
267
|
notification.setColor(color);
|
|
254
268
|
}
|
|
@@ -285,7 +299,7 @@ public class PushNotification implements IPushNotification {
|
|
|
285
299
|
}
|
|
286
300
|
|
|
287
301
|
protected void launchOrResumeApp() {
|
|
288
|
-
if (
|
|
302
|
+
if (NotificationIntentAdapter.canHandleTrampolineActivity(mContext)) {
|
|
289
303
|
final Intent intent = mAppLaunchHelper.getLaunchIntent(mContext);
|
|
290
304
|
mContext.startActivity(intent);
|
|
291
305
|
}
|
|
@@ -58,6 +58,14 @@ public class PushNotificationProps {
|
|
|
58
58
|
return 0.0;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
public Boolean getOverridemute() {
|
|
62
|
+
String val = mBundle.getString("overridemute");
|
|
63
|
+
if(val != null && !val.isEmpty()){
|
|
64
|
+
return val.toLowerCase().equals("true");
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
61
69
|
public Boolean getOngoing() {
|
|
62
70
|
return mBundle.getBoolean("ongoing");
|
|
63
71
|
}
|
package/package.json
CHANGED
package/react-native.config.js
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
-
# as it contains information specific to your local configuration.
|
|
3
|
-
#
|
|
4
|
-
# Location of the SDK. This is only used by Gradle.
|
|
5
|
-
# For customization when using a Version Control System, please read the
|
|
6
|
-
# header note.
|
|
7
|
-
#Tue Mar 22 09:43:01 CET 2022
|
|
8
|
-
sdk.dir=/Users/larserlingdahl/Library/Android/sdk
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Notification = void 0;
|
|
4
|
-
class Notification {
|
|
5
|
-
constructor(payload) {
|
|
6
|
-
this.payload = payload;
|
|
7
|
-
this.identifier = this.payload.identifier;
|
|
8
|
-
}
|
|
9
|
-
get title() {
|
|
10
|
-
return this.payload.title;
|
|
11
|
-
}
|
|
12
|
-
get body() {
|
|
13
|
-
return this.payload.body;
|
|
14
|
-
}
|
|
15
|
-
get sound() {
|
|
16
|
-
return this.payload.sound;
|
|
17
|
-
}
|
|
18
|
-
get badge() {
|
|
19
|
-
return this.payload.badge;
|
|
20
|
-
}
|
|
21
|
-
get type() {
|
|
22
|
-
return this.payload.type;
|
|
23
|
-
}
|
|
24
|
-
get thread() {
|
|
25
|
-
return this.payload.thread;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.Notification = Notification;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Notification_1 = require("./Notification");
|
|
4
|
-
const NotificationIOS_1 = require("./NotificationIOS");
|
|
5
|
-
const NotificationAndroid_1 = require("./NotificationAndroid");
|
|
6
|
-
describe('Notification', () => {
|
|
7
|
-
it('Should create notification with payload', () => {
|
|
8
|
-
const payload = { p: 'p' };
|
|
9
|
-
const notification = new Notification_1.Notification(payload);
|
|
10
|
-
expect(notification.payload).toEqual(payload);
|
|
11
|
-
});
|
|
12
|
-
it('Should create iOS notification with identifier', () => {
|
|
13
|
-
const payload = { identifier: 'identifier' };
|
|
14
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
15
|
-
expect(notification.identifier).toEqual(payload.identifier);
|
|
16
|
-
});
|
|
17
|
-
it('Should create Android notification with identifier', () => {
|
|
18
|
-
const payload = { 'google.message_id': 'identifier' };
|
|
19
|
-
const notification = new NotificationAndroid_1.NotificationAndroid(payload);
|
|
20
|
-
expect(notification.identifier).toEqual('identifier');
|
|
21
|
-
});
|
|
22
|
-
it('Should return title from payload', () => {
|
|
23
|
-
const payload = { title: 'title' };
|
|
24
|
-
const notification = new Notification_1.Notification(payload);
|
|
25
|
-
expect(notification.title).toEqual(payload.title);
|
|
26
|
-
});
|
|
27
|
-
it('Should return body from payload', () => {
|
|
28
|
-
const payload = { body: 'body' };
|
|
29
|
-
const notification = new Notification_1.Notification(payload);
|
|
30
|
-
expect(notification.body).toEqual(payload.body);
|
|
31
|
-
});
|
|
32
|
-
it('Should return sound from payload', () => {
|
|
33
|
-
const payload = { sound: 'sound.mp4' };
|
|
34
|
-
const notification = new Notification_1.Notification(payload);
|
|
35
|
-
expect(notification.sound).toEqual(payload.sound);
|
|
36
|
-
});
|
|
37
|
-
it('Should return badge from payload', () => {
|
|
38
|
-
const payload = { badge: 1 };
|
|
39
|
-
const notification = new Notification_1.Notification(payload);
|
|
40
|
-
expect(notification.badge).toEqual(payload.badge);
|
|
41
|
-
});
|
|
42
|
-
it('Should return type from payload', () => {
|
|
43
|
-
const payload = { type: 'type' };
|
|
44
|
-
const notification = new Notification_1.Notification(payload);
|
|
45
|
-
expect(notification.type).toEqual(payload.type);
|
|
46
|
-
});
|
|
47
|
-
it('Should return thread from payload', () => {
|
|
48
|
-
const payload = { thread: 'thread' };
|
|
49
|
-
const notification = new Notification_1.Notification(payload);
|
|
50
|
-
expect(notification.thread).toEqual(payload.thread);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationAndroid = void 0;
|
|
4
|
-
const Notification_1 = require("./Notification");
|
|
5
|
-
class NotificationAndroid extends Notification_1.Notification {
|
|
6
|
-
constructor(payload) {
|
|
7
|
-
super(payload);
|
|
8
|
-
this.identifier = this.payload["google.message_id"];
|
|
9
|
-
}
|
|
10
|
-
get title() {
|
|
11
|
-
return this.payload.title;
|
|
12
|
-
}
|
|
13
|
-
get body() {
|
|
14
|
-
return this.payload.body;
|
|
15
|
-
}
|
|
16
|
-
get sound() {
|
|
17
|
-
return this.payload.sound;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.NotificationAndroid = NotificationAndroid;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const NotificationAndroid_1 = require("./NotificationAndroid");
|
|
4
|
-
describe('Notification', () => {
|
|
5
|
-
it('Should create notification with payload', () => {
|
|
6
|
-
const payload = { p: 'p' };
|
|
7
|
-
const notification = new NotificationAndroid_1.NotificationAndroid(payload);
|
|
8
|
-
expect(notification.payload).toEqual(payload);
|
|
9
|
-
});
|
|
10
|
-
it('Should return title from payload', () => {
|
|
11
|
-
const payload = { title: 'title', body: 'body' };
|
|
12
|
-
const notification = new NotificationAndroid_1.NotificationAndroid(payload);
|
|
13
|
-
expect(notification.title).toEqual('title');
|
|
14
|
-
});
|
|
15
|
-
it('Should return body from payload', () => {
|
|
16
|
-
const payload = { title: 'title', body: 'body' };
|
|
17
|
-
const notification = new NotificationAndroid_1.NotificationAndroid(payload);
|
|
18
|
-
expect(notification.body).toEqual('body');
|
|
19
|
-
});
|
|
20
|
-
it('Should return sound from payload', () => {
|
|
21
|
-
const payload = { title: 'title', sound: 'sound.wav' };
|
|
22
|
-
const notification = new NotificationAndroid_1.NotificationAndroid(payload);
|
|
23
|
-
expect(notification.sound).toEqual('sound.wav');
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationFactory = void 0;
|
|
4
|
-
const Notification_1 = require("./Notification");
|
|
5
|
-
const NotificationIOS_1 = require("./NotificationIOS");
|
|
6
|
-
const NotificationAndroid_1 = require("./NotificationAndroid");
|
|
7
|
-
const react_native_1 = require("react-native");
|
|
8
|
-
class NotificationFactory {
|
|
9
|
-
fromPayload(payload) {
|
|
10
|
-
if (react_native_1.Platform.OS === 'ios') {
|
|
11
|
-
return payload.aps ? new NotificationIOS_1.NotificationIOS(payload) : new Notification_1.Notification(payload);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return new NotificationAndroid_1.NotificationAndroid(payload);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.NotificationFactory = NotificationFactory;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Notification } from './Notification';
|
|
2
|
-
export declare class NotificationIOS extends Notification {
|
|
3
|
-
identifier: string;
|
|
4
|
-
constructor(payload: object);
|
|
5
|
-
get aps(): any;
|
|
6
|
-
get alert(): any;
|
|
7
|
-
get title(): string;
|
|
8
|
-
get body(): string;
|
|
9
|
-
get sound(): string;
|
|
10
|
-
get badge(): number;
|
|
11
|
-
get thread(): string;
|
|
12
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationIOS = void 0;
|
|
4
|
-
const Notification_1 = require("./Notification");
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
class NotificationIOS extends Notification_1.Notification {
|
|
7
|
-
constructor(payload) {
|
|
8
|
-
super(payload);
|
|
9
|
-
this.identifier = this.payload.identifier;
|
|
10
|
-
}
|
|
11
|
-
get aps() {
|
|
12
|
-
return this.payload.aps || {};
|
|
13
|
-
}
|
|
14
|
-
get alert() {
|
|
15
|
-
if (_.isObject(this.aps.alert)) {
|
|
16
|
-
return this.aps.alert;
|
|
17
|
-
}
|
|
18
|
-
else if (_.isString(this.aps.alert)) {
|
|
19
|
-
return {
|
|
20
|
-
body: this.aps.alert
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
get title() {
|
|
25
|
-
return this.alert.title;
|
|
26
|
-
}
|
|
27
|
-
get body() {
|
|
28
|
-
return this.alert.body;
|
|
29
|
-
}
|
|
30
|
-
get sound() {
|
|
31
|
-
return this.aps.sound;
|
|
32
|
-
}
|
|
33
|
-
get badge() {
|
|
34
|
-
return this.aps.badge;
|
|
35
|
-
}
|
|
36
|
-
get thread() {
|
|
37
|
-
return this.aps.thread;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.NotificationIOS = NotificationIOS;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const NotificationIOS_1 = require("./NotificationIOS");
|
|
4
|
-
describe('Notification', () => {
|
|
5
|
-
it('Should create notification with payload', () => {
|
|
6
|
-
const payload = { p: 'p' };
|
|
7
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
8
|
-
expect(notification.payload).toEqual(payload);
|
|
9
|
-
});
|
|
10
|
-
it('Should create notification with valid aps', () => {
|
|
11
|
-
const aps = { alert: {} };
|
|
12
|
-
const payload = { aps };
|
|
13
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
14
|
-
expect(notification.aps).toEqual(aps);
|
|
15
|
-
});
|
|
16
|
-
it('Should create notification with empy aps', () => {
|
|
17
|
-
const payload = { aps: undefined };
|
|
18
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
19
|
-
expect(notification.aps).toEqual({});
|
|
20
|
-
});
|
|
21
|
-
it('Should return alert object', () => {
|
|
22
|
-
const payload = { aps: { alert: { title: 'title' } } };
|
|
23
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
24
|
-
expect(notification.alert).toEqual(payload.aps.alert);
|
|
25
|
-
});
|
|
26
|
-
it('Should return alert object when alert is string', () => {
|
|
27
|
-
const payload = { aps: { alert: 'title' } };
|
|
28
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
29
|
-
expect(notification.alert).toEqual({
|
|
30
|
-
body: 'title'
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
it('Should return title from alert', () => {
|
|
34
|
-
const payload = { aps: { alert: { title: 'title' } } };
|
|
35
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
36
|
-
expect(notification.title).toEqual('title');
|
|
37
|
-
});
|
|
38
|
-
it('Should return body from alert', () => {
|
|
39
|
-
const payload = { aps: { alert: { title: 'title', body: 'body' } } };
|
|
40
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
41
|
-
expect(notification.body).toEqual('body');
|
|
42
|
-
});
|
|
43
|
-
it('Should return badge from aps', () => {
|
|
44
|
-
const payload = { aps: { badge: 0 } };
|
|
45
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
46
|
-
expect(notification.badge).toEqual(0);
|
|
47
|
-
});
|
|
48
|
-
it('Should return sound from aps', () => {
|
|
49
|
-
const payload = { aps: { sound: 'sound.wav' } };
|
|
50
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
51
|
-
expect(notification.sound).toEqual('sound.wav');
|
|
52
|
-
});
|
|
53
|
-
it('Should return thread from aps', () => {
|
|
54
|
-
const payload = { aps: { thread: 'thread' } };
|
|
55
|
-
const notification = new NotificationIOS_1.NotificationIOS(payload);
|
|
56
|
-
expect(notification.thread).toEqual('thread');
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { EventsRegistry } from './events/EventsRegistry';
|
|
2
|
-
import { Notification } from './DTO/Notification';
|
|
3
|
-
import { NotificationCategory } from './interfaces/NotificationCategory';
|
|
4
|
-
import { NotificationChannel } from './interfaces/NotificationChannel';
|
|
5
|
-
import { NotificationsIOS } from './NotificationsIOS';
|
|
6
|
-
import { NotificationsAndroid } from './NotificationsAndroid';
|
|
7
|
-
import { NotificationPermissionOptions } from './interfaces/NotificationPermissions';
|
|
8
|
-
export declare class NotificationsRoot {
|
|
9
|
-
readonly _ios: NotificationsIOS;
|
|
10
|
-
readonly _android: NotificationsAndroid;
|
|
11
|
-
private readonly notificationFactory;
|
|
12
|
-
private readonly nativeEventsReceiver;
|
|
13
|
-
private readonly nativeCommandsSender;
|
|
14
|
-
private readonly commands;
|
|
15
|
-
private readonly eventsRegistry;
|
|
16
|
-
private readonly eventsRegistryIOS;
|
|
17
|
-
private readonly uniqueIdProvider;
|
|
18
|
-
private readonly completionCallbackWrapper;
|
|
19
|
-
constructor();
|
|
20
|
-
/**
|
|
21
|
-
* registerRemoteNotifications
|
|
22
|
-
*/
|
|
23
|
-
registerRemoteNotifications(options?: NotificationPermissionOptions): void;
|
|
24
|
-
/**
|
|
25
|
-
* postLocalNotification
|
|
26
|
-
*/
|
|
27
|
-
postLocalNotification(notification: Notification, id?: number): number;
|
|
28
|
-
/**
|
|
29
|
-
* getInitialNotification
|
|
30
|
-
*/
|
|
31
|
-
getInitialNotification(): Promise<Notification | undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* getLastAction
|
|
34
|
-
*/
|
|
35
|
-
getLastAction(): Promise<Notification | undefined>;
|
|
36
|
-
/**
|
|
37
|
-
* setCategories
|
|
38
|
-
*/
|
|
39
|
-
setCategories(categories: [NotificationCategory?]): void;
|
|
40
|
-
/**
|
|
41
|
-
* cancelLocalNotification
|
|
42
|
-
*/
|
|
43
|
-
cancelLocalNotification(notificationId: number): void;
|
|
44
|
-
/**
|
|
45
|
-
* removeAllDeliveredNotifications
|
|
46
|
-
*/
|
|
47
|
-
removeAllDeliveredNotifications(): void;
|
|
48
|
-
/**
|
|
49
|
-
* isRegisteredForRemoteNotifications
|
|
50
|
-
*/
|
|
51
|
-
isRegisteredForRemoteNotifications(): Promise<boolean>;
|
|
52
|
-
/**
|
|
53
|
-
* setNotificationChannel
|
|
54
|
-
*/
|
|
55
|
-
setNotificationChannel(notificationChannel: NotificationChannel): void;
|
|
56
|
-
/**
|
|
57
|
-
* Obtain the events registry instance
|
|
58
|
-
*/
|
|
59
|
-
events(): EventsRegistry;
|
|
60
|
-
/**
|
|
61
|
-
* ios/android getters
|
|
62
|
-
*/
|
|
63
|
-
get ios(): NotificationsIOS;
|
|
64
|
-
get android(): NotificationsAndroid;
|
|
65
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationsRoot = void 0;
|
|
4
|
-
const NativeCommandsSender_1 = require("./adapters/NativeCommandsSender");
|
|
5
|
-
const NativeEventsReceiver_1 = require("./adapters/NativeEventsReceiver");
|
|
6
|
-
const Commands_1 = require("./commands/Commands");
|
|
7
|
-
const EventsRegistry_1 = require("./events/EventsRegistry");
|
|
8
|
-
const EventsRegistryIOS_1 = require("./events/EventsRegistryIOS");
|
|
9
|
-
const UniqueIdProvider_1 = require("./adapters/UniqueIdProvider");
|
|
10
|
-
const CompletionCallbackWrapper_1 = require("./adapters/CompletionCallbackWrapper");
|
|
11
|
-
const NotificationsIOS_1 = require("./NotificationsIOS");
|
|
12
|
-
const NotificationsAndroid_1 = require("./NotificationsAndroid");
|
|
13
|
-
const NotificationFactory_1 = require("./DTO/NotificationFactory");
|
|
14
|
-
class NotificationsRoot {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.notificationFactory = new NotificationFactory_1.NotificationFactory();
|
|
17
|
-
this.nativeEventsReceiver = new NativeEventsReceiver_1.NativeEventsReceiver(this.notificationFactory);
|
|
18
|
-
this.nativeCommandsSender = new NativeCommandsSender_1.NativeCommandsSender();
|
|
19
|
-
this.completionCallbackWrapper = new CompletionCallbackWrapper_1.CompletionCallbackWrapper(this.nativeCommandsSender);
|
|
20
|
-
this.uniqueIdProvider = new UniqueIdProvider_1.UniqueIdProvider();
|
|
21
|
-
this.commands = new Commands_1.Commands(this.nativeCommandsSender, this.uniqueIdProvider, this.notificationFactory);
|
|
22
|
-
this.eventsRegistry = new EventsRegistry_1.EventsRegistry(this.nativeEventsReceiver, this.completionCallbackWrapper);
|
|
23
|
-
this.eventsRegistryIOS = new EventsRegistryIOS_1.EventsRegistryIOS(this.nativeEventsReceiver, this.completionCallbackWrapper);
|
|
24
|
-
this._ios = new NotificationsIOS_1.NotificationsIOS(this.commands, this.eventsRegistryIOS);
|
|
25
|
-
this._android = new NotificationsAndroid_1.NotificationsAndroid(this.commands);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* registerRemoteNotifications
|
|
29
|
-
*/
|
|
30
|
-
registerRemoteNotifications(options) {
|
|
31
|
-
this.ios.registerRemoteNotifications(options);
|
|
32
|
-
this.android.registerRemoteNotifications();
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* postLocalNotification
|
|
36
|
-
*/
|
|
37
|
-
postLocalNotification(notification, id) {
|
|
38
|
-
return this.commands.postLocalNotification(notification, id);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* getInitialNotification
|
|
42
|
-
*/
|
|
43
|
-
getInitialNotification() {
|
|
44
|
-
return this.commands.getInitialNotification();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* getLastAction
|
|
48
|
-
*/
|
|
49
|
-
getLastAction() {
|
|
50
|
-
return this.commands.getLastAction();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* setCategories
|
|
54
|
-
*/
|
|
55
|
-
setCategories(categories) {
|
|
56
|
-
this.commands.setCategories(categories);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* cancelLocalNotification
|
|
60
|
-
*/
|
|
61
|
-
cancelLocalNotification(notificationId) {
|
|
62
|
-
return this.commands.cancelLocalNotification(notificationId);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* removeAllDeliveredNotifications
|
|
66
|
-
*/
|
|
67
|
-
removeAllDeliveredNotifications() {
|
|
68
|
-
return this.commands.removeAllDeliveredNotifications();
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* isRegisteredForRemoteNotifications
|
|
72
|
-
*/
|
|
73
|
-
isRegisteredForRemoteNotifications() {
|
|
74
|
-
return this.commands.isRegisteredForRemoteNotifications();
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* setNotificationChannel
|
|
78
|
-
*/
|
|
79
|
-
setNotificationChannel(notificationChannel) {
|
|
80
|
-
return this.android.setNotificationChannel(notificationChannel);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Obtain the events registry instance
|
|
84
|
-
*/
|
|
85
|
-
events() {
|
|
86
|
-
return this.eventsRegistry;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* ios/android getters
|
|
90
|
-
*/
|
|
91
|
-
get ios() {
|
|
92
|
-
return this._ios;
|
|
93
|
-
}
|
|
94
|
-
get android() {
|
|
95
|
-
return this._android;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.NotificationsRoot = NotificationsRoot;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Commands } from './commands/Commands';
|
|
2
|
-
import { NotificationChannel } from './interfaces/NotificationChannel';
|
|
3
|
-
export declare class NotificationsAndroid {
|
|
4
|
-
private readonly commands;
|
|
5
|
-
constructor(commands: Commands);
|
|
6
|
-
/**
|
|
7
|
-
* Refresh FCM token
|
|
8
|
-
*/
|
|
9
|
-
registerRemoteNotifications(): void;
|
|
10
|
-
/**
|
|
11
|
-
* setNotificationChannel
|
|
12
|
-
*/
|
|
13
|
-
setNotificationChannel(notificationChannel: NotificationChannel): void;
|
|
14
|
-
}
|