diff --git a/examples/client/Locomotion/ios/Podfile.lock b/examples/client/Locomotion/ios/Podfile.lock index abe752b0e..343f89091 100644 --- a/examples/client/Locomotion/ios/Podfile.lock +++ b/examples/client/Locomotion/ios/Podfile.lock @@ -1,4 +1,7 @@ PODS: + - AppsFlyerFramework (6.13.1): + - AppsFlyerFramework/Main (= 6.13.1) + - AppsFlyerFramework/Main (6.13.1) - boost (1.76.0) - BVLinearGradient (2.6.2): - React-Core @@ -318,6 +321,9 @@ PODS: - React-jsinspector (0.68.5) - React-logger (0.68.5): - glog + - react-native-appsflyer (6.13.1): + - AppsFlyerFramework (= 6.13.1) + - React - react-native-background-timer (2.4.1): - React-Core - react-native-carrier-info (1.1.2): @@ -537,6 +543,7 @@ DEPENDENCIES: - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) - React-logger (from `../node_modules/react-native/ReactCommon/logger`) + - react-native-appsflyer (from `../node_modules/react-native-appsflyer`) - react-native-background-timer (from `../node_modules/react-native-background-timer`) - react-native-carrier-info (from `../node_modules/react-native-carrier-info`) - react-native-config (from `../node_modules/react-native-config`) @@ -584,6 +591,7 @@ DEPENDENCIES: SPEC REPOS: trunk: + - AppsFlyerFramework - Firebase - FirebaseCore - FirebaseCoreDiagnostics @@ -652,6 +660,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/jsinspector" React-logger: :path: "../node_modules/react-native/ReactCommon/logger" + react-native-appsflyer: + :path: "../node_modules/react-native-appsflyer" react-native-background-timer: :path: "../node_modules/react-native-background-timer" react-native-carrier-info: @@ -742,6 +752,7 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/yoga" SPEC CHECKSUMS: + AppsFlyerFramework: 971521cf5b890c2afeab2f2c91734547b8b169ca boost: a7c83b31436843459a1961bfd74b96033dc77234 BVLinearGradient: 34a999fda29036898a09c6a6b728b0b4189e1a44 DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 @@ -779,6 +790,7 @@ SPEC CHECKSUMS: React-jsiexecutor: 45c0496ca8cef6b02d9fa0274c25cf458fe91a56 React-jsinspector: eb202e43b3879aba9a14f3f65788aec85d4e1ea9 React-logger: 98f663b292a60967ebbc6d803ae96c1381183b6d + react-native-appsflyer: 7cf84f144123de4dd2c772d0be8e16ea6a66f681 react-native-background-timer: 117fffdc9b0d6f144444bb49029f94275a45fdb5 react-native-carrier-info: 1e6299256bd7ceaa36f851b30e071b2b4fc406ad react-native-config: bcafda5b4c51491ee1b0e1d0c4e3905bc7b56c1b @@ -831,6 +843,6 @@ SPEC CHECKSUMS: StripeUICore: 08c1efbd7e3c54ee7fa74334a37a1d4c08ba944d Yoga: c4d61225a466f250c35c1ee78d2d0b3d41fe661c -PODFILE CHECKSUM: 42909390370d7a65830c84fab99e66e070f1b4f9 +PODFILE CHECKSUM: 3d1a03e0b2517741427327a9545b9919923582eb -COCOAPODS: 1.12.1 +COCOAPODS: 1.12.0 diff --git a/examples/client/Locomotion/package-lock.json b/examples/client/Locomotion/package-lock.json index 6cfec6e09..fa42973f2 100644 --- a/examples/client/Locomotion/package-lock.json +++ b/examples/client/Locomotion/package-lock.json @@ -7190,7 +7190,7 @@ "decamelize-keys": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", - "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", + "integrity": "sha512-ocLWuYzRPoS9bfiSdDd3cxvrzovVMZnRDVEzAs+hWIVXGDbHxWMECij2OBuyB/An0FFW/nLuq6Kv1i/YC5Qfzg==", "requires": { "decamelize": "^1.1.0", "map-obj": "^1.0.0" @@ -7199,7 +7199,7 @@ "map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" + "integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==" } } }, @@ -7212,7 +7212,7 @@ "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" + "integrity": "sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==" }, "dedent": { "version": "0.6.0", @@ -8425,7 +8425,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, @@ -14460,6 +14460,11 @@ "prop-types": "^15.7.2" } }, + "react-native-appsflyer": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/react-native-appsflyer/-/react-native-appsflyer-6.13.1.tgz", + "integrity": "sha512-isJHrClob2IKGkhHWDagW5YrYWcoFRRD8+2mc/i1mLVFUtRFE4p6mx1I/z86JH9dq7xdiKZaD2mQXx60A6ruEQ==" + }, "react-native-background-timer": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/react-native-background-timer/-/react-native-background-timer-2.4.1.tgz", @@ -15701,7 +15706,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, @@ -16831,7 +16836,7 @@ "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + "integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==" }, "word-wrap": { "version": "1.2.3", diff --git a/examples/client/Locomotion/package.json b/examples/client/Locomotion/package.json index 7fa9978a6..85f765e9c 100644 --- a/examples/client/Locomotion/package.json +++ b/examples/client/Locomotion/package.json @@ -56,6 +56,7 @@ "react": "17.0.2", "react-i18next": "^11.7.2", "react-native": "^0.68.5", + "react-native-appsflyer": "^6.13.1", "react-native-background-timer": "^2.4.1", "react-native-carrier-info": "^1.1.2", "react-native-config": "^1.4.5", diff --git a/examples/client/Locomotion/src/Components/BusinessAccountText/index.tsx b/examples/client/Locomotion/src/Components/BusinessAccountText/index.tsx deleted file mode 100644 index 01d3cd986..000000000 --- a/examples/client/Locomotion/src/Components/BusinessAccountText/index.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { BoldTitle, SubTitle, TitleWithSubTitle } from './styled'; - -interface BusinessAccountTextProps { - title: string; - subTitle: string; -} -const BusinessAccountText = ({ - title, subTitle, -} : BusinessAccountTextProps) => ( - - {title} - {subTitle} - -); - -export default BusinessAccountText; diff --git a/examples/client/Locomotion/src/Components/BusinessAccountText/styled.ts b/examples/client/Locomotion/src/Components/BusinessAccountText/styled.ts deleted file mode 100644 index 8489378fb..000000000 --- a/examples/client/Locomotion/src/Components/BusinessAccountText/styled.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Text, View } from 'react-native'; -import styled from 'styled-components'; -import { FONT_SIZES, FONT_WEIGHTS } from '../../context/theme'; - -export const TitleWithSubTitle = styled(View)` - display: flex; - flex-direction: column; - flex: 1 0 0; -`; -export const BaseText = styled(Text)` -color: #212229; -${FONT_SIZES.LARGE}; -font-family: Inter; -font-style: normal; -line-height: 20px; -`; -export const SubTitle = styled(BaseText)` -font-weight: 500; -`; -export const BoldTitle = styled(BaseText)` -font-weight: 700; -`; diff --git a/examples/client/Locomotion/src/Components/CardRow/index.tsx b/examples/client/Locomotion/src/Components/CardRow/index.tsx index 72bb48ba1..ad83d7a05 100644 --- a/examples/client/Locomotion/src/Components/CardRow/index.tsx +++ b/examples/client/Locomotion/src/Components/CardRow/index.tsx @@ -5,7 +5,6 @@ import { View, Text } from 'react-native'; import moment from 'moment'; import styled, { ThemeContext } from 'styled-components'; import { PaymentIcon } from 'react-native-payment-icons'; -import BusinessAccountText from '../BusinessAccountText'; import { RideInterface, RidePageContext } from '../../context/newRideContext'; import { PAYMENT_METHODS, paymentMethodToIconMap } from '../../pages/Payments/consts'; import Button from '../Button'; @@ -204,19 +203,11 @@ const CardRow = (paymentMethod: any) => { ) : ( <> - { - (businessAccountId && offlinePaymentText) - ? ( - - ) - : ( - - {getPaymentMethodTitle()} - - )} + + + {getPaymentMethodTitle()} + + {paymentMethod.lastFour ? {getLastFourForamttedShort(paymentMethod.lastFour)} : null} diff --git a/examples/client/Locomotion/src/Components/RideCard/index.tsx b/examples/client/Locomotion/src/Components/RideCard/index.tsx index ed7902ca4..1a914469b 100644 --- a/examples/client/Locomotion/src/Components/RideCard/index.tsx +++ b/examples/client/Locomotion/src/Components/RideCard/index.tsx @@ -93,7 +93,7 @@ const RideCard = ({ const { getRidePriceCalculation, } = useContext(RidePageContext); - const { businessAccountId } = useContext(RidePageContext); + const { getBusinessAccountById } = PaymentContext.useContainer(); const { showPrice, loadShowPrice } = SettingContext.useContainer(); @@ -109,8 +109,8 @@ const RideCard = ({ }, [ride]); useEffect(() => { - showPriceBasedOnAccount(loadShowPrice, getBusinessAccountById, businessAccountId); - }, [businessAccountId]); + showPriceBasedOnAccount(loadShowPrice, getBusinessAccountById, ride.businessAccountId); + }, [ride.businessAccountId]); const formatScheludedTo = async (time: any) => { try { diff --git a/examples/client/Locomotion/src/Components/TextRowWithIcon/index.tsx b/examples/client/Locomotion/src/Components/TextRowWithIcon/index.tsx index 4d801026a..e1c6386bb 100644 --- a/examples/client/Locomotion/src/Components/TextRowWithIcon/index.tsx +++ b/examples/client/Locomotion/src/Components/TextRowWithIcon/index.tsx @@ -1,7 +1,6 @@ import React, { useContext } from 'react'; import { Text, View } from 'react-native'; import styled, { ThemeContext } from 'styled-components'; -import BusinessAccountText from '../BusinessAccountText'; import { FONT_SIZES } from '../../context/theme'; import SvgIcon from '../SvgIcon'; @@ -57,13 +56,7 @@ const TextRowWithIcon = ({ ...((Image || icon) && { marginLeft: 10 }), }} > - {subTitle ? ( - - ) - : text} + {text} ); diff --git a/examples/client/Locomotion/src/LocomotionRouter.js b/examples/client/Locomotion/src/LocomotionRouter.js index ef527a10f..aa684562a 100644 --- a/examples/client/Locomotion/src/LocomotionRouter.js +++ b/examples/client/Locomotion/src/LocomotionRouter.js @@ -17,6 +17,7 @@ import MessagesProvider from './context/messages'; import CancellationReasonsProvider from './context/cancellation-reasons'; import VirtualStationsProvider from './context/virtualStationsContext'; import Mixpanel from './services/Mixpanel'; +import initAppsFlyer from './services/appsflyer'; LogBox.ignoreAllLogs(); @@ -49,6 +50,7 @@ export default (props) => { useEffect(() => { sendAppLaunchEvent(); crashlytics().log('App mounted.'); + initAppsFlyer(); enableScreens(false); const listener = registerAppStateListener(); return () => { diff --git a/examples/client/Locomotion/src/context/payments/index.js b/examples/client/Locomotion/src/context/payments/index.js index 426aea373..1e184f37e 100644 --- a/examples/client/Locomotion/src/context/payments/index.js +++ b/examples/client/Locomotion/src/context/payments/index.js @@ -201,7 +201,9 @@ const usePayments = () => { if (relevantBusinessAccount) { return relevantBusinessAccount; } - return null; + // this means the client no longer have access to the business account, or BA was deleted + // requires a fallback object to avoid breaking the app + return {}; }; return { diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PaymentButton/index.tsx b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PaymentButton/index.tsx index fb2739ae4..1e7f43bcd 100644 --- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PaymentButton/index.tsx +++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PaymentButton/index.tsx @@ -6,7 +6,6 @@ import { PaymentIcon } from 'react-native-payment-icons'; import styled, { ThemeContext } from 'styled-components'; import { useFocusEffect } from '@react-navigation/native'; import SkeletonContent from 'react-native-skeleton-content-nonexpo'; -import BusinessAccountText from '../../../../../../Components/BusinessAccountText'; import { isCardPaymentMethod, isCashPaymentMethod, isOfflinePaymentMethod } from '../../../../../../lib/ride/utils'; import { getCouponText } from '../../../../../../context/newRideContext/utils'; import { MAIN_ROUTES } from '../../../../../routes'; @@ -77,7 +76,6 @@ interface PaymentButtonProps { brand?: Brand; id?: string; invalid?: boolean; - subTitle?: string; } @@ -87,7 +85,6 @@ const PaymentButton = ({ brand, id, invalid, - subTitle, }: PaymentButtonProps) => { const { primaryColor } = useContext(ThemeContext); const { getCoupon, coupon, setCoupon } = useContext(UserContext); @@ -168,9 +165,7 @@ const PaymentButton = ({ width={40} /> )} - { subTitle - ? - : {title} } + {title} {loadPromoButton()} @@ -185,5 +180,4 @@ PaymentButton.defaultProps = { brand: null, id: null, invalid: false, - subTitle: null, }; diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx index 31756c55d..f33c0d114 100644 --- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx +++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx @@ -269,7 +269,6 @@ const RideButtons = ({ brand={selectedPaymentMethod?.brand} icon={paymentMethodToIconMap[selectedPaymentMethod?.id]} title={getSelectedPaymentMethodTitle()} - subTitle={businessAccountId && offlinePaymentText} id={selectedPaymentMethod?.id} invalid={paymentMethodNotAllowedOnService} /> diff --git a/examples/client/Locomotion/src/services/appsflyer.ts b/examples/client/Locomotion/src/services/appsflyer.ts new file mode 100644 index 000000000..5d13574f5 --- /dev/null +++ b/examples/client/Locomotion/src/services/appsflyer.ts @@ -0,0 +1,36 @@ +import { Platform } from 'react-native'; +import appsFlyer from 'react-native-appsflyer'; +import Config from 'react-native-config'; + +const LOG_PREFIX = 'APPSFLYER INTEG'; +const { ANDROID_APPSFLYER_DEV_KEY, IOS_APPSFLYER_DEV_KEY, IOS_APP_ID } = Config; +const PLATFORM_CONFIG: any = { + android: { + devKey: ANDROID_APPSFLYER_DEV_KEY, + }, + ios: { + devKey: IOS_APPSFLYER_DEV_KEY, + appId: IOS_APP_ID, + timeToWaitForATTUserAuthorization: 10, // for iOS 14.5 + }, +}; + +export default () => { + const config = PLATFORM_CONFIG[Platform.OS]; + if (config?.devKey) { + appsFlyer.initSdk( + { + ...config, + isDebug: false, + onInstallConversionDataListener: true, // Optional + onDeepLinkListener: true, // Optional + }, + (result) => { + console.log(`${LOG_PREFIX} SUCCESS`, result); + }, + (error) => { + console.error(`${LOG_PREFIX} ERROR`, error); + }, + ); + } +};