How to use react-native-firebase - 10 common examples

To help you get started, we’ve selected a few react-native-firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uport-project / uport-mobile / lib / sagas / notifications.js View on Github external
function * getInitialNotification () {
  try {
    // console.log('getInitialNotification')
    const message = yield call([firebase.notifications(), 'getInitialNotification'])
    if (!message) return
    yield handleMessage(message.notification.data)
  } catch (error) {
    console.log(error)
  }
}
github natuanorg / react-native-starter-kit / App.js View on Github external
async requestPermission() {
        try {
            await firebase.messaging().requestPermission();
            // User has authorised
            this.getToken();
        } catch (error) {
            // User has rejected permissions
            console.log('permission rejected');
        }
    }
github blockmason / lndr-mobile / packages / ui / dialogs / add-debt / index.tsx View on Github external
const { friend, amount, memo, currency, sendViaLink } = this.state
    let success

    if (sendViaLink) {
      const { state: { user: { address } }, getUcacFromCurrency, sendEmailTx } = this.props
      const ucac = getUcacFromCurrency(currency)
      const inviteTx = new InviteTransaction({ address, amount, memo, ucac, direction, currency })

      const buildLink = new firebase.links.DynamicLink(inviteTx.hash, 'lndr.page.link')
      buildLink
      .android.setPackageName('com.lndr')
      .android.setFallbackUrl('https://play.google.com/store/apps/details?id=com.lndr')
      .ios.setAppStoreId('1322487591')
      .ios.setBundleId('io.lndr')

      firebase.links().createDynamicLink(buildLink)
      .then(url => {
        Share.share({
          message: `${splitExpense}: ${url}`,
          url: url,
          title: splitExpense
        }, {
          // Android only:
          dialogTitle: splitExpense
        })
        .then( async() => {
          console.log(3)
          try {
            console.log(4)
            await submittingTransaction.wrap(sendEmailTx(inviteTx))
            console.log(5)
            this.clearAndGoHome(friend, { type: true })
github blockmason / lndr-mobile / packages / ui / views / new-transaction / index.tsx View on Github external
const { friend, amount, memo, currency, nonFriend } = this.state
    let success

    if (nonFriend) {
      try {
        const { state: { user: { address } }, getUcacFromCurrency, sendEmailTx } = this.props
        const ucac = getUcacFromCurrency(currency)
        const inviteTx = new InviteTransaction({ address, amount, memo, ucac, direction, currency })

        const buildLink = new firebase.links.DynamicLink('https://blockmason.io/lndr', 'lndr.page.link')
        buildLink
        .android.setPackageName('com.lndr')
        .ios.setAppStoreId('1322487591')
        .ios.setBundleId('io.lndr')
      
        const url = await firebase.links().createShortDynamicLink(buildLink, "SHORT")

        const { action } : any = await Share.share({
          message: `${splitExpense}: ${url}?hash=${inviteTx.hash}`,
          title: splitExpense
        }, {
          dialogTitle: splitExpense // Android only
        })
        
        if (action === Share.sharedAction) {
          await submittingTransaction.wrap(sendEmailTx(inviteTx))
          this.clearAndGoHome(friend, { type: true })
        }
      } catch(error) {
        console.log('ERROR SENDING EMAIL TRANSACTION: ', error)
      }
    } else {
github RSG-Group / RSG-Chess-mobile / App.js View on Github external
import Settings from "./src/pages/Settings";
import About from "./src/pages/About";
import Privacy from "./src/pages/Privacy";
import NewGame from "./src/pages/NewGame";
import SplashScreen from "react-native-splash-screen";

type Props = {};
let game = Game.prototype.initializeGame();
const blankFEN = game.FEN;

// Set up Firebase
firebase.perf().setPerformanceCollectionEnabled(true);

// Set up AdMob
firebase.admob().initialize("ca-app-pub-3522556458609123~4498098193");
let interstitial = firebase
  .admob()
  .interstitial("ca-app-pub-3522556458609123/5974831399");
let AdRequest = firebase.admob.AdRequest;
// request.addKeyword('foo').addKeyword('bar');
interstitial.loadAd(new AdRequest().build());
interstitial.on("onAdClosed", () => {
  interstitial.loadAd(new AdRequest().build());
});

let language = NativeModules.I18nManager.localeIdentifier.split(`_`)[0];
firebase.crashlytics().setStringValue("initial_language", language);

const supportedLangs = Object.keys(strings.languages);
if (!includes(supportedLangs, language)) language = "en";

const supportedPalettes = Object.keys(colorPalettes);
github RSG-Group / RSG-Chess-mobile / App.js View on Github external
import Play from "./src/pages/Play";
import Settings from "./src/pages/Settings";
import About from "./src/pages/About";
import Privacy from "./src/pages/Privacy";
import NewGame from "./src/pages/NewGame";
import SplashScreen from "react-native-splash-screen";

type Props = {};
let game = Game.prototype.initializeGame();
const blankFEN = game.FEN;

// Set up Firebase
firebase.perf().setPerformanceCollectionEnabled(true);

// Set up AdMob
firebase.admob().initialize("ca-app-pub-3522556458609123~4498098193");
let interstitial = firebase
  .admob()
  .interstitial("ca-app-pub-3522556458609123/5974831399");
let AdRequest = firebase.admob.AdRequest;
// request.addKeyword('foo').addKeyword('bar');
interstitial.loadAd(new AdRequest().build());
interstitial.on("onAdClosed", () => {
  interstitial.loadAd(new AdRequest().build());
});

let language = NativeModules.I18nManager.localeIdentifier.split(`_`)[0];
firebase.crashlytics().setStringValue("initial_language", language);

const supportedLangs = Object.keys(strings.languages);
if (!includes(supportedLangs, language)) language = "en";
github RSG-Group / RSG-Chess-mobile / App.js View on Github external
import { strings, colorPalettes } from "./src/config";
import NavigationContext from "./src/components/NavigationContext";

import Play from "./src/pages/Play";
import Settings from "./src/pages/Settings";
import About from "./src/pages/About";
import Privacy from "./src/pages/Privacy";
import NewGame from "./src/pages/NewGame";
import SplashScreen from "react-native-splash-screen";

type Props = {};
let game = Game.prototype.initializeGame();
const blankFEN = game.FEN;

// Set up Firebase
firebase.perf().setPerformanceCollectionEnabled(true);

// Set up AdMob
firebase.admob().initialize("ca-app-pub-3522556458609123~4498098193");
let interstitial = firebase
  .admob()
  .interstitial("ca-app-pub-3522556458609123/5974831399");
let AdRequest = firebase.admob.AdRequest;
// request.addKeyword('foo').addKeyword('bar');
interstitial.loadAd(new AdRequest().build());
interstitial.on("onAdClosed", () => {
  interstitial.loadAd(new AdRequest().build());
});

let language = NativeModules.I18nManager.localeIdentifier.split(`_`)[0];
firebase.crashlytics().setStringValue("initial_language", language);
github pillarwallet / pillarwallet / src / actions / notificationsActions.js View on Github external
return async (dispatch: Function, getState: Function) => { // eslint-disable-line
    const notificationOpen = await firebase.notifications().getInitialNotification();
    if (notificationOpen) {
      checkForSupportAlert(notificationOpen.notification._data);
      const { type, navigationParams } = processNotification(notificationOpen.notification._data) || {};
      const notificationRoute = NOTIFICATION_ROUTES[type] || null;
      updateNavigationLastScreenState({
        lastActiveScreen: notificationRoute,
        lastActiveScreenParams: navigationParams,
      });
      firebase.notifications().setBadge(0);
    }
    if (notificationsOpenerListener) return;
    notificationsOpenerListener = firebase.notifications().onNotificationOpened((message) => {
      checkForSupportAlert(message.notification._data);
      firebase.notifications().setBadge(0);
      const pathAndParams = getNavigationPathAndParamsState();
      if (!pathAndParams) return;
github evollu / react-native-fcm / Examples / firebase-migration / app / App.js View on Github external
async componentDidMount(){
    // Build a channel
    const channel = new firebase.notifications.Android.Channel('test-channel', 'Test Channel', firebase.notifications.Android.Importance.Max)
    .setDescription('My apps test channel');

    // Create the channel
    firebase.notifications().android.createChannel(channel);

    registerAppListener(this.props.navigation);
    firebase.notifications().getInitialNotification()
      .then((notificationOpen: NotificationOpen) => {
        if (notificationOpen) {
          // Get information about the notification that was opened
          const notif: Notification = notificationOpen.notification;
          this.setState({
            initNotif: notif.data
          })
          if(notif && notif.targetScreen === 'detail'){
            setTimeout(()=>{
              this.props.navigation.navigate('Detail')
            }, 500)
          }
        }
github vikrantnegi / local-reminders / App.js View on Github external
createNotificationChannel = () => {
    // Build a android notification channel
    const channel = new firebase.notifications.Android.Channel(
      'reminder',
      'Reminders Channel',
      firebase.notifications.Android.Importance.High
    ).setDescription('Used for getting reminder notification');

    // Create the android notification channel
    firebase.notifications().android.createChannel(channel);
  };