Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
nativescript-plugin-firebase
Advanced tools
Google's realtime app platform (Database, Authentication, Configuration, Notifications) firebase.google.com
For readability the supported features have been moved to their own README's:
Please update to at least tns 2.1.0 to make plugin installation a little easier (otherwise you'll need to manually add an applicationId
to app/App_Resources/Android/app.gradle
).
Head on over to https://console.firebase.google.com/ and sign up for a free account.
Your first 'Firebase' will be automatically created and made available via an URL like https://n-plugin-test.firebaseio.com
.
Open your Firebase project at the Google console and click 'Add app' to add an iOS and / or Android app. Follow the steps (make sure the bundle id is the same as your nativescript.id
in package.json
and you'll be able to download:
iOS: GoogleService-Info.plist
which you'll add to your NativeScript project at app/App_Resources/iOS/GoogleService-Info.plist
Android: google-services.json
which you'll add to your NativeScript project at platforms/android/google-services.json
If you rather watch a video explaining the steps then check out this step-by-step guide - you'll also learn how to add iOS and Android support to the Firebase console and how to integrate anonymous authentication:
From the command prompt go to your app's root folder and execute:
tns plugin add nativescript-plugin-firebase
This will guide you through installing additional components. Check the doc links above to see what's what. You can always change your choices later.
Do yourself a favor by adding TypeScript support to your nativeScript app:
tns install typescript
Then open references.d.ts
in the root of your project and add this line to get autocompletion and type-checking for this plugin:
/// <reference path="./node_modules/nativescript-plugin-firebase/firebase.d.ts" />
Install packages 'Google Play Services' and 'Google Repository' in your Android SDK Manager
platforms/android/build.gradle
We're trying to automate these steps, but for now:
classpath "com.google.gms:google-services:3.0.0"
so it becomes something like: dependencies {
classpath "com.android.tools.build:gradle:1.5.0"
classpath "com.google.gms:google-services:3.0.0"
}
apply plugin: "com.google.gms.google-services"
If you want a quickstart, clone our demo app.
We need to do some wiring when your app starts, so open app.js
and add this before application.start();
:
var firebase = require("nativescript-plugin-firebase");
firebase.init({
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs.
}).then(
function (instance) {
console.log("firebase.init done");
},
function (error) {
console.log("firebase.init error: " + error);
}
);
import firebase = require("nativescript-plugin-firebase");
firebase.init({
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs.
}).then(
(instance) => {
console.log("firebase.init done");
},
(error) => {
console.log("firebase.init error: " + error);
}
);
On the simulator you may see this message if you have more than one app with the Firebase SDK ever installed:
[FirebaseDatabase] Authentication failed: invalid_token (Invalid claim 'aud' in auth token.)
or
[FirebaseDatabase] Authentication failed: invalid_token (audience was project 'firegroceries-904d0' but should have been project 'your-firebase-project')
This is a known issue in the Firebase SDK. I always use a real device to avoid this problem, but you can pass an 'iOSEmulatorFlush' option to init.
firebase.init({
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs and 'iOSEmulatorFlush' to flush token before init.
iOSEmulatorFlush: true
}).then()
If you see an error like Unable to satisfy the following requirements: Firebase (~> 3.3.0) required by Podfile
,
then check issue 98 which perfectly explains how to update your local Pod spec repo.
com.android.dex.DexIndexOverflowException: method ID not in..
Congrats, you ran into this issue
which can be solved by adding multiDexEnabled true
to your app/App_Resources/Android/app.gradle
so it becomes something like this:
android {
defaultConfig {
applicationId = "__PACKAGE__"
multiDexEnabled true
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Increase the Java Max Heap Size like this (the bit at the end):
android {
defaultConfig {
applicationId = "__PACKAGE__"
multiDexEnabled true
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
dexOptions {
javaMaxHeapSize "4g"
}
}
Another possible error is "FirebaseApp with name [DEFAULT] doesn't exist." which will be solved by
placing google-services.json
to platforms/android/google-services.json
(see above), and making
the changes to build.gradle
which are mentioned above as well.
And there's this one: "Could not find com.google.firebase:firebase-auth:9.4.0". That means
making sure you have the latest Google Repository bits installed.
Just run android
from a command prompt and install any pending updates.
Update your Android bits like the issue above and reinstall the android platform in your project.
removeEventListener
The starting point for this plugin was this great Gist by John Bristowe.
FAQs
Fire. Base. Firebase!
The npm package nativescript-plugin-firebase receives a total of 229 weekly downloads. As such, nativescript-plugin-firebase popularity was classified as not popular.
We found that nativescript-plugin-firebase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.