diff --git a/README.md b/README.md index 05eaf05f..c6b4c7ef 100755 --- a/README.md +++ b/README.md @@ -17,9 +17,11 @@ Firebase
-> Plugin version **10.0.0** works with NativeScript 6.1+. Using an older version? Stick to plugin version < 10. +> For NativeScript 7 compatibility, run `tns plugin add @nativescript/firebase`. -> For NativeScript 7 compatibiliy, install `@nativescript/firebase` version 11+. +> For NativeScript 6.1+ compatibility, install polugin version 10: `tns plugin add nativescript-plugin-firebase@10`. + +> For NativeScript 6.0 and lower, stick to plugin version < 10. ## Features * [AdMob](docs/ADMOB.md) @@ -54,16 +56,16 @@ If you rather watch a (slightly outdated) video explaining the steps then check add iOS and Android support to the Firebase console and how to integrate anonymous authentication: [![YouTube demo](docs/images/yt-thumb-setup.png)](https://youtu.be/IextEpoIzwE "YouTube demo") -From the command prompt go to your app's root folder and execute: +From the command prompt go to your app's root folder and execute this for NativeScript 7+: ```bash -tns plugin add nativescript-plugin-firebase +tns plugin add @nativescript/firebase ``` -or for NativeScript 7+: +or for NativeScript 6: ```bash -tns plugin add @nativescript/firebase +tns plugin add nativescript-plugin-firebase ``` This will launch an install script which will guide you through installing additional components. diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts index 317be73c..23d0fccc 100644 --- a/demo/app/main-view-model.ts +++ b/demo/app/main-view-model.ts @@ -1,20 +1,23 @@ -import { firebase, AddEventListenerResult, admob as firebaseAdMob, crashlytics as firebaseCrashlytics, GetRemoteConfigResult, IdTokenResult, LogComplexEventTypeParameter, performance as firebasePerformance, storage as firebaseStorage, User } from "@nativescript/firebase"; +import { alert, File, isAndroid, isIOS, knownFolders, Observable, prompt } from "@nativescript/core"; +import { firebase } from "@nativescript/firebase"; +import { admob as firebaseAdmob } from "@nativescript/firebase/admob"; import { RewardedVideoAdReward } from "@nativescript/firebase/admob/admob"; +import { analytics as firebaseAnalytics } from "@nativescript/firebase/analytics"; +import { crashlytics as firebaseCrashlytics } from "@nativescript/firebase/crashlytics"; +import { firebaseFunctions } from "@nativescript/firebase/functions"; +import { performance as firebasePerformance } from "@nativescript/firebase/performance"; import { FirebaseTrace } from "@nativescript/firebase/performance/performance"; -import { Observable, isAndroid, isIOS, Dialogs, knownFolders, File } from "@nativescript/core"; -import { UploadMetadata } from "../../src/storage/storage"; +import { storage as firebaseStorage } from "@nativescript/firebase/storage"; +import { UploadMetadata } from "@nativescript/firebase/storage/storage"; import { MessagingViewModel } from "./messaging-view-model"; const firebaseWebApi = require("@nativescript/firebase/app"); -declare const Crashlytics: any; - export class HelloWorldModel extends Observable { - public messaging = new MessagingViewModel(); public userEmailOrPhone: string; - private userListenerWrapper: AddEventListenerResult; - private companiesListenerWrapper: AddEventListenerResult; + private userListenerWrapper: firebase.AddEventListenerResult; + private companiesListenerWrapper: firebase.AddEventListenerResult; private onAuthStateChangedHandlerSet = false; private firebaseTrace: FirebaseTrace; @@ -25,7 +28,7 @@ export class HelloWorldModel extends Observable { private ensureWebOnAuthChangedHandler(): void { if (!this.onAuthStateChangedHandlerSet) { this.onAuthStateChangedHandlerSet = true; - firebaseWebApi.auth().onAuthStateChanged((user?: User) => { + firebaseWebApi.auth().onAuthStateChanged((user?: firebase.User) => { console.log(">> auth state changed: " + user); if (user) { this.set("userEmailOrPhone", user.email ? user.email : (user.phoneNumber ? user.phoneNumber : "N/A")); @@ -133,7 +136,7 @@ export class HelloWorldModel extends Observable { public doWebCreateUser(): void { firebaseWebApi.auth().createUserWithEmailAndPassword('eddyverbruggen+firebasewebapi@gmail.com', 'firebase') - .then((user: User) => { + .then((user: firebase.User) => { console.log("User created: " + JSON.stringify(user)); this.set("userEmailOrPhone", user.email); alert({ @@ -175,7 +178,7 @@ export class HelloWorldModel extends Observable { public doWebCallableFunction(): void { // see the implementation of this function @ https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/ff95c77c7b09acf66654f53c52e8ae0c8d7b1c78/demo/firebasefunctions/functions/src/index.ts#L15-L19 - const fn = firebase.functions.httpsCallable("helloName"); + const fn = firebaseFunctions.httpsCallable("helloName"); fn("Nativescript-Plugin-Firebase!") .then((dataCue: any) => { @@ -288,7 +291,7 @@ export class HelloWorldModel extends Observable { public doWebStoreCompanyByFirstCreatingKey(): void { const path = "companies", - companyRef = firebaseWebApi.database().ref().child(path), + companyRef = firebaseWebApi.database().ref(path), newCompanyKey = companyRef.push().key, storeAtPath = `/${path}/${newCompanyKey}`, value = { @@ -464,7 +467,7 @@ export class HelloWorldModel extends Observable { } public doEnableAnalytics(): void { - firebase.analytics.setAnalyticsCollectionEnabled(true); + firebaseAnalytics.setAnalyticsCollectionEnabled(true); alert({ title: "Analytics collection", message: "ENABLED", @@ -473,7 +476,7 @@ export class HelloWorldModel extends Observable { } public doDisableAnalytics(): void { - firebase.analytics.setAnalyticsCollectionEnabled(false); + firebaseAnalytics.setAnalyticsCollectionEnabled(false); alert({ title: "Analytics collection", message: "DISABLED", @@ -482,7 +485,7 @@ export class HelloWorldModel extends Observable { } public doLogAnalyticsEvents(): void { - firebase.analytics.logEvent({ + firebaseAnalytics.logEvent({ // see https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html key: "add_to_cart", parameters: [ @@ -514,7 +517,7 @@ export class HelloWorldModel extends Observable { * Same thing as logEvent but can add an array or specific types not just string (LogComplexEventTypeParameter.BOOLEAN, LogComplexEventTypeParameter.STRING, * LogComplexEventTypeParameter.DOUBLE, LogComplexEventTypeParameter.FLOAT, LogComplexEventTypeParameter.INT, LogComplexEventTypeParameter.ARRAY) */ - firebase.analytics.logComplexEvent({ + firebaseAnalytics.logComplexEvent({ key: "view_item_list", parameters: [{ key: "item1", @@ -522,26 +525,26 @@ export class HelloWorldModel extends Observable { value: [ { parameters: [ - {key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING}, - {key: "item_name", value: "name of item", type: LogComplexEventTypeParameter.STRING}, - {key: "item_category", value: "category", type: LogComplexEventTypeParameter.STRING}, - {key: "item_variant", value: "variant", type: LogComplexEventTypeParameter.STRING}, - {key: "item_brand", value: "name of item brand", type: LogComplexEventTypeParameter.STRING}, - {key: "price", value: 1, type: LogComplexEventTypeParameter.DOUBLE}, - {key: "item_list", value: "name of list", type: LogComplexEventTypeParameter.STRING}, - {key: "index", value: 1, type: LogComplexEventTypeParameter.INT} + {key: "item_id", value: "id of item", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_name", value: "name of item", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_category", value: "category", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_variant", value: "variant", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_brand", value: "name of item brand", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "price", value: 1, type: firebase.LogComplexEventTypeParameter.DOUBLE}, + {key: "item_list", value: "name of list", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "index", value: 1, type: firebase.LogComplexEventTypeParameter.INT} ] }, { parameters: [ - {key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING}, - {key: "item_name", value: "name of item", type: LogComplexEventTypeParameter.STRING}, - {key: "item_category", value: "category", type: LogComplexEventTypeParameter.STRING}, - {key: "item_variant", value: "variant", type: LogComplexEventTypeParameter.STRING}, - {key: "item_brand", value: "name of item brand", type: LogComplexEventTypeParameter.STRING}, - {key: "price", value: 1, type: LogComplexEventTypeParameter.DOUBLE}, - {key: "item_list", value: "name of list", type: LogComplexEventTypeParameter.STRING}, - {key: "index", value: 2, type: LogComplexEventTypeParameter.INT} + {key: "item_id", value: "id of item", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_name", value: "name of item", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_category", value: "category", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_variant", value: "variant", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "item_brand", value: "name of item brand", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "price", value: 1, type: firebase.LogComplexEventTypeParameter.DOUBLE}, + {key: "item_list", value: "name of list", type: firebase.LogComplexEventTypeParameter.STRING}, + {key: "index", value: 2, type: firebase.LogComplexEventTypeParameter.INT} ] } ] @@ -551,7 +554,7 @@ export class HelloWorldModel extends Observable { } public doSetAnalyticsUserProperty(): void { - firebase.analytics.setUserProperty({ + firebaseAnalytics.setUserProperty({ key: "origin", // note that this needs to be preregistered, see https://support.google.com/firebase/answer/6317519?hl=en&ref_topic=6317489#create-property value: "demoapp" }).then( @@ -580,7 +583,7 @@ export class HelloWorldModel extends Observable { } private setScreenName(screenName): void { - firebase.analytics.setScreenName({ + firebaseAnalytics.setScreenName({ screenName }).then( () => { @@ -600,8 +603,8 @@ export class HelloWorldModel extends Observable { } public doShowAdMobBanner(): void { - firebaseAdMob.showBanner({ - size: firebaseAdMob.AD_SIZE.SMART_BANNER, + firebaseAdmob.showBanner({ + size: firebaseAdmob.AD_SIZE.SMART_BANNER, margins: { bottom: isIOS ? 50 : 0 }, @@ -637,7 +640,7 @@ export class HelloWorldModel extends Observable { } public doShowAdMobInterstitial(): void { - firebase.admob.showInterstitial({ + firebaseAdmob.showInterstitial({ iosInterstitialId: "ca-app-pub-9517346003011652/6938836122", androidInterstitialId: "ca-app-pub-9517346003011652/9225834529", testing: true, @@ -661,7 +664,7 @@ export class HelloWorldModel extends Observable { } public doPreloadAdMobInterstitial(): void { - firebaseAdMob.preloadInterstitial({ + firebaseAdmob.preloadInterstitial({ iosInterstitialId: "ca-app-pub-9517346003011652/6938836122", androidInterstitialId: "ca-app-pub-9517346003011652/9225834529", testing: true, @@ -687,7 +690,7 @@ export class HelloWorldModel extends Observable { } public doShowPreloadedAdMobInterstitial(): void { - firebaseAdMob.showInterstitial().then( + firebaseAdmob.showInterstitial().then( () => console.log("AdMob interstitial showing"), errorMessage => { alert({ @@ -700,7 +703,7 @@ export class HelloWorldModel extends Observable { } public doPreloadRewardedVideoAd(): void { - firebaseAdMob.preloadRewardedVideoAd({ + firebaseAdmob.preloadRewardedVideoAd({ iosAdPlacementId: "ca-app-pub-9517346003011652/8586553377", androidAdPlacementId: "ca-app-pub-9517346003011652/2819097664", testing: true, @@ -727,7 +730,7 @@ export class HelloWorldModel extends Observable { public doShowPreloadedRewardedVideoAd(): void { let reward: RewardedVideoAdReward; - firebaseAdMob.showRewardedVideoAd({ + firebaseAdmob.showRewardedVideoAd({ onRewarded: receivedReward => { reward = receivedReward; console.log("Rewarded video ad: rewarded. Details: " + JSON.stringify(reward)); @@ -767,7 +770,7 @@ export class HelloWorldModel extends Observable { * so there's no function to do it programmatically. */ public doHideAdMobBanner(): void { - firebase.admob.hideBanner().then( + firebaseAdmob.hideBanner().then( () => { console.log("AdMob banner hidden"); }, @@ -814,7 +817,7 @@ export class HelloWorldModel extends Observable { "default": 11 }] }).then( - (result: GetRemoteConfigResult) => { + (result: firebase.GetRemoteConfigResult) => { console.log("remote config fetched: " + JSON.stringify(result.properties)); alert({ title: `Fetched at ${result.lastFetch} ${result.throttled ? '(throttled)' : ''}`, @@ -931,7 +934,7 @@ export class HelloWorldModel extends Observable { email: 'eddyverbruggen+firebasetest@gmail.com', password: 'firebase' }).then( - (user: User) => { + (user: firebase.User) => { console.log("User created: " + JSON.stringify(user)); this.set("userEmailOrPhone", user.email); alert({ @@ -992,7 +995,7 @@ export class HelloWorldModel extends Observable { { forceRefresh: false }) - .then((result: IdTokenResult) => console.log("Auth token retrieved: " + JSON.stringify(result))) + .then((result: firebase.IdTokenResult) => console.log("Auth token retrieved: " + JSON.stringify(result))) .catch(errorMessage => console.log("Auth token retrieval error: " + errorMessage)); }, errorMessage => { @@ -1959,7 +1962,7 @@ export class HelloWorldModel extends Observable { public doSetUserId(): void { // just for fun: showing usage of 'firebase.crashlytics' instead of 'firebaseCrashlytics' - firebase.crashlytics.setUserId("user#42"); + firebaseCrashlytics.setUserId("user#42"); alert({ title: "User id changed", diff --git a/demo/app/vendor-platform.android.ts b/demo/app/vendor-platform.android.ts deleted file mode 100644 index 16352227..00000000 --- a/demo/app/vendor-platform.android.ts +++ /dev/null @@ -1,9 +0,0 @@ -require("application"); -if (!global["__snapshot"]) { - // In case snapshot generation is enabled these modules will get into the bundle - // but will not be required/evaluated. - // The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. - // This way, they will be evaluated on app start as early as possible. - require("ui/frame"); - require("ui/frame/activity"); -} diff --git a/demo/app/vendor-platform.ios.ts b/demo/app/vendor-platform.ios.ts deleted file mode 100644 index 5ce49d81..00000000 --- a/demo/app/vendor-platform.ios.ts +++ /dev/null @@ -1,3 +0,0 @@ -// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files -// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3 -void 0; diff --git a/demo/app/vendor-platform.ts b/demo/app/vendor-platform.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/demo/app/vendor.ts b/demo/app/vendor.ts deleted file mode 100644 index 8a381374..00000000 --- a/demo/app/vendor.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Snapshot the ~/app.css and the theme -const application = require("application"); -require("ui/styling/style-scope"); -const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/); -global.registerWebpackModules(appCssContext); -application.loadAppCss(); - -require("./vendor-platform"); - -require("bundle-entry-points"); diff --git a/demo/package.json b/demo/package.json index 97ea3d4f..6832c5b0 100644 --- a/demo/package.json +++ b/demo/package.json @@ -1,15 +1,16 @@ { "dependencies": { - "firebase-functions": "^2.0.5", - "@nativescript/firebase": "file:../src", - "nativescript-theme-core": "^1.0.4", + "@nativescript/core": "~7.0.13", + "@nativescript/firebase": "file:../publish/package/nativescript-firebase-11.1.1.tgz", "@nativescript/unit-test-runner": "~1.0.2", - "@nativescript/core": "7.0.0", - "@nativescript/webpack": "~3.0.0" + "firebase-functions": "^2.0.5", + "nativescript-theme-core": "^1.0.4" }, "devDependencies": { + "@nativescript/android": "7.0.1", "@nativescript/ios": "7.0.4", - "@nativescript/types": "~7.0.0", + "@nativescript/types": "~7.0.4", + "@nativescript/webpack": "~3.0.8", "@types/jasmine": "~2.8.0", "babel-traverse": "6.12.0", "babel-types": "6.11.1", @@ -19,11 +20,9 @@ "karma": "4.1.0", "karma-jasmine": "2.0.1", "karma-nativescript-launcher": "^0.4.0", - "karma-webpack": "3.0.5", "lazy": "1.0.11", - "nativescript-css-loader": "~0.26.0", "tslint": "~5.4.3", - "typescript": "~4.0.0" + "typescript": "~4.0.5" }, "scripts": { "build.plugin": "cd ../src && npm run build", diff --git a/docs/CRASHLYTICS.md b/docs/CRASHLYTICS.md index 76826a34..e8df5bde 100644 --- a/docs/CRASHLYTICS.md +++ b/docs/CRASHLYTICS.md @@ -26,7 +26,10 @@ Then produce a crash, and it can easily take a day before that screen changes (l Send a native iOS or Android exception to Crashlytics. ```typescript -// either import like this: +// for NativeScript 7, import like this: +import { crashlytics } from "@nativescript/firebase/crashlytics"; + +// for older versions of NativeScript, either import like this: import { crashlytics } from "nativescript-plugin-firebase"; // and do: crashlytics.sendCrashLog // or this: import { crashlytics as firebaseCrashlytics } from "nativescript-plugin-firebase"; // and do: firebaseCrashlytics.sendCrashLog diff --git a/src/app/functions/index.ts b/src/app/functions/index.ts index 74f0ebe0..132b1f9a 100644 --- a/src/app/functions/index.ts +++ b/src/app/functions/index.ts @@ -1,10 +1,10 @@ -import { functions as fNamepspace } from "../../firebase"; +import { firebaseFunctions as fNamespace } from "../../firebase"; export namespace functions { // tslint:disable-next-line:class-name export class Functions { - httpsCallable(functionName: string, region?: fNamepspace.SupportedRegions) { - return fNamepspace.httpsCallable(functionName, region); + httpsCallable(functionName: string, region?: fNamespace.SupportedRegions) { + return fNamespace.httpsCallable(functionName, region); } } } \ No newline at end of file diff --git a/src/firebase.d.ts b/src/firebase.d.ts index bf21627c..907d61b8 100644 --- a/src/firebase.d.ts +++ b/src/firebase.d.ts @@ -782,8 +782,6 @@ export namespace firebase { * Tells the client to keep its local cache in sync with the server automatically. */ export function keepInSync(path: string, switchOn: boolean): Promise; - - } export namespace firestore { @@ -1222,7 +1220,7 @@ export namespace firestore { function clearPersistence(): Promise; } -export namespace functions { +export namespace firebaseFunctions { export type SupportedRegions = | "us-central1" | "us-east1" diff --git a/src/functions/functions.android.ts b/src/functions/functions.android.ts index c0372a8e..56f02108 100644 --- a/src/functions/functions.android.ts +++ b/src/functions/functions.android.ts @@ -2,7 +2,7 @@ import * as firebase from "../firebase"; import { firebase as firebaseCommon } from "../firebase-common"; import { HttpsCallable } from "./functions"; -export function httpsCallable(functionName: string, region: firebase.functions.SupportedRegions = "us-central1"): HttpsCallable { +export function httpsCallable(functionName: string, region: firebase.firebaseFunctions.SupportedRegions = "us-central1"): HttpsCallable { const instance = com.google.firebase.functions.FirebaseFunctions.getInstance(region); return (data: I) => new Promise((resolve, reject) => { diff --git a/src/functions/functions.d.ts b/src/functions/functions.d.ts index 29194eb8..708a9bc2 100644 --- a/src/functions/functions.d.ts +++ b/src/functions/functions.d.ts @@ -1,5 +1,7 @@ +import { firebaseFunctions } from "../firebase"; + export declare type HttpsCallable = (callableData: I) => Promise; -export declare function httpsCallable(functionName: string, region?: SupportedRegions): HttpsCallable; +export declare function httpsCallable(functionName: string, region?: firebaseFunctions.SupportedRegions): HttpsCallable; export declare function useFunctionsEmulator(origin: string): void; \ No newline at end of file diff --git a/src/functions/functions.ios.ts b/src/functions/functions.ios.ts index 8d2f7196..0e088793 100644 --- a/src/functions/functions.ios.ts +++ b/src/functions/functions.ios.ts @@ -4,14 +4,14 @@ import { HttpsCallable } from './functions'; let functions: FIRFunctions; -function getFunctions(region?: firebase.functions.SupportedRegions): FIRFunctions { +function getFunctions(region?: firebase.firebaseFunctions.SupportedRegions): FIRFunctions { if (!functions) { functions = region ? FIRFunctions.functionsForRegion(region) : FIRFunctions.functions(); } return functions; } -export function httpsCallable(functionName: string, region?: firebase.functions.SupportedRegions): HttpsCallable { +export function httpsCallable(functionName: string, region?: firebase.firebaseFunctions.SupportedRegions): HttpsCallable { const functions = getFunctions(region); return (data: I) => new Promise((resolve, reject) => { diff --git a/src/functions/index.ts b/src/functions/index.ts index 6fdfcc70..a8f4d445 100644 --- a/src/functions/index.ts +++ b/src/functions/index.ts @@ -1,2 +1,2 @@ import * as callableFns from "./functions"; -export const functions = callableFns; +export const firebaseFunctions = callableFns; diff --git a/src/mlkit/barcodescanning/index.android.ts b/src/mlkit/barcodescanning/index.android.ts index 75dcc9dd..b41a3098 100644 --- a/src/mlkit/barcodescanning/index.android.ts +++ b/src/mlkit/barcodescanning/index.android.ts @@ -4,8 +4,6 @@ import { BarcodeFormat, MLKitBarcodeScanner as MLKitBarcodeScannerBase } from ". export { BarcodeFormat }; -const gmsTasks = (com.google.android.gms).tasks; - export class MLKitBarcodeScanner extends MLKitBarcodeScannerBase { private player: android.media.MediaPlayer; @@ -59,7 +57,7 @@ export class MLKitBarcodeScanner extends MLKitBarcodeScannerBase { } protected createSuccessListener(): any { - return new gmsTasks.OnSuccessListener({ + return new (com.google.android.gms).tasks.OnSuccessListener({ onSuccess: barcodes => { const result = { @@ -142,7 +140,7 @@ export function scanBarcodesOnDevice(options: MLKitScanBarcodesOnDeviceOptions): const image: android.graphics.Bitmap = options.image instanceof ImageSource ? options.image.android : options.image.imageSource.android; const firImage = com.google.firebase.ml.vision.common.FirebaseVisionImage.fromBitmap(image); - const onSuccessListener = new gmsTasks.OnSuccessListener({ + const onSuccessListener = new (com.google.android.gms).tasks.OnSuccessListener({ onSuccess: barcodes => { const result = { barcodes: [] @@ -171,7 +169,7 @@ export function scanBarcodesOnDevice(options: MLKitScanBarcodesOnDeviceOptions): } }); - const onFailureListener = new gmsTasks.OnFailureListener({ + const onFailureListener = new (com.google.android.gms).tasks.OnFailureListener({ onFailure: exception => reject(exception.getMessage()) }); diff --git a/src/mlkit/custommodel/index.android.ts b/src/mlkit/custommodel/index.android.ts index cc151283..c219e3ce 100644 --- a/src/mlkit/custommodel/index.android.ts +++ b/src/mlkit/custommodel/index.android.ts @@ -2,8 +2,6 @@ import { ImageSource, knownFolders } from "@nativescript/core"; import { MLKitCustomModelOptions, MLKitCustomModelResult, MLKitCustomModelResultValue } from "./"; import { getLabelsFromAppFolder, MLKitCustomModel as MLKitCustomModelBase } from "./custommodel-common"; -const gmsTasks = (com.google.android.gms).tasks; - export class MLKitCustomModel extends MLKitCustomModelBase { private detector; private onFailureListener; @@ -22,7 +20,7 @@ export class MLKitCustomModel extends MLKitCustomModelBase { this.detectorBusy = true; if (!this.onFailureListener) { - this.onFailureListener = new gmsTasks.OnFailureListener({ + this.onFailureListener = new (com.google.android.gms).tasks.OnFailureListener({ onFailure: exception => { console.log(exception.getMessage()); this.detectorBusy = false; @@ -65,7 +63,7 @@ export class MLKitCustomModel extends MLKitCustomModelBase { } protected createSuccessListener(): any { - this.onSuccessListener = new gmsTasks.OnSuccessListener({ + this.onSuccessListener = new (com.google.android.gms).tasks.OnSuccessListener({ onSuccess: output => { const probabilities: Array = output.getOutput(0)[0]; @@ -136,7 +134,7 @@ export function useCustomModel(options: MLKitCustomModelOptions): Promisecom.google.android.gms).tasks.OnSuccessListener({ onSuccess: output => { const probabilities: Array = output.getOutput(0)[0]; @@ -154,7 +152,7 @@ export function useCustomModel(options: MLKitCustomModelOptions): Promisecom.google.android.gms).tasks.OnFailureListener({ onFailure: exception => reject(exception.getMessage()) }); diff --git a/src/mlkit/facedetection/index.android.ts b/src/mlkit/facedetection/index.android.ts index e327df00..4e1308a9 100644 --- a/src/mlkit/facedetection/index.android.ts +++ b/src/mlkit/facedetection/index.android.ts @@ -3,8 +3,6 @@ import { MLKitDetectFacesOnDeviceOptions, MLKitDetectFacesOnDeviceResult, MLKitD import { MLKitVisionOptions } from "../"; import { MLKitFaceDetection as MLKitFaceDetectionBase } from "./facedetection-common"; -const gmsTasks = (com.google.android.gms).tasks; - export class MLKitFaceDetection extends MLKitFaceDetectionBase { protected createDetector(): any { @@ -16,7 +14,7 @@ export class MLKitFaceDetection extends MLKitFaceDetectionBase { } protected createSuccessListener(): any { - return new gmsTasks.OnSuccessListener({ + return new (com.google.android.gms).tasks.OnSuccessListener({ onSuccess: faces => { if (!faces || faces.size() === 0) return; @@ -85,7 +83,7 @@ export function detectFacesOnDevice(options: MLKitDetectFacesOnDeviceOptions): P try { const firebaseVisionFaceDetector = getFaceDetector(options); - const onSuccessListener = new gmsTasks.OnSuccessListener({ + const onSuccessListener = new (com.google.android.gms).tasks.OnSuccessListener({ onSuccess: faces => { const result = { @@ -113,7 +111,7 @@ export function detectFacesOnDevice(options: MLKitDetectFacesOnDeviceOptions): P } }); - const onFailureListener = new gmsTasks.OnFailureListener({ + const onFailureListener = new (com.google.android.gms).tasks.OnFailureListener({ onFailure: exception => reject(exception.getMessage()) }); diff --git a/src/package.json b/src/package.json index 61286f1f..cdca4063 100644 --- a/src/package.json +++ b/src/package.json @@ -1,20 +1,10 @@ { "name": "@nativescript/firebase", - "version": "11.1.1-rc.0", + "version": "11.1.1", "description": "Fire. Base. Firebase!", "main": "firebase", "typings": "index.d.ts", "nativescript": { - "platforms": { - "android": "5.2.0", - "ios": "5.2.0" - }, - "plugin": { - "nan": "true", - "pan": "true", - "core3": "true", - "category": "Processing" - }, "hooks": [ { "type": "before-prepare", @@ -40,7 +30,8 @@ "tsc": "ts-patch install && tsc -skipLibCheck", "plugin.tscwatch": "npm run tsc -- -w", "package": "cd ../publish && ./pack.sh", - "demo.ios": "npm run preparedemo && cd ../demo && tns run ios", + "demo.ios": "npm run preparedemo && cd ../demo && tns run ios --emulator", + "demo.ios.eddy.iPadSim": "npm run preparedemo && cd ../demo && tns run ios --device 2542793E-9469-4F8C-A44B-620362A17B57", "demo.ios.eddy.iPad": "npm run preparedemo && cd ../demo && tns run ios --device fee4cf319a242eab4701543e4c16db89c722731f", "demo-ng.ios": "npm run preparedemo-ng && cd ../demo-ng && tns run ios", "demo-ng.ios.bundled": "npm run preparedemo-ng && cd ../demo-ng && tns run ios --bundle", @@ -144,11 +135,11 @@ }, "devDependencies": { "rimraf": "~3.0.2", - "@nativescript/core": "~7.0.0", - "@nativescript/types": "~7.0.0", - "@nativescript/webpack": "~3.0.0", + "@nativescript/core": "~7.0.13", + "@nativescript/types": "~7.0.4", + "@nativescript/webpack": "~3.0.8", "tslint": "~6.1.3", - "typescript": "~4.0.0", + "typescript": "~4.0.5", "ts-patch": "^1.3.0" } }