2024-04-17 21:05:48 -04:00
|
|
|
import React from 'react';
|
2024-04-02 21:50:19 -04:00
|
|
|
// @ts-ignore: react-native-handoff is not in the type definition
|
|
|
|
import Handoff from 'react-native-handoff';
|
2024-04-17 21:05:48 -04:00
|
|
|
import { useSettings } from './Context/SettingsContext';
|
2024-04-02 21:50:19 -04:00
|
|
|
|
|
|
|
interface HandOffComponentProps {
|
|
|
|
url?: string;
|
|
|
|
title?: string;
|
|
|
|
type: (typeof HandOffComponent.activityTypes)[keyof typeof HandOffComponent.activityTypes];
|
|
|
|
userInfo?: object;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface HandOffComponentWithActivityTypes extends React.FC<HandOffComponentProps> {
|
|
|
|
activityTypes: {
|
|
|
|
ReceiveOnchain: string;
|
|
|
|
Xpub: string;
|
|
|
|
ViewInBlockExplorer: string;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const HandOffComponent: HandOffComponentWithActivityTypes = props => {
|
2024-04-17 21:05:48 -04:00
|
|
|
const { isHandOffUseEnabled } = useSettings();
|
2024-04-02 21:50:19 -04:00
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
console.log('HandOffComponent: props', props);
|
|
|
|
}
|
|
|
|
if (isHandOffUseEnabled) {
|
|
|
|
return <Handoff {...props} />;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
const activityTypes = {
|
|
|
|
ReceiveOnchain: 'io.bluewallet.bluewallet.receiveonchain',
|
|
|
|
Xpub: 'io.bluewallet.bluewallet.xpub',
|
|
|
|
ViewInBlockExplorer: 'io.bluewallet.bluewallet.blockexplorer',
|
|
|
|
};
|
|
|
|
|
|
|
|
HandOffComponent.activityTypes = activityTypes;
|
|
|
|
|
|
|
|
export default HandOffComponent;
|