Coder Social home page Coder Social logo

nativescript / firebase Goto Github PK

View Code? Open in Web Editor NEW
50.0 16.0 45.0 5.21 MB

Modular Firebase ๐Ÿ”ฅ implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.

Home Page: https://docs.nativescript.org/plugins/firebase-core.html

License: Apache License 2.0

Shell 0.01% TypeScript 74.84% SCSS 0.06% HTML 0.78% JavaScript 1.64% Ruby 0.27% Kotlin 15.10% Objective-C 0.70% Swift 4.49% Vue 2.09%
firebase nativescript ios android typescript firebase-auth firestore firebase-database crashlytics firebase-functions

firebase's Introduction

How to use?

This workspace manages the suite of plugins listed above.

In general, when in doubt with what to do, just npm start.

How to add a new package to workspace?

npm run add

At the prompt, enter the name of the new package.

  • This adds a plugin harness in packages with the necessary boilerplate to just start developing
  • Updates all demo app flavors to support demoing the new package
  • Adds shared code in tools/demo where you can write demo code once and share across all demo flavors
  • Updates build tooling to support the new package
  • Updates the npm start interactive display
  • Updates the README here to list the new package

How to add Angular compatibility to a package

npm run add-angular

At the prompt, enter the name of the package to add an angular folder to it with the necessary boilerplate to provide Angular support to the package.

How to focus on just 1 package to develop in isolation

npm start
  • Choose the focus commands for the package you wish to focus on and hit enter.
  • All the demo app's will be updated to isolate that 1 package and for supported IDE's (currently VS Code), the source code will also become isolated in the workspace.

Note: good to always clean the demo you plan to run after focusing. (You can clean any demo from npm start as well)

How to publish packages?

npm run publish-packages
  • You will be prompted for the package names to publish. Leaving blank and hitting enter will publish them all.
  • You will then be prompted for the version to use. Leaving blank will auto bump the patch version (it also handles prerelease types like alpha, beta, rc, etc. - It even auto tags the corresponding prelease type on npm).
  • You will then be given a brief sanity check ๐Ÿง ๐Ÿ˜Š

Made with โค๏ธ

firebase'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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

firebase's Issues

Initial Release

  • Admob
  • Analytics
  • AppCheck
  • Auth
  • Cloud Messaging
  • Core
  • Crashlytics
  • Database (Realtime)
  • Dynamic Links
  • Firestore
  • Functions
  • In-App Messaging
  • Installations
  • Performance Monitoring
  • Remote Config
  • Storage

[feature] Support for communication notifications (ios 15)

firebase-auth Android: sendEmailVerification NullpointerException

firebase().auth().createUserWithEmailAndPassword("[email protected]", "password").then((result: UserCredential) => {
    result.user.sendEmailVerification().then(() => {
      //...
    }, (e) => {
      //...
  });

The call of sendEmailVerification always fails with the following error:

java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter actionCodeSettings

No matter what I am passing as parameter actionCodeSettings

Demo app for reproducing:
ns-firebase-auth.zip

[firebase-auth] Error on send email verification (only android) not solved - alpha 42

The error below continue to happen (and is blocking) even on alpha package .42 and I'm really stuck :(

DETAILS

Packages:

"dependencies": {
    "@angular/animations": "~13.1.1",
    "@angular/common": "~13.1.1",
    "@angular/compiler": "~13.1.1",
    "@angular/core": "~13.1.1",
    "@angular/forms": "~13.1.1",
    "@angular/platform-browser": "~13.1.1",
    "@angular/platform-browser-dynamic": "~13.1.1",
    "@angular/router": "~13.1.1",
    "@nativescript/angular": "^13.0.0",
    "@nativescript/core": "~8.1.1",
    "@nativescript/firebase-auth": "^1.0.0-alpha.42",
    "@nativescript/firebase-core": "^1.0.0-alpha.42",
    "@nativescript/localize": "^5.0.4",
    "@nativescript/theme": "~3.0.1",
    "nativescript-ui-sidedrawer": "^10.0.2",
    "rxjs": "~7.4.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.1.1",
    "@angular/compiler-cli": "~13.1.1",
    "@nativescript/android": "8.1.1",
    "@nativescript/ios": "8.1.0",
    "@nativescript/types": "~8.1.1",
    "@nativescript/webpack": "~5.0.0",
    "@ngtools/webpack": "~13.1.1",
    "typescript": "~4.4.4"
  }

Source code:

signUpUserPassword() {
    firebase().auth()
      .createUserWithEmailAndPassword('[email protected]', 'password')
      .then((cred) => {
        if (cred && !cred.user.emailVerified) {
          cred.user.sendEmailVerification()
        }
       })
      .catch(error => {
        console.error(error)
       })
  }

ERROR:

JS: ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter actionCodeSettings
JS: (file: src/webpack:/fidelity-card-client/node_modules/@nativescript/firebase-auth/index.android.js:344:0)
JS:     at ZoneAwarePromise(file: src/webpack:/fidelity-card-client/node_modules/zone.js/fesm2015/zone.js:1387:0)
JS:     at sendEmailVerification(file: src/webpack:/fidelity-card-client/node_modules/@nativescript/firebase-auth/index.android.js:338:0)
JS:     at (file: src/webpack:/fidelity-card-client/src/app/auth/userpassword/userpassword.component.ts:35:0)
JS:     at invoke(file: src/webpack:/fidelity-card-client/node_modules/zone.js/fesm2015/zone.js:372:0)
JS:     at onInvoke(file: src/webpack:/fidelity-card-client/node_modules/@angular/core/fesm2015/core.mjs:25457:0)
JS:     at invoke(file: src/webpack:/fidelity-card-client/node_modules/zone.js/fesm2015/zone.js:371:0)
JS:     at run(file: src/webpack:/fidelity-card-client/node_modules/zone.js/fesm2015/zone.js:134:0)
JS:     at (file:///data/d...

[firebase-functions] Function calls with boolean parameters throw 'Error: Cannot convert boolean to Ljava/lang/Object; at index 1'

Similar to issue #25, including a boolean parameter in the payload of a firebase functions call results in
'Error: Cannot convert boolean to Ljava/lang/Object; at index 1'

Example code:

let params = {email: this.newUserEmail, invite:false};
let result = await firebase().functions().httpsCallable("user-getByEmail")(params);

Tested with @1.0.0-alpha.34 on Android. No issue on iOS

Switching between MLKitBarcodeScanner and MLKitFaceDetection

Hi,

I have a problem, i have a samsung tablet. And in our app we switch between barcode scanner and face detection. When a qr code is found we detect your face to upload it.

The problem is on this tablet when we detect a qr code, we switch to facedetection, we switch back to barcodescanner, it takes something like 10 mins for him to see the qr code and it raises also a lot of times. Like something was stuck.

I don't have any error or anything, i just tried to put a console log in the plugin when it founds a qr code and i have it like 20 times after im playing with the qr code in front of the camera for like 10 min on the second time.

ns --version 8.1.5. Nativescript angular

package.json

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "@angular/animations": "^12.2.5",
    "@angular/common": "^12.2.5",
    "@angular/compiler": "^12.2.5",
    "@angular/core": "^12.2.5",
    "@angular/forms": "^12.2.5",
    "@angular/platform-browser": "^12.2.5",
    "@angular/platform-browser-dynamic": "^12.2.5",
    "@angular/router": "^12.2.5",
    "@nativescript/angular": "^12.2.0",
    "@nativescript/background-http": "~5.0.0",
    "@nativescript/camera": "~5.0.0",
    "@nativescript/core": "~8.1.1",
    "@nativescript/datetimepicker": "^2.1.9",
    "@nativescript/firebase": "^11.1.3",
    "@nativescript/geolocation": "~8.0.0",
    "@nativescript/imagepicker": "~1.0.0",
    "@nativescript/theme": "^3.0.1",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@nstudio/nativescript-camera-plus": "^4.1.0",
    "@nstudio/nativescript-loading-indicator": "~4.0.0",
    "@nstudio/nativescript-pulltorefresh": "~3.0.0",
    "@nstudio/nativescript-snackbar": "~2.0.0",
    "nativescript-imagecropper": "~4.0.0",
    "nativescript-nfc": "~5.0.0",
    "nativescript-permissions": "^1.3.8",
    "nativescript-sound-kak": "^1.2.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-chart": "~9.0.0",
    "nativescript-ui-sidedrawer": "~10.0.0",
    "nativescript-webview-interface": "^1.4.2",
    "rxjs": "^7.4.0",
    "tns-platform-declarations": "^6.5.15",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-eslint/builder": "13.0.1",
    "@angular-eslint/eslint-plugin": "13.0.1",
    "@angular-eslint/eslint-plugin-template": "13.0.1",
    "@angular-eslint/schematics": "13.0.1",
    "@angular-eslint/template-parser": "13.0.1",
    "@angular/compiler-cli": "^12.2.5",
    "@nativescript/android": "8.1.1",
    "@nativescript/schematics": "~0.5.0",
    "@nativescript/types": "~8.1.0",
    "@nativescript/webpack": "~5.0.0",
    "@ngtools/webpack": "^12.2.5",
    "@types/jasmine": "^3.5.11",
    "@typescript-eslint/eslint-plugin": "5.3.0",
    "@typescript-eslint/parser": "5.3.0",
    "eslint": "^8.2.0",
    "typescript": "~4.3.5"
  },
  "readme": "NativeScript Application",
  "main": "./src/main.ts",
  "scripts": {
    "lint": "ng lint"
  }
}

component.ts

import { Component, OnInit } from '@angular/core';
import { registerElement } from '@nativescript/angular';
import { MLKitScanBarcodesOnDeviceResult } from '@nativescript/firebase/mlkit/barcodescanning';
import { LoaderService } from '../services/loader/loader.service';
registerElement("MLKitBarcodeScanner", () => require("@nativescript/firebase/mlkit/barcodescanning").MLKitBarcodeScanner);
registerElement("MLKitFaceDetection", () => require("@nativescript/firebase/mlkit/facedetection").MLKitFaceDetection);

@Component({
  selector: 'ns-test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.css'],
  moduleId: module.id,
})

export class TestComponent implements OnInit {
  qrcode = true;

  constructor(private loader: LoaderService) { }

  ngOnInit() {
   this.loader.hide();
  }

  onBarcodeScanningResult(event: any): void {
      const result: MLKitScanBarcodesOnDeviceResult = event.value;
      let barcodes = result.barcodes;
      if (barcodes.length > 0) {
        console.log(" barcode result !!!!!!!!!!!!!!!!!!");
        this.qrcode = false;
      }
    }

    onFaceDetectionResult(event) {
    console.log("on face detection !!!!!!!!!!!!");
    this.qrcode = true;
    }
}

component.html

<GridLayout>
    <GridLayout *ngIf="qrcode">
            <MLKitBarcodeScanner  processEveryNthFrame="10" beepOnScan="true"
                 formats="QR_CODE, EAN_8, EAN_13" preferFrontCamera="true"
                supportInverseBarcodes="false" (scanResult)="onBarcodeScanningResult($event)">
            </MLKitBarcodeScanner>
    </GridLayout>
    <GridLayout *ngIf="!qrcode">
        <MLKitFaceDetection  detectionMode="accurate" enableFaceTracking="true"
              minimumFaceSize="0.2" preferFrontCamera="true"
            (scanResult)="onFaceDetectionResult($event)">
        </MLKitFaceDetection>
    </GridLayout>
</GridLayout>

I tried with and without the "registerElement" in the ts. Thats the same. Thank you

[firebase-auth] currentUser property keeps the user object after signing out

firebase().auth().currentUser property stores the User object on a successful sign-in as expected. But it keeps storing the user object after signing out. currentUser getter returns the first signed-in user even after signing in to another user account.

โš ๏ธ Because of firebase().auth().currentUser.getIdToken() returns the first user's token; It causes the 2nd user to use the first user's id token when hitting API endpoints.

Steps to reproduce

  1. Sign in (Account A)
console.log(firebase().auth().currentUser) // User (Account A)
console.log(firebase().auth().native.getCurrentUser()) // [Android] Native user (Account A)
console.log(firebase().auth().native.currentUser) // [IOS] Native user (Account A)
  1. Sign out (Account A)
console.log(firebase().auth().currentUser) // Still has the user data of Account A [BUG]
console.log(firebase().auth().native.getCurrentUser()) // [Android] null
console.log(firebase().auth().native.currentUser) // [IOS] null
  1. Sign in (Account B)
console.log(firebase().auth().currentUser) // Still has the user data of Account A [BUG]
console.log(firebase().auth().native.getCurrentUser()) // [Android] Native user (Account B)
console.log(firebase().auth().native.currentUser) // [IOS] Native user (Account B)

[firebase-crashlytics] Error on building

Hi, i just wanted to start using firebase-crashlytics and i got this error after installing and importing @nativescript/firebase-crashlytics and this is what happened after running "ns run"

ERROR in ./node_modules/source-map/lib/read-wasm.js 21:15-30
Module not found: Error: Can't resolve 'path' in '/Users/hamoboker/Projects/Tafawok/bitlims/node_modules/source-map/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }
resolve 'path' in '/Users/hamoboker/Projects/Tafawok/bitlims/node_modules/source-map/lib'
  Parsed request is a module
  using description file: /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/source-map/package.json (relative path: ./lib)
    resolve as module
      looking for modules in /Users/hamoboker/Projects/Tafawok/bitlims/node_modules
        single file module
          using description file: /Users/hamoboker/Projects/Tafawok/bitlims/package.json (relative path: ./node_modules/path)
            no extension
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path doesn't exist
            .android.vue
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.vue doesn't exist
            .vue
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.vue doesn't exist
            .android.ts
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.ts doesn't exist
            .ts
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.ts doesn't exist
            .android.js
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.js doesn't exist
            .js
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.js doesn't exist
            .android.css
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.css doesn't exist
            .css
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.css doesn't exist
            .android.scss
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.scss doesn't exist
            .scss
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.scss doesn't exist
            .android.json
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.json doesn't exist
            .json
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.json doesn't exist
        /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path doesn't exist
      /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/source-map/lib/node_modules doesn't exist or is not a directory
      /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/source-map/node_modules doesn't exist or is not a directory
      /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/node_modules doesn't exist or is not a directory
      looking for modules in /Users/hamoboker/Projects/Tafawok/bitlims/node_modules
        single file module
          using description file: /Users/hamoboker/Projects/Tafawok/bitlims/package.json (relative path: ./node_modules/path)
            no extension
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path doesn't exist
            .android.vue
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.vue doesn't exist
            .vue
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.vue doesn't exist
            .android.ts
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.ts doesn't exist
            .ts
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.ts doesn't exist
            .android.js
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.js doesn't exist
            .js
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.js doesn't exist
            .android.css
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.css doesn't exist
            .css
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.css doesn't exist
            .android.scss
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.scss doesn't exist
            .scss
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.scss doesn't exist
            .android.json
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.android.json doesn't exist
            .json
              /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path.json doesn't exist
        /Users/hamoboker/Projects/Tafawok/bitlims/node_modules/path doesn't exist
      /Users/hamoboker/Projects/Tafawok/node_modules doesn't exist or is not a directory
      /Users/hamoboker/Projects/node_modules doesn't exist or is not a directory
      /Users/hamoboker/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
 @ ./node_modules/source-map/lib/source-map-consumer.js 12:17-44
 @ ./node_modules/source-map/source-map.js 7:0-82
 @ ./node_modules/stacktrace-gps/stacktrace-gps.js
 @ ./node_modules/stacktrace-js/stacktrace.js
 @ ./node_modules/@nativescript/firebase-crashlytics/index.android.js 15:0-39 78:12-32
 @ ./app/services/firebase.js 4:0-43
 @ ./app/app.js 10:0-28
 
webpack 5.68.0 compiled with 2 errors in 84 ms

This the file where i import firebase

import { firebase } from '@nativescript/firebase-core'
import '@nativescript/firebase-auth'
import '@nativescript/firebase-firestore'
import '@nativescript/firebase-crashlytics'

firebase().initializeApp()
firebase().firestore()
firebase().crashlytics()

Versions i use

{
    "@nativescript/firebase-auth": "^1.0.0-alpha.38",
    "@nativescript/firebase-core": "^1.0.0-alpha.38",
    "@nativescript/firebase-crashlytics": "^1.0.0-alpha.38",
    "@nativescript/firebase-firestore": "^1.0.0-alpha.38",
    "@nativescript/core": "~8.1.5",
    "@nativescript/android": "8.1.1",
    "@nativescript/ios": "8.1.0",
    "@nativescript/webpack": "~5.0.4",
    "nativescript-vue": "~2.9.0"
}

File google-services.json is missing. The Google Services Plugin cannot function without it

I get the following error when trying to build my app.

Execution failed for task ':app:processDebugGoogleServices'.                                                                                                                                                   
File google-services.json is missing. The Google Services Plugin cannot function without it.                                                                                                                   
 Searched Location:                                                                                                                                                                                            
/home/dimitrisrafail/workdir/clients/mobile/platforms/android/app/src/debug/google-services.json                                                                                                               
/home/dimitrisrafail/workdir/clients/mobile/platforms/android/app/src/google-services.json                                                                                                                     
/home/dimitrisrafail/workdir/clients/mobile/platforms/android/app/src/Debug/google-services.json                                                                                                               
/home/dimitrisrafail/workdir/clients/mobile/platforms/android/app/google-services.json

Of course, this gets solved if one puts the file into platform folder manually but it would be ideal if file was copied from App_Resources.

[firebase-firestore] doc() does not work as expected

Hi. Normally, collection.doc() usage (without parameter) must be creating doc with auto generate id as explained by Firebase docs.

example usage: firestore.batch().set(firestore.collection('users').doc(), {data})) ...

error: Invalid document reference. Document references must have an even number of segments
expected: it must be behaving like add() method.

I need to this feature because add() method isn't usaged inside the batch write. Is there a way to do this ?

firebase-auth ios: TypeError cannot read property <x> of null

I just tried @nativescript/firebase-auth 1.0.0.alpha.0 and I have the problem that I am not able to call any auth method on iOS, e.g.:

firebase().auth().createUserWithEmailAndPassword("my-email", "my-password")
will fail with the following error:

TypeError: Cannot read property 'createUserWithEmailPasswordCompletion' of null.

This happens for all other operations like signInWithEmailAndPassword, sendPasswordResetEmail, ... as well.

On Android, all that stuff seems to work as expected.

Demo app to reproduce:
ns-firebase-auth.zip

Crashlytics: NullpointerException in recordError() if the StackFrame's functionName is falsy due to arrow-function

I do not have real steps to reproduce but on Android, calling firebase().crashlytics().recordError(new Error("foobar")); raises a
java.lang.NullPointerException if the functionName of the StackFrame is not available. This is a {N} Angular application bzw.

In my case, the relevant parts of the original JS runtime stack trace looks like this, see inline comments for context:

// handleError() is our custom Angular ErrorHandler, therefore it is in bundle.js
handleError(file:///data/data/foo.bar.dev/files/app/bundle.js:1215:27)
at next(file:///data/data/foo.bar.dev/files/app/vendor.js:43721:42)
at SafeSubscriber.__tryOrUnsub(file:///data/data/foo.bar.dev/files/app/vendor.js:158609:16)
at SafeSubscriber.next(file:///data/data/foo.bar.dev/files/app/vendor.js:158547:22)
at Subscriber._next(file:///data/data/foo.bar.dev/files/app/vendor.js:158493:26)
at Subscriber.next(file:///data/data/foo.bar.dev/files/app/vendor.js:158470:18)
at Subject.next(file:///data/data/foo.bar.dev/files/app/vendor.js:158240:25)
at emit(file:///data/data/foo.bar.dev/files/app/vendor.js:40373:15)
// this part of the stack is actually the body of an arrow function
//   zone.runOutsideAngular(() => zone.onError.emit(error));
// I guess this is why there is no functionName as it is anonymous
at (file:///data/data/foo.bar.dev/files/app/vendor.js:76877:55)
at invoke(file:///data/data/foo.bar.dev/files/app/vendor.js:179011:26)
at run(file:///data/data/foo.bar.dev/files/app/vendor.js:178773:43)
at runOutsideAngular(file:///data/data/foo.bar.dev/files/app/vendor.js:76751:28)
at onHandleError(file:///data/data/foo.bar.dev/files/app/vendor.js:76877:18)
at handleError(file:///data/data/foo.bar.dev/files/app/vendor.js:179015:37)

This empty function name causes an java.lang.NullPointerException error here as the methodName argument of a java.lang.StackTraceElement may not be null:

traceElements[i] = new java.lang.StackTraceElement('', item.functionName, item.fileName, -1);

[Messaging] hasPermission returns authorized when the status is not determined

Hi,

currently this plugin returns the permission status AuthorizationStatus.AUTHORIZED on iOS when it actually should be AuthorizationStatus.NOT_DETERMINED.

_hasPermission(resolve, reject) {
		if (parseInt(Device.osVersion) >= 10) {
			UNUserNotificationCenter.currentNotificationCenter().getNotificationSettingsWithCompletionHandler((settings) => {
				let status = AuthorizationStatus.NOT_DETERMINED;
				switch (settings.authorizationStatus) {
					...
					case UNAuthorizationStatus.NotDetermined:
						status = AuthorizationStatus.AUTHORIZED;
						break;
				}
				resolve(status);
			});
		} else {
			resolve(AuthorizationStatus.AUTHORIZED);
		}
	}

it should be AuthorizationStatus.NOT_DETERMINED but it is being explicitly overridden in case UNAuthorizationStatus.NotDetermined:

analytics: [NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance

Can happen if a null gets passed in as params to logEvent:

CONSOLE ERROR: ERROR Error: Uncaught (in promise): Error: -[NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance 0x115d21fb0
Error: -[NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance 0x115d21fb0
at Analytics.logEvent (file: node_modules/@nativescript/firebase-analytics/index.ios.js:69:0)

[firebase-messaging] APNS device token not set before retrieving FCM Token for Sender ID

Hi there,

I'm actually trying to change the @nativescript/firebase plugin for packages from this repo.

I started the "migration" with @nativescript/firebase-core and @nativescript/firebase-messaging.

When I try to register notifications with this code:

import Vue from 'nativescript-vue'
import { firebase } from '@nativescript/firebase-core'
import { AuthorizationStatus } from '@nativescript/firebase-messaging'

import Home from './components/Home'

new Vue({
    render: (h) => h('frame', [h(Home)]),
    created() {
        firebase().initializeApp()
            .then(() => {
                const messaging = firebase().messaging()

                messaging.requestPermission({
                    ios: {
                        alert: true,
                    },
                })
                    .then((authStatus) => {
                        const enabled = authStatus === AuthorizationStatus.AUTHORIZED || authStatus === AuthorizationStatus.PROVISIONAL

                        if (enabled) {
                            messaging.getToken()
                                .then((pushToken) => {
                                    console.log(pushToken)
                                    messaging.registerDeviceForRemoteMessages()
                                })

                            messaging.onMessage((message) => {
                                console.log(message)
                            })
                        }
                    })
                    .catch((error) => {
                        console.error(error)
                    })
            })
            .catch((error) => {
                console.error(error)
            })
    },
}).$start()

This error is thrown in the console (several times, starting when the promise for the permission request resolves):

8.11.0 - [Firebase/Messaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '************'. Notifications to this FCM Token will not be delivered over APNS.Be sure to re-retrieve the FCM token once the APNS device token is set.

I don't know what I did wrong here. I think the Firebase configuration is good because it works with the same app with @nativescript/firebase.

Here is what I tried to troubleshoot (with no effect):

  • Uninstall/reinstall the app
  • Reboot the iPhone
  • Add some setTimeout before requesting permission, just to be sure everything is initialized
  • Change the order of getToken and registerDeviceForRemoteMessages
  • Check if "Push notifications" capability and needed background modes are checked in Xcode

I'm now out of solutions to fix this. Has anyone made it work with a real device?

Thanks for your help :)

GoogleSignIn Error in firebase

Receive the following error when using @nativescript/firebase when using IPHONEOS_DEPLOYMENT_TARGET = 12.0

error: the following command failed with exit code 0 but produced no further output
CompileC /Users/cupidchan/Library/Developer/Xcode/DerivedData/CareHealth-avugryobljqfondlarzvnbtpafiq/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/GoogleSignIn.build/Objects-normal/arm64/GIDEMMErrorHandler.o /Users/cupidchan/Documents/GitHub/pistevo-decision/CareHealth/platforms/ios/Pods/GoogleSignIn/GoogleSignIn/Sources/GIDEMMErrorHandler.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'GoogleSignIn' from project 'Pods')

In addition to that, there are also a few deprecation warnings:

/Users/cupidchan/Documents/GitHub/pistevo-decision/CareHealth/platforms/ios/Pods/GoogleSignIn/GoogleSignIn/Sources/GIDEMMErrorHandler.m:177:11: warning: 'openURL:' is deprecated: first deprecated in iOS
      10.0 [-Wdeprecated-declarations]
          openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
          ^~~~~~~
          openURL:options:completionHandler:
In module 'UIKit' imported from /Users/cupidchan/Documents/GitHub/pistevo-decision/CareHealth/platforms/ios/Pods/GoogleSignIn/GoogleSignIn/Sources/GIDEMMErrorHandler.m:17:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:124:1: note: 
      'openURL:' has been explicitly marked deprecated here
- (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0, 10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
^
/Users/cupidchan/Documents/GitHub/pistevo-decision/CareHealth/platforms/ios/Pods/GoogleSignIn/GoogleSignIn/Sources/GIDEMMErrorHandler.m:207:42: warning: 'openURL:' is deprecated: first deprecated in iOS
      10.0 [-Wdeprecated-declarations]
      [[UIApplication sharedApplication] openURL:url];
                                         ^~~~~~~
                                         openURL:options:completionHandler:
In module 'UIKit' imported from /Users/cupidchan/Documents/GitHub/pistevo-decision/CareHealth/platforms/ios/Pods/GoogleSignIn/GoogleSignIn/Sources/GIDEMMErrorHandler.m:17:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:124:1: note: 
      'openURL:' has been explicitly marked deprecated here
- (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0, 10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");```

[iOS] Firebase Messaging: TypeError: Cannot set property 'delegate' of null

When on iOS call firebase().messaging(), get this error. I found an error in constructor of class Messaging for iOS

this.#native.delegate = this.#delegate;
in constructor on 48 line.

This error prevents the constructor from finishing executing the code after this line. For this reason, the first call to the function await firebase().messaging().requestPermission() will not work, as and any other methods.

How reproduction this error (only on iOS):

import { firebase } from '@nativescript/firebase-core'
import '@nativescript/firebase-messaging'

...
const messaging = firebase().messaging()
const status = await messaging.requestPermission({ ios: { alert: true } }) // this line not will working
...

I may be wrong, but i think what this issue #24 also related to this error


Until this bug is fixed, may use a temporary solution (hook):

if (isIOS) {
  ;(async () => firebase().messaging())()
}
const status = await firebase().messaging().requestPermission({ ios: { alert: true } })

add this before firebase().messaging().anyMethod()

firebase-auth Android verifyPhoneNumber TypeError: Cannot read property 'extend' of undefined

I am trying firebase-auth 1.0.0.alpha.0 on Android and when I want to test Phone login like this:

PhoneAuthProvider.provider().verifyPhoneNumber("+44 7123 123 456").then((verificationId: string) => {
    console.log("verifyPhoneNumber received verification id:");
    console.log(verificationId);
  }, (e) => {
    console.log("Phone login error: " + e);
  });

... I get an error:

TypeError: Cannot read property 'extend' of undefined

It does not matter if I run the app on Emulator or physical device.

Demo app to reproduce:
ns-firebase-auth.zip

Error when run ns run with pod install

I have:

  • NS 8.1.5
  • node v16.13.0
  • NPM 8.1.0
  • Xcode 13.1
  • macOS Big Sur 11.6.1

When I run:

$ ns run ios --log trace

get error:

Multiple identical platforms with different versions have been detected during the processing of podfiles. The current platform's content "platform :ios, '9.0'" from /Users/creditoh_it/PhpstormProjects/crmhex-app/node_modules/@nativescript/firebase/platforms/ios/Podfile will be replaced with "platform :ios, '10.0'" from /Users/creditoh_it/PhpstormProjects/crmhex-app/node_modules/nativescript-applozic-chat-fork/platforms/ios/Podfile
Installing pods...
spawn: pod "install"
Analyzing dependencies
[!] There are multiple dependencies with different sources for `SVGKit` in `Podfile`:

- SVGKit (from `https://github.com/SVGKit/SVGKit.git`, branch `3.x`)
- SVGKit (from `https://github.com/SVGKit/SVGKit.git`, branch `2.x`)

signInWithCredential is empty

Hi! I'm trying to get the credential by PhoneAuthProvider (on Android) and get empty data.

  • NativeScript: 8.1.1
  • nativescript/firebase-auth: 1.0.0-alpha.2

2021-12-28_14-45-25
2021-12-28_14-43-15

firebase().crashlytics() internal this.native property is null on iOS, so all methods fail

I'm attempting to use the Crashlytics module on iOS, but every method is failing.

I'm importing it like so:

import { firebase } from '@nativescript/firebase-core';
import '@nativescript/firebase-crashlytics';

...and then trying to call methods like so:

console.log('firebase().crashlytics(): ', firebase().crashlytics());
console.log('firebase().crashlytics().setCrashlyticsCollectionEnabled: ', firebase().crashlytics().setCrashlyticsCollectionEnabled);
firebase().crashlytics().setCrashlyticsCollectionEnabled(true);

The firebase().crashlytics() object exists, and I can see that the setCrashlyticsCollectionEnabled method exists too:

CONSOLE LOG: firebase().crashlytics():  {}
CONSOLE LOG: firebase().crashlytics().setCrashlyticsCollectionEnabled:  setCrashlyticsCollectionEnabled(enabled) {
this.native.setCrashlyticsCollectionEnabled(enabled);
}

However, when I actually call the method (or any other method off of firebase().crashlytics(), the call fails because "this.native" (within the crashlytics code, not within my own) is null.

CONSOLE LOG: TypeError: Cannot read property 'setCrashlyticsCollectionEnabled' of null
CONSOLE LOG: > at Crashlytics.setCrashlyticsCollectionEnabled (file: node_modules/@nativescript/firebase-crashlytics/index.ios.js:97:0)

This is using the latest version of @nativescript/firebase-crashlytics: ^1.0.0-alpha.0. My @nativescript/core version is 8.1.5.

[ios][firebase-admob] Banner sizes can not be defined (alpha.32)

Hi,
and first and foremost: THANK YOU for the work on this plugin.
I have a few issues with firebase-admob (alpha.32) banners, related to sizes. They only appear on iOS, Android works fine. errors in code comments

<BannerAd
  unitId="ca-myUnitID.fsakfjsadlfjsdfgjkgsd"
  @layoutChanged="bannerLoaded"/>
bannerLoaded(args) {
    const bannerAd = event.object as BannerAd;

//    bannerAd.size = BannerAdSize.createInLineAdaptiveBanner('fullWidth');  // this crashes on ios
//    bannerAd.size = new BannerAdSize(368, 60);  // this crashes with ReferenceError: kGADAdSizeFullBanner is not defined
    bannerAd.load();
}

Do you need an example repository to confirm?

[firebase-messaging] Cannot read property 'AUTHORIZED' of undefined

a little bit strange but i am using this code

const authStatus = await messaging.requestPermission({
    			ios: {
    				alert: true,
    			},
    		});

            const enabled = authStatus === messaging.AuthorizationStatus.AUTHORIZED || authStatus === messaging.AuthorizationStatus.PROVISIONAL;

and get the error (on Android)
Cannot read property 'AUTHORIZED' of undefined

authStatus is 0 here. you can reproduce this in my repo here: https://github.com/eikaramba/firebase-test

firebase auth iOS: verifyPhoneNumber is crashing the app

When using @nativescript/firebase-auth 1.0.0-alpha.31, a call to verifyPhoneNumber is crashing the app (Simulator and physical device).

PhoneAuthProvider.provider().verifyPhoneNumber("+44 7123 123 456").then((verificationId: string) => {
    console.log("verifyPhoneNumber received verification id:");
    console.log(verificationId);
  }, (e) => {
    console.log(e);
});

***** Fatal JavaScript exception - application has been terminated. *****
NativeScript encountered a fatal error: Uncaught Error: The default FirebaseApp instance must be configured before the default Authinstance can be initialized. One way to ensure this is to call FirebaseApp.configure() in the App Delegate's application(_:didFinishLaunchingWithOptions:) (or the @main struct's initializer in SwiftUI).
at
provider(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/firebase-auth/index.ios.js:682:0)
at submitLoginPhone(file: app/webpack:/@nativescript/template-hello-world-ts/app/main-page.ts:86:2)
at _handleEvent(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/data/observable/index.js:233:0)
at notify(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/data/observable/index.js:216:0)
at _emit(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/data/observable/index.js:256:0)
at TapHandlerImpl.tap(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/ui/button/index.ios.js:261:0)
*** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Uncaught Error: The default FirebaseApp instance must be configured before the default Authinstance can be initialized. One way to ensure this is to call FirebaseApp.configure() in the App Delegate's application(_:didFinishLaunchingWithOptions:) (or the @main struct's initializer in SwiftUI).
at
provider(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/firebase-auth/index.ios.js:682:0)
at submitLoginPhone(file: app/webpack:/@nativescript/template-hello-world-ts/app/main-page.ts:86:2)
at _handleEvent(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/data/observable/index.js:233:0)
at notify(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/data/observable/index.js:216:0)
at _emit(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/data/observable/index.js:256:0)
at TapHandlerImpl.tap(file: app/webpack:/@nativescript/template-hello-world-ts/node_modules/@nativescript/core/ui/button/index.ios.js:261:0)
', reason: '(null)'
*** First throw call stack:
(0x1840ddd3c 0x19b4426a8 0x104ca20b8 0x10501e6e4 0x10501e550 0x104f5f2b8 0x104eb7aa4 0x104eb7058 0x104d0a50c 0x104be4794 0x104cd7974 0x104cd81b4 0x18684ec98 0x1869701e4 0x186703198 0x186799de0 0x186a14d1c 0x1865064ac 0x186537c40 0x1865445d4 0x1866e80d8 0x186519124 0x18650e070 0x186513400 0x1840f<\M-b\M^@\M-&>

[firebase-app-check] can't call firebase functions on emulator

Hello :) I am trying to use the firebase-app-check plugin in an android emulator and getting error when calling a firebase function. From the logcat I found this:

2022-02-14 12:27:56.164 19682-19682/no.way.m.app W/FirebaseContextProvider: Error getting App Check token; using placeholder token instead. Error: com.google.firebase.FirebaseException: No AppCheckProvider installed.

We are using vue in our app and the initialization of AppCheck happens in main.js like this:

firebase().initializeApp().then((app) => {
  const appcheck = new AppCheck(app);
  appcheck.activate();
}).catch(error => {
  console.log(error);
});

Authentication by phone works just fine, however it opens up captcha in a web browser, so maybe captcha doesn't generate a valid AppCheck token? I am using a local firebase functions-emulator, this is the output from the function that throws an error:

i  functions: Beginning execution of "us-central1-updateUser"
 {"severity":"WARNING","message":"Failed to validate AppCheck token. FirebaseAppCheckError: Decoding App Check token failed. Make sure you passed the entire string JWT which represents the Firebase App Check token.\n 

When going through the firebase official docs I found that App Check in debug environments requires additional setup: https://firebase.google.com/docs/app-check/android/debug-provider
But I cannot find any of these functions required in the nativescript plugin. Or does this happen automatically when building in a debug environment?

In summary, steps to reproduce:

  1. initialize firebase app
  2. call AppCheck activate method
  3. attempt to call a firebase function. in my case, this is the function that throws an error:
       const updateUserFn = firebase().functions().httpsCallable(
          "updateUser",
          functionsRegion
        );
        updateUserFn({
          user: this.user,
          id_number: this.idNumber,
          registering: true,
        });
  1. Launch app on android emulator

[firebase-functions] Arrays in returned objects are null

If the returned object resulting from a firebase function call contains an Array, the array returned by the plugin is null.

For example:

const stripeServer = firebase().functions().httpsCallable("stripeServer")
let result = await stripeServer({ action, content });

Firebase function stripeServer returns:

{ associated_objects: [ { type: 'customer', id: 'cus_InjovAWnSWCAVE' } ],
  created: 1639799535,
  expires: 1639803135,
  livemode: false,
}

...then the returned result is

{ associated_objects: null,
  created: 1639799535,
  expires: 1639803135,
  livemode: false,
}

Android, using:

"@nativescript/firebase-core": "^1.0.0-alpha.25",
"@nativescript/firebase-functions": "^1.0.0-alpha.25",

Firebase-database: Cannot convert boolean to Ljava/lang/Object; at index 1

I'm trying to set a model in my realtime database and i got the following error:

Cannot convert boolean to Ljava/lang/Object; at index 1

I have the same thing in update.

My model:

{"date":"Thu Jan 20 2022 11:15:20 GMT+0200 (IST)","id":58622,"finished":false}

Code TS:

import { firebase } from '@nativescript/firebase-core';
import '@nativescript/firebase-database';

const database = firebase().database();

            database.ref(url).set(model).then(
                (data) => {
                    observer.next(data);
                    observer.complete();
                }
            ).catch((error) =>  {console.log("error in set " + error); observer.error(error);})

package.json

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "@angular/animations": "^12.2.5",
    "@angular/common": "^12.2.5",
    "@angular/compiler": "^12.2.5",
    "@angular/core": "^12.2.5",
    "@angular/forms": "^12.2.5",
    "@angular/platform-browser": "^12.2.5",
    "@angular/platform-browser-dynamic": "^12.2.5",
    "@angular/router": "^12.2.5",
    "@nativescript/angular": "^12.2.0",
    "@nativescript/background-http": "~5.0.0",
    "@nativescript/camera": "~5.0.0",
    "@nativescript/core": "~8.1.1",
    "@nativescript/datetimepicker": "^2.1.9",
    "@nativescript/firebase": "^11.1.3",
    "@nativescript/firebase-core": "^1.0.0-alpha.35",
    "@nativescript/firebase-crashlytics": "^1.0.0-alpha.35",
    "@nativescript/firebase-database": "^1.0.0-alpha.35",
    "@nativescript/firebase-storage": "^1.0.0-alpha.35",
    "@nativescript/geolocation": "~8.0.0",
    "@nativescript/imagepicker": "~1.0.0",
    "@nativescript/mlkit-barcode-scanning": "^1.0.0-alpha.8",
    "@nativescript/mlkit-core": "^1.0.0-alpha.8",
    "@nativescript/mlkit-face-detection": "^1.0.0-alpha.8",
    "@nativescript/theme": "^3.0.1",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@nstudio/nativescript-camera-plus": "^4.1.0",
    "@nstudio/nativescript-loading-indicator": "~4.0.0",
    "@nstudio/nativescript-pulltorefresh": "~3.0.0",
    "@nstudio/nativescript-snackbar": "~2.0.0",
    "nativescript-imagecropper": "~4.0.0",
    "nativescript-nfc": "~5.0.0",
    "nativescript-permissions": "^1.3.8",
    "nativescript-sound-kak": "^1.2.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-chart": "~9.0.0",
    "nativescript-ui-sidedrawer": "~10.0.0",
    "nativescript-webview-interface": "^1.4.2",
    "rxjs": "^7.4.0",
    "tns-platform-declarations": "^6.5.15",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-eslint/builder": "13.0.1",
    "@angular-eslint/eslint-plugin": "13.0.1",
    "@angular-eslint/eslint-plugin-template": "13.0.1",
    "@angular-eslint/schematics": "13.0.1",
    "@angular-eslint/template-parser": "13.0.1",
    "@angular/compiler-cli": "^12.2.5",
    "@nativescript/android": "8.1.1",
    "@nativescript/schematics": "~0.5.0",
    "@nativescript/types": "~8.1.0",
    "@nativescript/webpack": "~5.0.0",
    "@ngtools/webpack": "^12.2.5",
    "@types/jasmine": "^3.5.11",
    "@typescript-eslint/eslint-plugin": "5.3.0",
    "@typescript-eslint/parser": "5.3.0",
    "eslint": "^8.2.0",
    "typescript": "~4.3.5"
  },
  "readme": "NativeScript Application",
  "main": "./src/main.ts",
  "scripts": {
    "lint": "ng lint"
  }
}

Stacktrace:

System.err: (file: node_modules@nativescript\firebase-core\utils.js:102:0)
System.err: at serialize(file: node_modules@nativescript\firebase-core\utils.js:102:0)
System.err: at (file: node_modules@nativescript\firebase-database\index.android.js:488:63)
System.err: at ZoneAwarePromise(file: node_modules\zone.js\fesm2015\zone.js:1387:0)
System.err: at update(file: node_modules@nativescript\firebase-database\index.android.js:487:0)
System.err: at (file: src\app\services\firebase\database\firebase-database.service.ts:22:0)
System.err: at Observable._trySubscribe(file: node_modules\rxjs\dist\cjs\internal\Observable.js:41:0)
System.err: at (file: node_modules\rxjs\dist\cjs\internal\Observable.js:35:0)
System.err: at errorContext(file: node_modules\rxjs\dist\cjs\internal\util\errorContext.js:22:0)
System.err: at Observable.subscribe(file: node_modules\rxjs\dist\cjs\internal\Observable.js:26:0)
System.err: at (file: src\app\scan\scan.component.ts:1313:111)
System.err: at (file: node_modules\rxjs\dist\cjs\internal\Subscriber.js:161:0)
System.err: at exports.modules../node_modules/rxjs/dist/cjs/internal/Subscriber.js.Subscriber._next(file: node_modules\rxjs\dist\cjs\internal\Subscriber.js:101:0)
System.err: at exports.modules../node_modules/rxjs/dist/cjs/internal/Subscriber.js.Subscriber.next(file: node_modules\rxjs\dist\cjs\internal\Subscriber.js:72:0)
System.err: at (file: src\app\services\firebase\storage\firebase-storage.service.ts:19:0)
System.err: at onComplete(file: node_modules@nativescript\firebase-storage\index.android.js:137:0)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err: at com.tns.gen.java.lang.Runnable.run(Runnable.java:17)
System.err: at android.os.Handler.handleCallback(Handler.java:938)
System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
System.err: at android.os.Looper.loop(Looper.java:246)
System.err: at android.app.ActivityThread.main(ActivityThread.java:8653)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Please don't forget that its doing that on set AND update

If you can help @triniwiz thank you

ERROR on send email verification. ONLY android.

I got this error:

Error: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter actionCodeSettings

on android emulator when tried to send email verification. The account on firebase is created instead.

Please see in the image below details about the implementation, the error and also the package.json

image

image

Any idea how to fix it?

The same code it working like a charm on IOS simulator. It sends the activation email after creates the account.

[firebase-firestore]: android WriteBatch set method is closing app

Application crashes when I try to batch write with set method on android. Documents are not added and there is no error message. No problem on iOS.

  firestore.batch()
        .set(exampleDoc, {
            message: message,
        })
        .set(exampleDoc2, {
            date: date,
        })
        .commit()
        .then(() => {

        })
        .catch((error) => {
           console.error(error);
        });

Cannot load dependencies correctly

i have created a demo repo for you to checkout. basically when i switch from EddyVerbruggen/nativescript-plugin-firebase to this firebase plugin, webpack is not compiling correctly anymore. see the following issue

ERROR in ./node_modules/@nativescript/firebase-crashlytics/index.android.js 15:0-39
Module not found: Error: Can't resolve 'stacktrace-js' in 'D:\firebase-test\node_modules\@nativescript\firebase-crashlytics'
resolve 'stacktrace-js' in 'D:\firebase-test\node_modules\@nativescript\firebase-crashlytics'
  Parsed request is a module
  using description file: D:\firebase-test\node_modules\@nativescript\firebase-crashlytics\package.json (relative path: .)
    resolve as module
...

This happens upon calling import { firebase } from '@nativescript/firebase-core';

when i manually add stacktrace-js as a dependency i get the same problem with "fs" module. so something is not working.

to reproduce:

  1. clone repo https://github.com/eikaramba/firebase-test
  2. execute npm run dev

environment:
node: 16.6.1
npm: 7.21.1
windows 10 x64

[android-messaging] NPE on `deleteToken`

Since I use authentication in my app, I want token change callback to be called only when user is signed in.
I'm using the following:

messaging.onToken(null);
await messaging.deleteToken();

When I call deleteToken after I set onToken as null, I receive the following error:
Error: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter callback

Firebase().message() is not a function

Hello, I'm trying to implement this plugin on a basic application but I'm getting an error firebase().messaging() is not a function.

here's what the codes look like
Home.vue

<template>
		<Page @loaded="pageLoaded">
				<ActionBar>
						<Label text="Home"/>
				</ActionBar>

				<GridLayout>
						<Label class="info" textWrap="true">
								<FormattedString>
										<Span class="fas" text.decode="&#xf135; "/>
								</FormattedString>
						</Label>
						<TextView v-model="fcmToken" />
						<Button @tap="wakeLock" text="Wake lock" />
				</GridLayout>
		</Page>
</template>

<script>
import { Application } from '@nativescript/core';
import { firebase } from '@nativescript/firebase-core';
import { alert } from '@nativescript/core';

export default {
	data () {
		return {
			fcmToken: null,
			screenManager: null
		}
	},

	computed: {
		message() {
			return `Blank {N}-Vue app\n\n ${this.fcmToken}`;
		}
	},

	methods: {

		pageLoaded () {
			this.initFirebase()

			this.getFCMToken()

			this.handleFCMEvents()
		},

		async getFCMToken() {
			firebase()
				.messaging()
				.getToken()
				.then(token => {
					this.fcmToken = token
				})

			firebase()
				.messaging()
				.onTokenRefresh(token => {
      		this.fcmToken = token
				});
		},

		handleFCMEvents () {
			firebase()
				.messaging()
				.onMessage(async (remoteMessage) => {
					alert('[onMessage] A new FCM message arrived!', JSON.stringify(remoteMessage));
				})

			firebase().messaging()
				.setBackgroundMessageHandler(async (message) => {
					alert('[onMessage] A new FCM message arrived!', JSON.stringify(message));
				})
		},

		async initFirebase () {
			try {
				firebase().messaging().showNotificationsWhenInForeground = true
			}
			catch (error) {
				console.error('failed to initialize firebase plugin with error: ', error)
			}
		}
	}
};
</script>

app.js

import Vue from 'nativescript-vue'

import Home from './components/Home'

new Vue({
  render: (h) => h('frame', [h(Home)]),
}).$start()

package.json dependencies

"dependencies": {
    "@nativescript/core": "~8.1.1",
    "@nativescript/firebase-messaging": "^1.0.0-alpha.0",
    "@nativescript/theme": "~3.0.1",
    "nativescript-vue": "~2.9.0"
  },
  "devDependencies": {
    "@nativescript/android": "8.1.1",
    "@nativescript/webpack": "~5.0.0",
    "nativescript-vue-template-compiler": "~2.9.0",
    "webpack-cli": "^3.3.12"
  }

[firebase-firestore] FieldValue doesn't work inside the batch write

example:

   firestore.batch().set(exampleDoc, {
            date: FieldValue.serverTimestamp()
        }) ...

This create the empty map object in the document like this: date: {}.
This problem exist in the all FieldValue methods on batch write. serverTimestamp, increment, arrayUnion.. and probably exist on GeoPoint.

it seems like, set() and update() method which are inside the batchwrite have different data-serialize stages compared to the normal set(), update() methods

[firebase-messaging] Token change callback is not triggered in android

It seems that onToken callback is never called. I reinstalled app and deleted token but none of these seem to trigger it.

Sample:

var messaging = firebase().messaging();
// This is never called
messaging.onToken(function(token) {
  console.log(token);
});
messaging.showNotificationsWhenInForeground = true;

try {
  await messaging.deleteToken();
  let token = await messaging.getToken();
} catch(err) {
}

In order to confirm this, I also created my custom Service class and assigned it as a service into my app's manifest file.
The following class method was triggered on app start and token deletion.

package org.dnr;

public class FirebaseMessagingCustom extends com.google.firebase.messaging.FirebaseMessagingService {
	@Override
	public void onNewToken(String token) {
		System.err.println("Token: " + token);
		super.onNewToken(token);
	}
}

I wonder if the following service declaration is really working: https://github.com/NativeScript/firebase/blob/main/packages/firebase-messaging/src-native/android/messaging/src/main/AndroidManifest.xml#L10

[firebase-auth] How to obtain appleCredentialIdentityToken and rawNonce parameters not clear

The example code for Sign In With Apple functionality is as follows:

import { firebase } from '@nativescript/firebase-core';
import { OAuthProvider } from '@nativescript/firebase-auth';
const oauthCredential = new OAuthProvider('apple.com');
oauthCredential.credential(appleCredentialIdentityToken /* idToken */, rawNonce /* nonce */);

firebase().auth().signInWithCredential(oauthCredential);

Where is the appleCredentialIdentityToken and rawNonce obtained?

[firebase-database] ServerValue.timestamp()

Hello. I am trying to add server timestamp to realtime database:

        database.ref('/table').set({
            date: ServerValue.timeStamp()
        });

But, this doesn't create anything. ServerValue.timeStamp() returns empty object. I am not sure, is this a bug or is there another way to add timestamp

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.