Skip to content

Commit

Permalink
Prevent running notifications on a simulator/emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
kunall17 committed Jul 1, 2017
1 parent 7d7cd1b commit 1ae9d50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/MainScreenContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React from 'react';
import { connect } from 'react-redux';
import isEqual from 'lodash.isequal';
import DeviceInfo from 'react-native-device-info';

import config from '../config';
import boundActions from '../boundActions';
Expand All @@ -17,7 +18,9 @@ import { initializeNotifications } from '../utils/notifications';
class MainScreenContainer extends React.Component {
componentWillMount() {
const { auth, saveTokenPush, switchNarrow } = this.props;
initializeNotifications(auth, saveTokenPush, switchNarrow);
if (!DeviceInfo.isEmulator()) {
initializeNotifications(auth, saveTokenPush, switchNarrow);
}
}

componentWillReceiveProps(nextProps) {
Expand Down
4 changes: 3 additions & 1 deletion src/realm/realmActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* @flow */
import DeviceInfo from 'react-native-device-info';

import { Auth, Dispatch } from '../types';
import { homeNarrow, specialNarrow } from '../utils/narrow';
import { tryUntilSuccessful } from '../utils/async';
Expand Down Expand Up @@ -51,7 +53,7 @@ export const fetchRestOfInitialData = (auth: Auth, pushToken: string) =>
dispatch(initStreams(streams));
dispatch(initUsers(users));
dispatch(initRealmEmojis(realmEmoji));
if (auth.apiKey !== '' && pushToken === '') {
if (auth.apiKey !== '' && pushToken === '' && !DeviceInfo.isEmulator()) {
refreshNotificationToken();
}
};
Expand Down

0 comments on commit 1ae9d50

Please sign in to comment.