This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const twilio = require('./utils/twilio'); | |
| class TwilioSMS { | |
| constructor(messagingServiceSid, account) { | |
| this.from = messagingServiceSid; | |
| this.sms = twilio.init(account); | |
| this.sendSMS = ({ to, body }) => this.sms.create({ to, body, messagingServiceSid: this.from }); | |
| this.attempts = 0; | |
| } | |
| send(to, body) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const twilio = require('twilio'); | |
| // created in order to stub twilio in tests | |
| module.exports = { | |
| init: () => twilio(ACCOUNT_ID, AUTH_TOKEN).messages, | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Notifications } from 'expo' | |
| Notifications.addListener(async ({ data, origin }) => { | |
| if (origin === 'received') { | |
| // trigger modal | |
| } else if (origin === 'selected') { | |
| // route to page with linked data | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Expo = require('expo-server-sdk') | |
| const expo = new Expo() | |
| async function send(messages) { | |
| const chunks = expo.chunkPushNotifications(messages) | |
| for (const chunk of chunks) { | |
| try { | |
| const receipts = await expo.sendPushNotificationsAsync(chunk) | |
| receipts.forEach(receipt => { | |
| if (receipt.status === 'error') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DeepLink { | |
| constructor(branchKey) { | |
| this.key = branchKey; | |
| this.url = 'https://api.branch.io/v1/url'; | |
| } | |
| request(data) { | |
| return fetch(this.url, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { DangerZone } from 'expo' | |
| const { Branch } = DangerZone | |
| Branch.subscribe((bundle) => { | |
| if (bundle && bundle.params && !bundle.error) { | |
| // handle link | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Permissions } from 'expo' | |
| export default async function verifyPushNotificationsPermissions() { | |
| const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS) | |
| let finalStatus = existingStatus | |
| // only ask if permissions have not already been determined, because | |
| // iOS won't necessarily prompt the user a second time. | |
| if (existingStatus !== 'granted') { | |
| // Android remote notification permissions are granted during the app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1) | |
| // lib, returns Context.Provider, Context. | |
| function reactXState ({ name, machine, actions }) { | |
| name = name || 'defaultName' | |
| const Context = React.createContext(name) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DrawerOpen* | |
| loadTape -> HasTape | |
| closeDrawer -> NoTape | |
| DrawerClosed | |
| eject -> DrawerOpen | |
| NoTape | |
| HasTape* |