美文网首页
Flutter Firebase集成

Flutter Firebase集成

作者: 郑了了了 | 来源:发表于2021-06-11 10:30 被阅读0次

    Firebase三方登录集成过程

    1. Add dependency

    dependencies:
      flutter:
        sdk: flutter
      firebase_core: "^0.7.0"
      firebase_auth: "^0.20.1"
    

    Google登录

    参考地址(https://firebase.flutter.dev/docs/auth/overview

    pubspec.yaml
    dependencies:
      google_sign_in: "^4.5.1"
    
    1. Android

    1.Firebase官网添加Android应用 https://console.firebase.google.com/u/0/
    2.准备包名,示例:com.example.untitled
    3.获取调试SHA-1签名(生产环境SHA-1签名)
    4.下载google-services.json添加至android/app目录下
    5.Android项目gradle下增加 classpath 'com.google.gms:google-services:4.3.4'
    6.app gradle下增加插件apply plugin: 'com.google.gms.google-services'

    2.Web

    1.Firebase官网添加web应用 https://console.firebase.google.com/u/0/
    2.添加SDK到html中

          <script src="https://www.gstatic.com/firebasejs/8.6.5/firebase-app.js"></script>
          <script src="https://www.gstatic.com/firebasejs/8.6.5/firebase-analytics.js</script>
    

    3.初始化Firebase(参考资料:https://developers.google.com/identity/sign-in/web/sign-in)

    var firebaseConfig = {
             // ...
           };
           // Initialize Firebase
           firebase.initializeApp(firebaseConfig);
    

    Twitter登录

    参考地址(https://firebase.flutter.dev/docs/auth/social#twitter

    pubspec.yaml
    dependencies:
      flutter_twitter_login: ^1.1.0
    

    Apple登录

    1.配置使用 Apple 登录(https://firebase.google.com/docs/auth/ios/apple#configure-sign-in-with-apple

    pubspec.yaml
    dependencies:
      sign_in_with_apple: ^2.5.2
      crypto: ^2.1.5
    

    注意:Firebase官方选择Authentication开启Google,Twitter,Apple登录提供程序

    相关文章

      网友评论

          本文标题:Flutter Firebase集成

          本文链接:https://www.haomeiwen.com/subject/qrsjeltx.html