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
| 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
| 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
| 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 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
| 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
| import { init, dispatch } from '@rematch/core' | |
| import delay from './makeMeWait.js' | |
| const count = { | |
| state: 0, | |
| reducers: { | |
| increment: (state, payload) => state + payload, | |
| decrement: (state, payload) => state - payload, | |
| }, | |
| effects: { |
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 anyActionCreator = (namespace, type) => (payload) => ({ | |
| type: `${namespace}/${type}`, | |
| payload | |
| }) |
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 count = { | |
| state: 0, | |
| reducers: { | |
| increment: (state, action) => state + action.payload, | |
| decrement: (state, action) => state - action.payload, | |
| } | |
| } |
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 incrementAsync = async (count) => { | |
| await delay() | |
| dispatch(increment(count)) | |
| } |