diff --git a/packages/mobile/ios/Podfile.lock b/packages/mobile/ios/Podfile.lock index 9fee4651c09..36c9c5d9c5d 100644 --- a/packages/mobile/ios/Podfile.lock +++ b/packages/mobile/ios/Podfile.lock @@ -311,6 +311,8 @@ PODS: - React - react-native-safe-area-context (0.5.0): - React + - react-native-sms (1.9.0): + - React - react-native-splash-screen (3.2.0): - React - react-native-tcp (3.3.0): @@ -446,6 +448,7 @@ DEPENDENCIES: - react-native-mail (from `../../../node_modules/react-native-mail`) - "react-native-netinfo (from `../../../node_modules/@react-native-community/netinfo`)" - react-native-safe-area-context (from `../../../node_modules/react-native-safe-area-context`) + - react-native-sms (from `../../../node_modules/react-native-sms`) - react-native-splash-screen (from `../../../node_modules/react-native-splash-screen`) - react-native-tcp (from `../../../node_modules/react-native-tcp`) - react-native-udp (from `../../../node_modules/react-native-udp`) @@ -553,6 +556,8 @@ EXTERNAL SOURCES: :path: "../../../node_modules/@react-native-community/netinfo" react-native-safe-area-context: :path: "../../../node_modules/react-native-safe-area-context" + react-native-sms: + :path: "../../../node_modules/react-native-sms" react-native-splash-screen: :path: "../../../node_modules/react-native-splash-screen" react-native-tcp: @@ -664,6 +669,7 @@ SPEC CHECKSUMS: react-native-mail: 7e37dfbe93ff0d4c7df346b738854dbed533e86f react-native-netinfo: 6bb847e64f45a2d69c6173741111cfd95c669301 react-native-safe-area-context: 13004a45f3021328fdd9ee1f987c3131fb65928d + react-native-sms: 6fc6a1581970f77253981c8c69cd0d303e1d991c react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865 react-native-tcp: e1a8c3ac010774cd71811989805ff3eaebb62f17 react-native-udp: 54a1aa9bf5c0824f930b1ba6dbfb3fd3e733bba9 diff --git a/packages/mobile/ios/celo.xcodeproj/project.pbxproj b/packages/mobile/ios/celo.xcodeproj/project.pbxproj index 30a4f78e570..b1eb6be22a6 100644 --- a/packages/mobile/ios/celo.xcodeproj/project.pbxproj +++ b/packages/mobile/ios/celo.xcodeproj/project.pbxproj @@ -507,6 +507,7 @@ "${BUILT_PRODUCTS_DIR}/react-native-mail/react_native_mail.framework", "${BUILT_PRODUCTS_DIR}/react-native-netinfo/react_native_netinfo.framework", "${BUILT_PRODUCTS_DIR}/react-native-safe-area-context/react_native_safe_area_context.framework", + "${BUILT_PRODUCTS_DIR}/react-native-sms/react_native_sms.framework", "${BUILT_PRODUCTS_DIR}/react-native-splash-screen/react_native_splash_screen.framework", "${BUILT_PRODUCTS_DIR}/react-native-tcp/react_native_tcp.framework", "${BUILT_PRODUCTS_DIR}/react-native-udp/react_native_udp.framework", @@ -567,6 +568,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_mail.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_netinfo.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_safe_area_context.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_sms.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_splash_screen.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_tcp.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_udp.framework", diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 93b5b310e07..6adfd1957b2 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -118,6 +118,7 @@ "react-native-send-intent": "git+https://github.com/celo-org/react-native-send-intent#a0f4b00", "react-native-shadow": "^1.2.2", "react-native-share": "^2.0.0", + "react-native-sms": "^1.9.0", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^9.11.1", "react-native-swiper": "^1.5.14", diff --git a/packages/mobile/src/invite/saga.ts b/packages/mobile/src/invite/saga.ts index e51ea618759..7cbc73d4f64 100644 --- a/packages/mobile/src/invite/saga.ts +++ b/packages/mobile/src/invite/saga.ts @@ -4,6 +4,7 @@ import { getEscrowContract, getGoldTokenContract, getStableTokenContract } from import BigNumber from 'bignumber.js' import { Linking, Platform } from 'react-native' import SendIntentAndroid from 'react-native-send-intent' +import SendSMS from 'react-native-sms' import VersionCheck from 'react-native-version-check' import { call, delay, put, race, select, spawn, takeLeading } from 'redux-saga/effects' import { showError, showMessage } from 'src/alert/actions' @@ -99,11 +100,24 @@ async function sendSms(toPhone: string, msg: string) { try { if (Platform.OS === 'android') { SendIntentAndroid.sendSms(toPhone, msg) + resolve() } else { - // TODO - throw new Error('Implement sendSms using MFMessageComposeViewController on iOS') + // react-native-sms types are incorrect + // tslint:disable-next-line: no-floating-promises + SendSMS.send( + { + body: msg, + recipients: [toPhone], + }, + (completed, cancelled, error) => { + if (!completed) { + reject(new Error(`Couldn't send sms: isCancelled: ${cancelled} isError: ${error}`)) + } else { + resolve() + } + } + ) } - resolve() } catch (e) { reject(e) } diff --git a/yarn.lock b/yarn.lock index 87e0e3e9862..578effb84a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -26680,6 +26680,11 @@ react-native-share@^2.0.0: resolved "https://registry.yarnpkg.com/react-native-share/-/react-native-share-2.0.0.tgz#4543a746013e0d8fa9f765fb8937007cfbcffcf7" integrity sha512-J8Xl3mq0L9KDFtSYtKsQDAnZWw/niZIpAD1PRiNfZFHo44Rc+oS2bEIhskNnoQXKEgBNdPzCl/DenMXYAHXRYg== +react-native-sms@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/react-native-sms/-/react-native-sms-1.9.0.tgz#362d94f75664d45144433d820155d9da66adf053" + integrity sha512-qq5v5rClCSMwTZL5TAK3P89SOQFrBwa6LyqCQV1Md0p78cS+DQWTX/wnb1H8gH32gDzr7barKTEXZPN7lZ5fCA== + react-native-splash-screen@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.2.0.tgz#d47ec8557b1ba988ee3ea98d01463081b60fff45"