GithubHelp home page GithubHelp logo

firebase-multiplatform's Introduction

Firebase wrappers for Kotlin Multiplatform Download Build Status

Kotlin Multiplatform is great, Firebase is great, why not use them togheter?

This library aims to bridge the common Firebase APIs in different platforms so that it is possible to use them in Kotlin Multiplatform!

All APIs look and feel will try to stay faithful to the Android version as much as possible since Kotlin has been created mostly with Java into account. As consequence of that, until a proper documentation is available use the official Firebase Android/Java documentation

How it works

Each class or interface has a platform specific delegate that is actually doing all the stuff inside the object. You can access this delegate only when ia a specific platform sources.

Platforms

Since Firebase has many platforms and services, covering them all by myself is kind of hard, especially for the Objective-C one. I will list the ones that i want to support by myself, but pull requests are welcome!

  • Android:
    • core ✅
    • auth ✅
    • storage ✅
      • storage-mobile [HALTED] #10
    • firestore [TODO]
  • JS web client:
    • core ✅ (probably bugged)
    • auth ✅ (probably bugged)
    • storage ✅ (probably bugged)
    • firestore [TODO]
  • iOS:
    • core ✅
    • auth ✅
    • storage ✅
      • storage-mobile [HALTED] #10
    • firestore [TODO]

Some examples

FirebaseApp initialization:

// common sources
val fApp: FirebaseApp = FirebaseApp.initializeApp {
    setApiKey("mkey")
    setApplicationId("mAppId")
    setDatabaseUrl("dbUrl")
    setProjectId("projectId")
    setStorageBucket("bucket")
    setGcmSenderId("i have no idea what this is")
}

FirebaseAuth initialization and auth changes:

// get the default firebase auth 
// instance and listen to auth changes
// in global scope
val job = FirebaseAuth.default.authStateFlow
    // this will be executed in main thread 
    // as the official documentation states!        
    .onEach { isLoggedIn -> /*do stuff*/ }
    .launchIn(GlobalScope)
    
    // stop listening and detach listener
    job.cancel()

Install Download

Packages are available at my Bintray repo:

repositories {
    maven("https://dl.bintray.com/lamba92/com.github.lamba92")
}

Someday I will setup the sign of the packes so that they will be mirrored to Maven Central Repository, but today is not that day!

Add in common sources:

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("com.github.lamba92:firebase-multiplatform-core:0.0.2")
                implementation("com.github.lamba92:firebase-multiplatform-auth:0.0.2")
            }
        }    
    }
}

firebase-multiplatform's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ciurlaro

firebase-multiplatform's Issues

JS externals

At the moment is impossible to generate externals using Dukat v0.0.24 due to Dukat/issues#197.

Until proper externals are available I will not start working on the JS sources.

Project wont compile using the core and auth dependency using Gradle 5.6.4

Thank you for creating these libraries, but still, I am not able to include them in my project. I am having difficulties including the core and auth libs in my common main module as am getting some variant error.

Anyway, I am not using any flavours in the android project. The Gradle version is 5.6.4.

What could be the problem here and please feel free to ask me for more info on it?

Thank you in advance for your help!

Here is the error:

Could not determine the dependencies of task ':androidApp:dataBindingMergeDependencyArtifactsDebug'.
> Could not resolve all task dependencies for configuration ':androidApp:debugRuntimeClasspath'.
   > Could not resolve com.github.lamba92:firebase-multiplatform-core:0.1.8.
     Required by:
         project :androidApp > project :shared
      > Unable to find a matching variant of com.github.lamba92:firebase-multiplatform-core:0.1.8:
          - Variant 'android-releaseApiElements' capability com.github.lamba92:firebase-multiplatform-core:0.1.8:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found compatible value 'androidJvm'.
          - Variant 'android-releaseRuntimeElements' capability com.github.lamba92:firebase-multiplatform-core:0.1.8:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found compatible value 'androidJvm'.
          - Variant 'iosArm64-api' capability com.github.lamba92:firebase-multiplatform-core:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'native'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.native.target 'ios_arm64' but wasn't required.
          - Variant 'iosX64-api' capability com.github.lamba92:firebase-multiplatform-core:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'native'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.native.target 'ios_x64' but wasn't required.
          - Variant 'js-api' capability com.github.lamba92:firebase-multiplatform-core:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'js'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
          - Variant 'js-runtime' capability com.github.lamba92:firebase-multiplatform-core:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-runtime'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'js'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
          - Variant 'metadata-api' capability com.github.lamba92:firebase-multiplatform-core:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'common'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
   > Could not resolve com.github.lamba92:firebase-multiplatform-auth:0.1.8.
     Required by:
         project :androidApp > project :shared
      > Unable to find a matching variant of com.github.lamba92:firebase-multiplatform-auth:0.1.8:
          - Variant 'android-releaseApiElements' capability com.github.lamba92:firebase-multiplatform-auth:0.1.8:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found compatible value 'androidJvm'.
          - Variant 'android-releaseRuntimeElements' capability com.github.lamba92:firebase-multiplatform-auth:0.1.8:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found compatible value 'androidJvm'.
          - Variant 'iosArm64-api' capability com.github.lamba92:firebase-multiplatform-auth:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'native'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.native.target 'ios_arm64' but wasn't required.
          - Variant 'iosX64-api' capability com.github.lamba92:firebase-multiplatform-auth:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'native'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.jetbrains.kotlin.native.target 'ios_x64' but wasn't required.
          - Variant 'js-api' capability com.github.lamba92:firebase-multiplatform-auth:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'js'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
          - Variant 'js-runtime' capability com.github.lamba92:firebase-multiplatform-auth:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-runtime'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'js'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
          - Variant 'metadata-api' capability com.github.lamba92:firebase-multiplatform-auth:0.1.8:
              - Incompatible attributes:
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'androidJvm' and found incompatible value 'common'.
              - Other attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.

Did you generate the code or write it for @file:JsModule ?

I see that a lot of code is available under import firebase.app etc.. which connects with the js module from kotlin, did you write it or generate it somehow ?


@file:JsModule("firebase")
@file:JsNonModule
@file:JsQualifier("auth")
@file:Suppress(
  "INTERFACE_WITH_SUPERCLASS",
  "OVERRIDING_FINAL_MEMBER",
  "RETURN_TYPE_MISMATCH_ON_OVERRIDE",
  "CONFLICTING_OVERLOADS",
  "EXTERNAL_DELEGATION"
)

Upload from file or uri

At the moment there no common available notion of File or Uri. While an Uri common class may be available some time in the future, a unified notion of file probably won't due to the low level nature of the it.

TaskSnapshot.task missing

It is impossible to keep track of the task type inside the snapshot unless using an inner class. If going inner, you have to go abstract and you go abstract only if you can have an intermediate delegate to dispatch some of the logic. The obvious candidate would be com.google.firebase.storage.StorageTask, but its generic upper bound is private, which would not allow to define a StorageTask<BaseSnapshot> nullifying the purpose of the abstract class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.