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 link = | |
new firebase.links.DynamicLink('https://example.com?param1=foo¶m2=bar', 'abc123.page.link') | |
.android.setPackageName('com.example.android') | |
.ios.setBundleId('com.example.ios'); | |
firebase.links() | |
.createShortDynamicLink(link, 'UNGUESSABLE') // <--- (Optional)SHORT or UNGUESSABLE | |
.then((url) => { | |
// ... | |
}); |
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 firebase from 'react-native-firebase'; | |
export const dynamicEventLink = async (id) => { | |
const link = | |
new firebase.links.DynamicLink( | |
encodeURI(`https://eventsmag.page.link/${id}`), | |
'eventsmag.page.link' | |
).android.setPackageName('app_android_package_name') | |
.ios.setBundleId('app_ios_bundle_id'); |
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
firebase.links() | |
.getInitialLink() | |
.then((url) => { | |
if (url) { | |
// app opened from a url | |
} else { | |
// app NOT opened from a url | |
} | |
}); |
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 {Platform, Linking} from 'react-native' | |
import firebase from 'react-native-firebase' | |
firebase.links() | |
.getInitialLink() | |
.then((url) => { | |
if (url) { | |
// app opened from a dynamic link URL | |
} else { | |
// use deep link to handle the URL. |
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
export async function calculateTripCost(from: Coords, to: Coords, numPassengers: number) { | |
try { | |
const res = await getDistanceAndDuration(from, to) // this is a google maps api for returning distance and duration | |
const { distance } = res | |
let { duration } = res | |
if (res.duration_in_traffic) { | |
duration = res.duration_in_traffic | |
} |
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
/** | |
* User signIn Http Request | |
*/ | |
import * as functions from 'firebase-functions'; | |
import * as APIRequest from 'request' | |
import { admin } from '../admin' // project is initialized before importing | |
const signInwithTokenURL = 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=[API_KEY]' | |
const lookUpUserURL = 'https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=[API_Key]' |
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
/** | |
* User updated trigger | |
*/ | |
import * as functions from 'firebase-functions' | |
import { createStripeCustomer } from './stripe'; | |
// listen for changes when user record is updated | |
export const userUpdatedTrigger = functions.firestore | |
.document('users/{userId}') | |
.onUpdate(async (change, context) => { |
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
/** | |
* Create your stripe customer | |
*/ | |
import * as functions from 'firebase-functions'; | |
import { DocumentSnapshot } from "firebase-functions/lib/providers/firestore"; | |
import * as Stripe from "stripe" | |
const secretKey = functions.config().stripe.key // ensure you have set the configuration | |
const stripe = new Stripe(secretKey) |
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
** | |
* Prompt to write or update the Spreadsheet | |
* ----------------------------------------- | |
* Detect an entry in a defined collection on the | |
* Firestore database. Listen for onCreate, onUpdate | |
* and onDelete | |
*/ | |
export const writeToSheetTrigger = functions.firestore | |
.document('collectionName/{docId}') | |
.onWrite(async (change, context) => { |
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
/** | |
* Logic for appending an Entry on the Spreadsheet | |
*/ | |
interface Metadata { | |
theRange: string | |
theData: (number|string)[][] | |
} | |
export function appendEntry(sheetsAPI: any, spreadsheetId: string, auth: any, metadata: Metadata) { | |
return new Promise((resolve, reject) => { |