Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react';
import { Notifications } from 'expo';
import { Alert, Platform } from 'react-native';
import { EventSubscription } from 'fbemitter';
import ComponentListScreen from './ComponentListScreen';
import { Screens } from '../navigation/ExpoApis';
try {
require('react-native-branch').default.subscribe((bundle: any) => {
if (bundle && bundle.params && !bundle.error) {
Alert.alert('Opened Branch link', JSON.stringify(bundle.params, null, 2));
}
});
} catch (e) {
// Branch is not available, do nothing
}
export default class ExpoApisScreen extends React.Component {
static path = '';
static navigationOptions = {
title: 'APIs in Expo SDK',
};
_notificationSubscription?: EventSubscription;
Engine.context.PersonalMessageManager.hub.on('unapprovedMessage', messageParams => {
if (!this.isTabActive()) return false;
this.setState({ signMessage: true, signMessageParams: messageParams, signType: 'personal' });
});
Engine.context.TypedMessageManager.hub.on('unapprovedMessage', messageParams => {
if (!this.isTabActive()) return false;
this.setState({ signMessage: true, signMessageParams: messageParams, signType: 'typed' });
});
Engine.context.AssetsController.hub.on('pendingSuggestedAsset', suggestedAssetMeta => {
if (!this.isTabActive()) return false;
this.setState({ watchAsset: true, suggestedAssetMeta });
});
Branch.subscribe(this.handleDeeplinks);
if (Platform.OS === 'ios') {
this.state.scrollAnim.addListener(({ value }) => {
const diff = value - this.scrollValue;
this.scrollValue = value;
this.clampedScrollValue = Math.min(Math.max(this.clampedScrollValue + diff, 0), BOTTOM_NAVBAR_HEIGHT);
});
this.state.offsetAnim.addListener(({ value }) => {
this.offsetValue = value;
});
} else {
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.keyboardDidHide);
}
// Listen to network changes
import Branch, { BranchEvent } from 'react-native-branch';
// Branch has a default and named export, add `BranchEvent` to the default export so it looks
// similar.
Branch.BranchEvent = BranchEvent;
export default Branch;
import React from 'react';
import { Alert, Button, StyleSheet, Text, View, Platform } from 'react-native';
import Constants from 'expo-constants';
let Branch = null;
if (Platform.OS !== 'web') {
try {
Branch = require('react-native-branch').default;
} catch (e) {
console.log('Branch is not supported on this platform.', e);
}
}
export default class BranchScreen extends React.Component {
static navigationOptions = {
title: 'Branch',
};
_branchUniversalObject?: any;
async _getOrCreateBranchObjectAsync() {
if (this._branchUniversalObject) {
return this._branchUniversalObject;
}
componentDidMount() {
DeeplinkManager.init(this.props.navigation);
this.unsubscribeFromBranch = Branch.subscribe(this.handleDeeplinks);
setTimeout(async () => {
const existingUser = await AsyncStorage.getItem('@MetaMask:existingUser');
if (existingUser !== null) {
await this.unlockKeychain();
} else {
this.animateAndGoTo('OnboardingRootNav');
}
}, 100);
}
componentDidMount() {
branch.subscribe(this.onDeepLinkData)
}
pressShare = async () => {
const { trashPoint, photo } = this.props;
const description = trashPoint.composition[0];
const branchUniversalObject = await branch
.createBranchUniversalObject(trashPoint.id, {
locallyIndex: true,
title: trashPoint.name,
contentDescription: description,
contentImageUrl: photo,
contentMetadata: {
ratingAverage: 4.2,
customMetadata: {
type: 'trashpoint',
name: trashPoint.name,
address: trashPoint.address,
amount: trashPoint.amount,
areas: trashPoint.areas.join(),
composition: trashPoint.composition.join(),
counter: trashPoint.counter.toString(),
createdAt: trashPoint.createdAt,
pressShare = async () => {
const { event, photo } = this.props;
const branchUniversalObject = await branch.createBranchUniversalObject(event.id, {
locallyIndex: true,
title: event.name,
contentDescription: event.description,
contentImageUrl: photo,
});
const linkProperties = {
feature: 'share',
channel: 'RNApp',
};
const controlParams = {
$desktop_url: 'https://www.worldcleanupday.org/map-it/',
$uri_redirect_mode: 2,
type: 'event',
};