@inngageregistry/inngage-react 2.2.6 → 2.2.7
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/index.js +14 -2
- package/inngageApi.js +1 -0
- package/package.json +1 -1
- package/utils.js +4 -3
package/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { firebase } from '@react-native-firebase/messaging';
|
|
2
|
-
import InAppBrowser from 'react-native-inappbrowser-reborn'
|
|
3
2
|
import DeviceInfo from "react-native-device-info";
|
|
4
3
|
import * as RNLocalize from "react-native-localize";
|
|
5
4
|
import { formatDate, subscriptionRequestAdapter, showAlertLink } from "./utils";
|
|
6
5
|
import ListenToNotifications, { linkInApp } from "./ListenToNotifications";
|
|
7
|
-
import { subscription,
|
|
6
|
+
import { subscription, eventsApi } from "./inngageApi";
|
|
8
7
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
9
8
|
import Carousel, { Pagination } from 'react-native-snap-carousel';
|
|
10
9
|
import React, { useState, useEffect, useRef } from 'react';
|
|
@@ -495,6 +494,7 @@ const Inngage = {
|
|
|
495
494
|
customFields,
|
|
496
495
|
customData,
|
|
497
496
|
phoneNumber,
|
|
497
|
+
authKey
|
|
498
498
|
} = props;
|
|
499
499
|
const respToken = await getFirebaseAccess()
|
|
500
500
|
|
|
@@ -524,6 +524,7 @@ const Inngage = {
|
|
|
524
524
|
app_installed_in,
|
|
525
525
|
app_updated_in,
|
|
526
526
|
uuid: DeviceInfo.getUniqueId(),
|
|
527
|
+
authKey
|
|
527
528
|
}
|
|
528
529
|
};
|
|
529
530
|
|
|
@@ -535,6 +536,17 @@ const Inngage = {
|
|
|
535
536
|
console.error(e);
|
|
536
537
|
return { subscribed: false };
|
|
537
538
|
}
|
|
539
|
+
},
|
|
540
|
+
SendEvent: async (props) => {
|
|
541
|
+
const { authKey, newEventRequest } = props
|
|
542
|
+
const rawRequest = {
|
|
543
|
+
registerSubscriberRequest: {
|
|
544
|
+
authKey
|
|
545
|
+
},
|
|
546
|
+
newEventRequest
|
|
547
|
+
}
|
|
548
|
+
const subscribe = await eventsApi(rawRequest);
|
|
549
|
+
return subscribe
|
|
538
550
|
}
|
|
539
551
|
}
|
|
540
552
|
|
package/inngageApi.js
CHANGED
|
@@ -2,3 +2,4 @@ import { fetchClient } from './utils'
|
|
|
2
2
|
|
|
3
3
|
export const subscription = (request, dev = false) => fetchClient('POST', request, '/subscription/', !!dev)
|
|
4
4
|
export const notificationApi = (request, dev = false) => fetchClient('POST', request, '/notification/', !!dev)
|
|
5
|
+
export const eventsApi = (request, dev = false) => fetchClient('POST', request, '/events/newEvent/', !!dev)
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -11,6 +11,7 @@ const requestConfigFactory = (method, request) => ({
|
|
|
11
11
|
headers: {
|
|
12
12
|
Accept: 'application/json',
|
|
13
13
|
'Content-Type': 'application/json',
|
|
14
|
+
Authorization: request.registerSubscriberRequest.authKey
|
|
14
15
|
},
|
|
15
16
|
method,
|
|
16
17
|
body: JSON.stringify(request),
|
|
@@ -20,7 +21,7 @@ export const fetchClient = (method, requestBody, path, isDev = false) => {
|
|
|
20
21
|
return new Promise((resolve) => {
|
|
21
22
|
const url = String(baseUrlHook[isDev]).concat(path)
|
|
22
23
|
const request = requestConfigFactory(method, requestBody)
|
|
23
|
-
|
|
24
|
+
console.log(request)
|
|
24
25
|
fetch(url, request)
|
|
25
26
|
.then(resolve)
|
|
26
27
|
.catch(err => console.log('Fetch Error', err))
|
|
@@ -28,7 +29,7 @@ export const fetchClient = (method, requestBody, path, isDev = false) => {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export const formatDate = (timestamp) => {
|
|
31
|
-
if(!timestamp) {
|
|
32
|
+
if (!timestamp) {
|
|
32
33
|
return null
|
|
33
34
|
}
|
|
34
35
|
return new Date(timestamp).toISOString()
|
|
@@ -52,7 +53,7 @@ export const showAlertLink = (title, body, appName, link) => {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
export const subscriptionRequestAdapter = (sdkRequest, useCustomData, customData) => {
|
|
55
|
-
if(useCustomData) {
|
|
56
|
+
if (useCustomData) {
|
|
56
57
|
return {
|
|
57
58
|
registerSubscriberRequest: {
|
|
58
59
|
...sdkRequest.registerSubscriberRequest,
|