Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Navigation } from 'react-native-navigation';
import { Screens, startApp } from 'screens';
import { Sentry } from 'react-native-sentry';
import codePush from 'react-native-code-push';
import config from 'config';
import Store, { StoreProvider } from 'store';
// Initialize Sentry
if (!__DEV__) {
Sentry.config(config.SENTRY_DSN).install();
}
// Set Sentry CodePush metadata
codePush.getUpdateMetadata().then((update) => {
if (update) {
Sentry.setVersion(`${update.appVersion}-codepush:${update.label}`);
}
});
// Create new instance of the Store
const store = new Store(config.SECRET_TOKEN);
// Register screens
Array.from(Screens.entries()).forEach(([screenConst, screenModule]) =>
Navigation.registerComponent(
screenConst,
screenModule,
store,
codePush(StoreProvider),
));
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
requestPermissions: true,
});
// We only need to do some things on first ever render
const fromSplash = this.props.navigation.getParam('fromSplash');
if (!isAndroid) {
const Spotlight = require('../extensions/spotlight');
Spotlight.addListener(this.handleSpotlightClick);
const id = await Spotlight.handleAppOpen();
if (fromSplash && id) {
this.props.navigation.push('DeploymentDetails', { id });
}
}
const update = await codePush.getUpdateMetadata();
if (fromSplash && update && update.isFirstRun && update.description) {
this.props.navigation.navigate('WhatsNew', { description: update.description });
}
};
const checkExtraCodepush = useCallback(async () => {
const meta = await CodePush.getUpdateMetadata();
console.log('[codepush] meta', meta);
}, []);
_appStateTimer = setTimeout(() => {
this._checkVersion();
CodePush.getUpdateMetadata().then(localPackage => {
if (localPackage == null) {
this._checkForUpdate();
} else {
if (localPackage.isPending) {
localPackage.install(CodePush.InstallMode.ON_NEXT_RESUME);
} else {
this._checkForUpdate();
}
}
});
clearTimeout(_appStateTimer);
}, 1000);
} else if (nextState == "background" && this.nextState != 'background') {
return flow(function* () {
self.updateMetadata = yield CodePush.getUpdateMetadata();
})();
},
componentDidMount() {
CodePush.getUpdateMetadata()
.then(update => {
if (update) {
this.setState({
version: `${update.appVersion}-codepush:${update.label}`,
})
}
})
.catch(e => {
Sentry.captureException(e)
})
}