Skip to content

Commit

Permalink
Implement sms invite on iOS, #1460
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanregisser committed Oct 30, 2019
1 parent 433838a commit e3a7b08
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions packages/mobile/ios/celo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 17 additions & 3 deletions packages/mobile/src/invite/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e3a7b08

Please sign in to comment.