* move `notifee.ts` to notifications folder * install expo notifications * add UIBackgroundMode `remote-notifications` to app.json * fix notifee import in Debug.tsx * add `google-services.json` * add `development-device` class to eas.json * Add `notifications.ts` for native notification handling * send push token to server * update `@atproto/api` * fix putting notif token to server * fix how push token is uploaded * fix lint * enable debug appview proxy header on all platforms * setup `notifications.ts` to work with app view notifs * clean up notification handler * add comments * update packages to correct versions * remove notifee * clean up code a lil * rename push token endpoint * remove unnecessary comments * fix comments * Remove old background scheduler * Fixes to push notifications API use * Bump @atproto/api@0.6.6 --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
/**
|
|
* APP-700
|
|
*
|
|
* This is a temporary debug setting we're running on the Web build to
|
|
* help the protocol team test some changes.
|
|
*
|
|
* It should be removed in ~2 weeks. It should only be used on the Web
|
|
* version of the app.
|
|
*/
|
|
|
|
import {useState, useCallback, useEffect} from 'react'
|
|
import {BskyAgent} from '@atproto/api'
|
|
import {isWeb} from 'platform/detection'
|
|
import * as Storage from 'lib/storage'
|
|
|
|
export function useDebugHeaderSetting(agent: BskyAgent): [boolean, () => void] {
|
|
const [enabled, setEnabled] = useState<boolean>(false)
|
|
|
|
useEffect(() => {
|
|
async function check() {
|
|
if (await isEnabled()) {
|
|
setEnabled(true)
|
|
}
|
|
}
|
|
check()
|
|
}, [])
|
|
|
|
const toggle = useCallback(() => {
|
|
if (!enabled) {
|
|
Storage.saveString('set-header-x-appview-proxy', 'yes')
|
|
agent.api.xrpc.setHeader('x-appview-proxy', 'true')
|
|
setEnabled(true)
|
|
} else {
|
|
Storage.remove('set-header-x-appview-proxy')
|
|
agent.api.xrpc.unsetHeader('x-appview-proxy')
|
|
setEnabled(false)
|
|
}
|
|
}, [setEnabled, enabled, agent])
|
|
|
|
return [enabled, toggle]
|
|
}
|
|
|
|
export function setDebugHeader(agent: BskyAgent, enabled: boolean) {
|
|
if (enabled) {
|
|
Storage.saveString('set-header-x-appview-proxy', 'yes')
|
|
agent.api.xrpc.setHeader('x-appview-proxy', 'true')
|
|
} else {
|
|
Storage.remove('set-header-x-appview-proxy')
|
|
agent.api.xrpc.unsetHeader('x-appview-proxy')
|
|
}
|
|
}
|
|
|
|
export async function applyDebugHeader(agent: BskyAgent) {
|
|
if (!isWeb) {
|
|
return
|
|
}
|
|
if (await isEnabled()) {
|
|
agent.api.xrpc.setHeader('x-appview-proxy', 'true')
|
|
}
|
|
}
|
|
|
|
async function isEnabled() {
|
|
return (await Storage.loadString('set-header-x-appview-proxy')) === 'yes'
|
|
}
|