@inngageregistry/inngage-react 2.2.3 → 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.
@@ -4,7 +4,7 @@ import messaging, { firebase } from '@react-native-firebase/messaging';
4
4
  import DeviceInfo from 'react-native-device-info'
5
5
  import { showAlert, showAlertLink } from './utils'
6
6
  import { notificationApi } from './inngageApi'
7
- import AsyncStorage from '@react-native-community/async-storage';
7
+ import AsyncStorage from '@react-native-async-storage/async-storage';
8
8
 
9
9
  export const linkInApp = (link) => {
10
10
  InAppBrowser.open(link, {
package/index.js CHANGED
@@ -1,11 +1,10 @@
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, notificationApi } from "./inngageApi";
8
- import AsyncStorage from '@react-native-community/async-storage';
6
+ import { subscription, eventsApi } from "./inngageApi";
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';
11
10
  import {
@@ -471,6 +470,7 @@ const getFirebaseAccess = () => {
471
470
  const Inngage = {
472
471
  // ------------ Get Permission ------------------//
473
472
  GetPermission: async (props) => {
473
+
474
474
  try {
475
475
  LogBox.ignoreLogs(['registerHeadlessTask'])
476
476
  } catch (e) { }
@@ -479,7 +479,7 @@ const Inngage = {
479
479
  } catch (e) { }
480
480
  try {
481
481
  AppRegistry.registerHeadlessTask('ReactNativeFirebaseMessagingHeadlessTask', () => backgroundNotificationHandler)
482
- ListenToNotifications(props);
482
+ ListenToNotifications(props);
483
483
  } catch (e) {
484
484
  console.error(e);
485
485
  return { subscribed: false };
@@ -493,6 +493,8 @@ const Inngage = {
493
493
  friendlyIdentifier,
494
494
  customFields,
495
495
  customData,
496
+ phoneNumber,
497
+ authKey
496
498
  } = props;
497
499
  const respToken = await getFirebaseAccess()
498
500
 
@@ -510,6 +512,7 @@ const Inngage = {
510
512
  app_token: appToken,
511
513
  identifier: friendlyIdentifier,
512
514
  registration: respToken,
515
+ phone_Number: phoneNumber,
513
516
  platform: DeviceInfo.getSystemName(),
514
517
  sdk: DeviceInfo.getBuildNumber(),
515
518
  device_model: DeviceInfo.getModel(),
@@ -521,15 +524,29 @@ const Inngage = {
521
524
  app_installed_in,
522
525
  app_updated_in,
523
526
  uuid: DeviceInfo.getUniqueId(),
527
+ authKey
524
528
  }
525
529
  };
526
530
 
527
531
  const request = subscriptionRequestAdapter(rawRequest, customData, customFields)
528
- return subscription(request, dev);
532
+ const subscribe = await subscription(request, dev);
533
+ console.log(await subscribe.json())
534
+ return subscribe;
529
535
  } catch (e) {
530
536
  console.error(e);
531
537
  return { subscribed: false };
532
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
533
550
  }
534
551
  }
535
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inngageregistry/inngage-react",
3
- "version": "2.2.3",
3
+ "version": "2.2.7",
4
4
  "description": "Inngage react integration",
5
5
  "main": "index.js",
6
6
  "scripts": {
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,