@inngageregistry/inngage-react 3.2.1 → 3.3.0-alpha.10
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/package.json +2 -3
- package/src/Inngage.ts +24 -2
- package/src/components/Inapp.tsx +1 -1
- package/src/components/styles.ts +3 -3
- package/src/models/inngage_properties.ts +8 -0
- package/src/notificationsListener.ts +1 -1
- package/src/services/inngage.ts +5 -0
- package/src/utils.ts +4 -0
- package/tsconfig.json +5 -2
- package/src/index.d.ts +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inngageregistry/inngage-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0-alpha.10",
|
|
4
4
|
"description": "Inngage Plugin for React Native applications for marketing campaign optimization using Push Notification.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"@types/react": "^18.2.0",
|
|
36
36
|
"@types/react-native": "^0.71.6",
|
|
37
37
|
"@types/react-native-push-notification": "^8.1.1",
|
|
38
|
-
"@types/react-native-snap-carousel": "^3.8.5",
|
|
39
38
|
"@types/react-test-renderer": "^18.0.0",
|
|
40
39
|
"typescript": "^5.0.4"
|
|
41
40
|
}
|
|
42
|
-
}
|
|
41
|
+
}
|
package/src/Inngage.ts
CHANGED
|
@@ -3,9 +3,10 @@ import DeviceInfo from "react-native-device-info";
|
|
|
3
3
|
import * as RNLocalize from "react-native-localize";
|
|
4
4
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
5
5
|
|
|
6
|
-
import { eventRequest, formatDate, subscriptionRequestAdapter } from "./utils";
|
|
6
|
+
import { addUserDataRequest, eventRequest, formatDate, subscriptionRequestAdapter } from "./utils";
|
|
7
7
|
import notificationsListener, { notificationsListenerProps } from "./notificationsListener";
|
|
8
|
-
import { subscriptionApi, eventsApi } from "./services/inngage";
|
|
8
|
+
import { subscriptionApi, eventsApi, addUserDataApi } from "./services/inngage";
|
|
9
|
+
import { InngageProperties } from './models/inngage_properties';
|
|
9
10
|
|
|
10
11
|
import RNPermissions, { NotificationOption, RESULTS } from 'react-native-permissions';
|
|
11
12
|
|
|
@@ -92,6 +93,7 @@ const Inngage = {
|
|
|
92
93
|
return { subscribed: false };
|
|
93
94
|
}
|
|
94
95
|
},
|
|
96
|
+
|
|
95
97
|
Subscribe: async ({
|
|
96
98
|
appToken,
|
|
97
99
|
dev,
|
|
@@ -101,6 +103,9 @@ const Inngage = {
|
|
|
101
103
|
phoneNumber,
|
|
102
104
|
email,
|
|
103
105
|
}: SubscriptionProps) => {
|
|
106
|
+
InngageProperties.appToken = appToken;
|
|
107
|
+
InngageProperties.identifier = friendlyIdentifier!;
|
|
108
|
+
|
|
104
109
|
try {
|
|
105
110
|
const respToken = await getFirebaseAccess()
|
|
106
111
|
|
|
@@ -177,6 +182,23 @@ const Inngage = {
|
|
|
177
182
|
console.error(e)
|
|
178
183
|
return { subscribed: false };
|
|
179
184
|
}
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
async addUserData(customFields: any): Promise<any> {
|
|
188
|
+
const rawRequest = {
|
|
189
|
+
fieldsRequest: {
|
|
190
|
+
app_token: InngageProperties.appToken,
|
|
191
|
+
identifier: InngageProperties.identifier,
|
|
192
|
+
custom_field: customFields ?? {}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const request = addUserDataRequest(rawRequest);
|
|
197
|
+
try {
|
|
198
|
+
return await addUserDataApi(request);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
console.error(e);
|
|
201
|
+
}
|
|
180
202
|
}
|
|
181
203
|
}
|
|
182
204
|
|
package/src/components/Inapp.tsx
CHANGED
package/src/components/styles.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { StyleSheet } from "react-native";
|
|
|
4
4
|
interface styleInappProps {
|
|
5
5
|
SLIDER_WIDTH: number;
|
|
6
6
|
}
|
|
7
|
-
export const styleInapp = ({SLIDER_WIDTH}: styleInappProps) => StyleSheet.create({
|
|
7
|
+
export const styleInapp = ({ SLIDER_WIDTH }: styleInappProps) => StyleSheet.create({
|
|
8
8
|
carouselContainer: {
|
|
9
9
|
width: "100%",
|
|
10
10
|
marginTop: 10,
|
|
@@ -39,7 +39,7 @@ interface styleItemProps {
|
|
|
39
39
|
msg: any,
|
|
40
40
|
checkBG: Function,
|
|
41
41
|
}
|
|
42
|
-
export const styleItem = ({msg, checkBG}: styleItemProps) => StyleSheet.create({
|
|
42
|
+
export const styleItem = ({ msg, checkBG }: styleItemProps) => StyleSheet.create({
|
|
43
43
|
btn_left: {
|
|
44
44
|
backgroundColor: msg.btn_left_bg_color || "#FFFFFF",
|
|
45
45
|
height: 40,
|
|
@@ -94,4 +94,4 @@ export const styleItem = ({msg, checkBG}: styleItemProps) => StyleSheet.create({
|
|
|
94
94
|
marginLeft: 5,
|
|
95
95
|
elevation: 5,
|
|
96
96
|
}
|
|
97
|
-
});
|
|
97
|
+
});
|
|
@@ -30,7 +30,7 @@ export const linkInApp = (link: string) => {
|
|
|
30
30
|
const openLinkByType = (type: string, url: string) => {
|
|
31
31
|
const linkTypeHandlers: Record<string, () => void> = {
|
|
32
32
|
deep: () => Linking.openURL(url),
|
|
33
|
-
inapp: () => linkInApp(url),
|
|
33
|
+
// inapp: () => linkInApp(url),
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const handler = linkTypeHandlers[type];
|
package/src/services/inngage.ts
CHANGED
|
@@ -15,3 +15,8 @@ export const eventsApi = (request, dev = false) => {
|
|
|
15
15
|
console.log('eventsApi', request)
|
|
16
16
|
return fetchClient('POST', request, '/events/newEvent/', !!dev)
|
|
17
17
|
}
|
|
18
|
+
export const addUserDataApi = (request, dev = false) => {
|
|
19
|
+
if (dev)
|
|
20
|
+
console.log('addUserData', request)
|
|
21
|
+
return fetchClient('POST', request, '/subscription/addCustomField', !!dev)
|
|
22
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -44,6 +44,10 @@ export const eventRequest = (request) => {
|
|
|
44
44
|
return { ...request }
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export const addUserDataRequest = (request) => {
|
|
48
|
+
return { ...request }
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
export const isEmpty = (obj: any) => {
|
|
48
52
|
for (var prop in obj) {
|
|
49
53
|
if (obj.hasOwnProperty(prop)) {
|
package/tsconfig.json
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"skipLibCheck": true,
|
|
12
12
|
"moduleResolution": "node",
|
|
13
13
|
"noImplicitAny": false,
|
|
14
|
-
"lib": [
|
|
14
|
+
"lib": [
|
|
15
|
+
"dom",
|
|
16
|
+
"es2015"
|
|
17
|
+
]
|
|
15
18
|
},
|
|
16
19
|
"include": [
|
|
17
20
|
"**/*"
|
|
@@ -21,4 +24,4 @@
|
|
|
21
24
|
"**/__tests__/*",
|
|
22
25
|
"build"
|
|
23
26
|
]
|
|
24
|
-
}
|
|
27
|
+
}
|
package/src/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
interface notificationsListenerProps {
|
|
2
|
-
appToken: string,
|
|
3
|
-
dev?: boolean,
|
|
4
|
-
enableAlert: boolean,
|
|
5
|
-
onNotificationOpenedApp?: any,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface SubscriptionProps {
|
|
9
|
-
appToken: string;
|
|
10
|
-
enableAlert: boolean;
|
|
11
|
-
dev?: boolean;
|
|
12
|
-
friendlyIdentifier?: string;
|
|
13
|
-
customFields?: any;
|
|
14
|
-
customData?: any;
|
|
15
|
-
phoneNumber?: string;
|
|
16
|
-
email?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface SendEventProps {
|
|
20
|
-
appToken: string,
|
|
21
|
-
eventName: string,
|
|
22
|
-
identifier?: string,
|
|
23
|
-
registration?: string,
|
|
24
|
-
conversionEvent?: boolean,
|
|
25
|
-
conversionValue?: number,
|
|
26
|
-
conversionNotId?: string,
|
|
27
|
-
eventValues?: any
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
declare const Inngage: {
|
|
31
|
-
RegisterNotificationListener: (props: notificationsListenerProps) => Promise<any>;
|
|
32
|
-
Subscribe: (props: SubscriptionProps) => Promise<any>;
|
|
33
|
-
SendEvent: (props: SendEventProps) => Promise<any>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default Inngage;
|