Taishi Kato
Taishi Kato

Reputation: 410

How to use Firebase Authentication in Vue Native

I am using Vue Native with Firebase and try to make Firebase Auth work.
However, i can't.

I got this error message.

this operation is not supported in the environment this application is running on. location.protocol

I use Firebase Web SDK.

$ yarn add firebase

and I know what this error message means.

This application is native App and not running on http/https of course.

So what should I do to use Firebase with Vue Native?

Thanks in advance.

My code is here↓

<template>


<view class="container">
<button
  :on-press="signInWithGoogle"
  title="Sign In"
  color="#841584"
/>
</view>
</template>

<script>

import firebase from 'firebase';

const config = {
  apiKey: "API-KEY",
  authDomain: "authDomain",
  databaseURL: "databaseURL",
  projectId: "projectId",
  storageBucket: "storageBucket",
  messagingSenderId: "messagingSenderId"
};

const app = firebase.initializeApp(config);
const provider = new firebase.auth.GoogleAuthProvider();

export default {
  methods: {
    signInWithGoogle() {
      firebase.auth().signInWithRedirect(provider);
    }
  }

}

Upvotes: 0

Views: 1907

Answers (1)

Sanket Sahu
Sanket Sahu

Reputation: 8568

You can use react-native-firebase.

You can install using yarn

yarn add react-native-firebase

And start using their API as documented here.

You should use --no-crna when init'ing your project.

Upvotes: 1

Related Questions