notifly-sdk 3.1.2 → 3.3.0
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/android/build.gradle +6 -6
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/{com/notiflysdk → tech/notifly/rn}/NotiflySdkModule.kt +52 -14
- package/android/src/main/java/{com/notiflysdk → tech/notifly/rn}/NotiflySdkPackage.kt +1 -1
- package/android/src/main/java/tech/notifly/rn/NotiflySdkUtils.kt +79 -0
- package/android/src/newarch/NotiflySdkSpec.kt +1 -1
- package/android/src/oldarch/NotiflySdkSpec.kt +2 -2
- package/ios/NotiflySdk.m +1 -5
- package/ios/NotiflySdk.swift +3 -8
- package/lib/commonjs/{NativeNotiflySdk.js → NativeNotiflyReactNativeSdk.js} +2 -2
- package/lib/commonjs/NativeNotiflyReactNativeSdk.js.map +1 -0
- package/lib/commonjs/constants.js +12 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/events/EventReceiver.js +60 -0
- package/lib/commonjs/events/EventReceiver.js.map +1 -0
- package/lib/commonjs/index.js +29 -45
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/index.js +17 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/notification.js +14 -0
- package/lib/commonjs/types/notification.js.map +1 -0
- package/lib/module/NativeNotiflyReactNativeSdk.js +3 -0
- package/lib/module/NativeNotiflyReactNativeSdk.js.map +1 -0
- package/lib/module/constants.js +5 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/events/EventReceiver.js +53 -0
- package/lib/module/events/EventReceiver.js.map +1 -0
- package/lib/module/index.js +27 -41
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/notification.js +7 -0
- package/lib/module/types/notification.js.map +1 -0
- package/lib/typescript/{NativeNotiflySdk.d.ts → NativeNotiflyReactNativeSdk.d.ts} +5 -8
- package/lib/typescript/NativeNotiflyReactNativeSdk.d.ts.map +1 -0
- package/lib/typescript/constants.d.ts +4 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/events/EventReceiver.d.ts +11 -0
- package/lib/typescript/events/EventReceiver.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -16
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +13 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types/notification.d.ts +28 -0
- package/lib/typescript/types/notification.d.ts.map +1 -0
- package/notifly_react_native_sdk.podspec +1 -1
- package/package.json +5 -5
- package/src/{NativeNotiflySdk.ts → NativeNotiflyReactNativeSdk.ts} +5 -10
- package/src/constants.ts +3 -0
- package/src/events/EventReceiver.ts +67 -0
- package/src/index.tsx +59 -56
- package/src/types/index.ts +15 -0
- package/src/types/notification.ts +40 -0
- package/lib/commonjs/NativeNotiflySdk.js.map +0 -1
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/NativeNotiflySdk.js +0 -3
- package/lib/module/NativeNotiflySdk.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/NativeNotiflySdk.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -7
- package/lib/typescript/types.d.ts.map +0 -1
- package/src/types.ts +0 -7
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { NativeModules, Platform } from 'react-native';
|
|
2
|
-
import
|
|
2
|
+
import type {
|
|
3
|
+
InitializeParams,
|
|
4
|
+
EventProperties,
|
|
5
|
+
UserProperties,
|
|
6
|
+
NotificationClickListener,
|
|
7
|
+
OSNotificationClickEvent,
|
|
8
|
+
} from './types';
|
|
9
|
+
import EventReceiver from './events/EventReceiver';
|
|
10
|
+
import { EventNames } from './constants';
|
|
11
|
+
|
|
12
|
+
export type * from './types';
|
|
3
13
|
|
|
4
14
|
const LINKING_ERROR =
|
|
5
15
|
`The package 'notifly-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -10,12 +20,12 @@ const LINKING_ERROR =
|
|
|
10
20
|
// @ts-expect-error
|
|
11
21
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
12
22
|
|
|
13
|
-
const
|
|
14
|
-
? require('./
|
|
15
|
-
: NativeModules.
|
|
23
|
+
const NotiflyReactNativeSdkModule = isTurboModuleEnabled
|
|
24
|
+
? require('./NativeNotiflyReactNativeSdk').default
|
|
25
|
+
: NativeModules.NotiflyReactNativeSdk;
|
|
16
26
|
|
|
17
|
-
const
|
|
18
|
-
?
|
|
27
|
+
const NotiflyReactNativeSdk = NotiflyReactNativeSdkModule
|
|
28
|
+
? NotiflyReactNativeSdkModule
|
|
19
29
|
: new Proxy(
|
|
20
30
|
{},
|
|
21
31
|
{
|
|
@@ -25,31 +35,27 @@ const NotiflySdk = NotiflySdkModule
|
|
|
25
35
|
}
|
|
26
36
|
);
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
const eventReceiver =
|
|
39
|
+
NotiflyReactNativeSdkModule && Platform.OS === 'android'
|
|
40
|
+
? new EventReceiver(NotiflyReactNativeSdkModule)
|
|
41
|
+
: null;
|
|
31
42
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.warn(
|
|
41
|
-
'Warning: useCustomClickHandler of notifly.initialize is deprecated and will be removed in the next major release.'
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return NotiflySdk.initialize(projectId, username, password);
|
|
43
|
+
let isNativeNotificationClickListenerRegistered = false;
|
|
44
|
+
|
|
45
|
+
export function initialize(params: InitializeParams): Promise<void> {
|
|
46
|
+
return NotiflyReactNativeSdk.initialize(
|
|
47
|
+
params.projectId,
|
|
48
|
+
params.username,
|
|
49
|
+
params.password
|
|
50
|
+
);
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
export function setUserId(userId: string | undefined): Promise<void> {
|
|
48
|
-
return
|
|
53
|
+
export function setUserId(userId: string | null | undefined): Promise<void> {
|
|
54
|
+
return NotiflyReactNativeSdk.setUserId(userId);
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
export function setUserProperties(properties: UserProperties): Promise<void> {
|
|
52
|
-
return
|
|
58
|
+
return NotiflyReactNativeSdk.setUserProperties(properties);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
export function trackEvent(
|
|
@@ -57,7 +63,7 @@ export function trackEvent(
|
|
|
57
63
|
eventParams: EventProperties | null | undefined = undefined,
|
|
58
64
|
segmentationEventParamKeys: string[] | undefined | null = null
|
|
59
65
|
): Promise<void> {
|
|
60
|
-
return
|
|
66
|
+
return NotiflyReactNativeSdk.trackEvent(
|
|
61
67
|
eventName,
|
|
62
68
|
eventParams,
|
|
63
69
|
segmentationEventParamKeys
|
|
@@ -67,41 +73,40 @@ export function trackEvent(
|
|
|
67
73
|
export function setLogLevel(logLevel: number): Promise<void> {
|
|
68
74
|
// only implemented on Android
|
|
69
75
|
if (Platform.OS === 'android') {
|
|
70
|
-
return
|
|
76
|
+
return NotiflyReactNativeSdk.setLogLevel(logLevel);
|
|
77
|
+
} else {
|
|
78
|
+
console.error(
|
|
79
|
+
'[Notifly React Native SDK] setLogLevel is only supported on Android.'
|
|
80
|
+
);
|
|
71
81
|
}
|
|
72
82
|
return Promise.resolve();
|
|
73
83
|
}
|
|
74
84
|
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated Since version 2.3.0.
|
|
77
|
-
*/
|
|
78
|
-
export function notiflyBackgroundHandler(_remoteMessage: any): Promise<void> {
|
|
79
|
-
console.warn(
|
|
80
|
-
'Warning: notifly.notiflyBackgroundHandler(remoteMessage) is deprecated and will be removed in the next major release. You do not need to call this method anymore. remoteMessage is now handled automatically.'
|
|
81
|
-
);
|
|
82
|
-
return Promise.resolve();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @deprecated Since version 2.3.0.
|
|
87
|
-
*/
|
|
88
|
-
export function setNotiflyBackgroundMessageHandler(): Promise<void> {
|
|
89
|
-
console.warn(
|
|
90
|
-
'Warning: notifly.setNotiflyBackgroundMessageHandler() is deprecated and will be removed in the next major release. You do not need to call this method anymore. remoteMessage is now handled automatically.'
|
|
91
|
-
);
|
|
92
|
-
return Promise.resolve();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
85
|
export function disableInAppMessage(): Promise<void> {
|
|
96
|
-
return
|
|
86
|
+
return NotiflyReactNativeSdk.disableInAppMessage();
|
|
97
87
|
}
|
|
98
88
|
|
|
99
|
-
export function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
export function addNotificationClickListener(
|
|
90
|
+
listener: NotificationClickListener
|
|
91
|
+
): Promise<void> {
|
|
92
|
+
if (eventReceiver) {
|
|
93
|
+
// only implemented on Android
|
|
94
|
+
eventReceiver.addEventListener<OSNotificationClickEvent>(
|
|
95
|
+
EventNames.NOTIFICATION_CLICKED,
|
|
96
|
+
listener
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (!isNativeNotificationClickListenerRegistered) {
|
|
100
|
+
NotiflyReactNativeSdk.addNotificationClickListener();
|
|
101
|
+
isNativeNotificationClickListenerRegistered = true;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
console.error(
|
|
105
|
+
'[Notifly React Native SDK] addNotificationClickListener is only supported on Android.'
|
|
106
|
+
);
|
|
103
107
|
}
|
|
104
|
-
|
|
108
|
+
|
|
109
|
+
return Promise.resolve();
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
const notifly = {
|
|
@@ -110,10 +115,8 @@ const notifly = {
|
|
|
110
115
|
setUserProperties,
|
|
111
116
|
trackEvent,
|
|
112
117
|
setLogLevel,
|
|
113
|
-
notiflyBackgroundHandler,
|
|
114
|
-
setNotiflyBackgroundMessageHandler,
|
|
115
118
|
disableInAppMessage,
|
|
116
|
-
|
|
119
|
+
addNotificationClickListener,
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
export default notifly;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './notification';
|
|
2
|
+
|
|
3
|
+
export interface InitializeParams {
|
|
4
|
+
projectId: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface UserProperties {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface EventProperties {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type NotificationClickListener = (
|
|
2
|
+
event: OSNotificationClickEvent
|
|
3
|
+
) => void;
|
|
4
|
+
|
|
5
|
+
export enum OSNotificationImportance {
|
|
6
|
+
LOW = 0,
|
|
7
|
+
NORMAL = 1,
|
|
8
|
+
HIGH = 2,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface OSNotificationClickEvent {
|
|
12
|
+
notification: OSNotification;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface OSNotification {
|
|
16
|
+
// The Notifly message ID of the notification.
|
|
17
|
+
notiflyMessageId?: string;
|
|
18
|
+
// (Only Android) The Android system notification ID of the notification.
|
|
19
|
+
androidNotificationId?: number;
|
|
20
|
+
// Notifly campaign ID where the notification was sent from.
|
|
21
|
+
campaignId?: string;
|
|
22
|
+
// Notification title
|
|
23
|
+
title?: string;
|
|
24
|
+
// Notification body
|
|
25
|
+
body?: string;
|
|
26
|
+
// (Only Android) Importance of the notification.
|
|
27
|
+
importance?: OSNotificationImportance;
|
|
28
|
+
// URL included in the notification.
|
|
29
|
+
url?: string;
|
|
30
|
+
// URL to the image included in the notification.
|
|
31
|
+
imageUrl?: string;
|
|
32
|
+
// Sent time of the notification in milliseconds since epoch
|
|
33
|
+
sentTime?: number;
|
|
34
|
+
// TTL of the notification in seconds
|
|
35
|
+
ttl?: number;
|
|
36
|
+
// Customized data included in the notification.
|
|
37
|
+
customData?: { [key: string]: any };
|
|
38
|
+
// Raw payload of the notification.
|
|
39
|
+
rawPayload?: { [key: string]: any };
|
|
40
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","TurboModuleRegistry","getEnforcing","exports","default"],"sourceRoot":"../../src","sources":["NativeNotiflySdk.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAyBpCC,gCAAmB,CAACC,YAAY,CAAO,YAAY,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA"}
|
package/lib/commonjs/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeNotiflySdk.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAyBlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,YAAY,CAAC"}
|
package/lib/module/types.js
DELETED
package/lib/module/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeNotiflySdk.d.ts","sourceRoot":"","sources":["../../src/NativeNotiflySdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,IAAK,SAAQ,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