Skip to content

Commit

Permalink
feat: v2
Browse files Browse the repository at this point in the history
fixes: #88
fixes: #77
breaking(android): min sdk is now API 19 (kitkat) for Analytics, Firestore, Messaging & Dynamic Links
  • Loading branch information
triniwiz committed May 18, 2022
1 parent 8a53b8b commit 4dc8122
Show file tree
Hide file tree
Showing 69 changed files with 1,035 additions and 902 deletions.
19 changes: 11 additions & 8 deletions apps/demo/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ dynamicLinks.onLink((link) => {
});

const messaging = firebase().messaging();
messaging.onMessage((message) => {
console.log('Firebase onMessage', message);
});

messaging.onNotificationTap((message) => {
console.log('Firebase onNotificationTap', message);
});
Application.on('launch', (args) => {
messaging.onMessage((message) => {
console.log('Firebase onMessage', message);
});

messaging.onToken((token) => {
console.log('Firebase onToken', token);
messaging.onNotificationTap((message) => {
console.log('Firebase onNotificationTap', message);
});

messaging.onToken((token) => {
console.log('Firebase onToken', token);
});
});

messaging
Expand Down
9 changes: 6 additions & 3 deletions apps/demo/src/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class MainViewModel extends Observable {
{
name: 'firebase-app-check',
},
{
name: 'firebase-app-check-debug',
},
{
name: 'firebase-in-app-messaging',
},
Expand All @@ -38,9 +41,9 @@ export class MainViewModel extends Observable {
{
name: 'firebase-messaging',
},
{
name: 'firebase-firestore',
},
{
name: 'firebase-firestore',
},
];

viewDemo(args) {
Expand Down
6 changes: 3 additions & 3 deletions apps/demo/src/plugin-demos/firebase-admob.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ xmlns:ui="@nativescript/firebase-admob"
</ActionBar>
</Page.actionBar>
<StackLayout class="p-20">
<!-- <ui:BannerAd height="100" width="100" unitId="{{bannerAdUnit}}" layoutChanged="{{bannerLoaded}}"/> -->
<ui:NativeAdView height="400" loaded="{{nativeAdLoaded}}" layoutChanged="{{nativeAdLayoutChanged}}">
<ui:BannerAd height="100" width="100" unitId="{{bannerAdUnit}}" layoutChanged="{{bannerLoaded}}"/>
<!-- <ui:NativeAdView height="400" loaded="{{nativeAdLoaded}}" layoutChanged="{{nativeAdLayoutChanged}}">
<GridLayout rows="auto,auto,auto,auto" height="300" width="300">
<Label id="headLineView" text="First"/>
<ui:MediaView row="1" id="mediaView" height="100%"/>
<Label row="2" id="bodyView"/>
<Image id="iconView" row="3"/>
</GridLayout>
</ui:NativeAdView>
</ui:NativeAdView> -->
</StackLayout>
</Page>
19 changes: 17 additions & 2 deletions apps/demo/src/plugin-demos/firebase-app-check-debug.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import { Observable, EventData, Page } from '@nativescript/core';
import { DemoSharedFirebaseAppCheckDebug } from '@demo/shared';
import { } from '@nativescript/firebase-app-check-debug';
import { firebase } from '@nativescript/firebase-core';
import '@nativescript/firebase-app-check-debug';

export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = new DemoModel();
}

export class DemoModel extends DemoSharedFirebaseAppCheckDebug {

constructor() {
super();
}

testIt(): void {
firebase()
.appCheck()
.getToken(true)
.then((token) => {
console.log(token.token);
})
.catch((error) => {
console.log(error);
});
}
}
20 changes: 12 additions & 8 deletions apps/demo/src/plugin-demos/firebase-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ export class DemoModel extends DemoSharedFirebaseDatabase {
super();
this.auth = firebase().auth();
this.database = firebase().database();
}

testIt(): void {
this.transaction();
this.randomData();
this.children();
this.setData();
}

setData(){
setData() {
this.database
.ref('/person/me')
.set({ name: 'set', boolean: true , updated: new Date() })
.then((value) => {
console.log('set some data', value);
}).catch(e =>{
console.log('failed to set data', e);
});
.ref('/person/me')
.set({ name: 'set', boolean: true, updated: new Date() })
.then((value) => {
console.log('set some data', value);
})
.catch((e) => {
console.log('failed to set data', e);
});
}

randomData() {
Expand Down
32 changes: 17 additions & 15 deletions apps/demo/src/plugin-demos/firebase-firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export function navigatingTo(args: EventData) {
export class DemoModel extends DemoSharedFirebaseFirestore {
constructor() {
super();
Promise.all([this.init(),this.invalid_field_path()]);
}

testIt(): void {
Promise.all([this.init(), this.invalid_field_path()]);
}

async init() {
Expand Down Expand Up @@ -57,21 +60,20 @@ export class DemoModel extends DemoSharedFirebaseFirestore {
const exampleDoc2 = firebase().firestore().collection('things').doc('exampleDoc2');

firebase()
.firestore()
.batch()
.set(exampleDoc, {
message: 'Hello doc',
})
.set(exampleDoc2, {
date: new Date(),
})
.commit()
.then(() => {})
.catch((error) => {
console.error(error);
});
.firestore()
.batch()
.set(exampleDoc, {
message: 'Hello doc',
})
.set(exampleDoc2, {
date: new Date(),
})
.commit()
.then(() => {})
.catch((error) => {
console.error(error);
});
}


async invalid_field_path() {
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugins",
"version": "1.2.2",
"version": "2.0.0",
"license": "MIT",
"scripts": {
"postinstall": "husky install && npx ts-patch install",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-admob/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-admob",
"version": "1.2.2",
"version": "2.0.0",
"description": "NativeScript Firebase - Admob",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-admob/platforms/android/include.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies {
implementation 'com.google.android.gms:play-services-ads:20.4.0'
implementation 'com.google.android.gms:play-services-ads:20.6.0'
implementation 'com.google.android.ump:user-messaging-platform:2.0.0'
}
2 changes: 1 addition & 1 deletion packages/firebase-admob/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
use_frameworks!
pod 'Google-Mobile-Ads-SDK', '~> 8.10'
pod 'Google-Mobile-Ads-SDK', '~> 9.5.0'
2 changes: 1 addition & 1 deletion packages/firebase-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-analytics",
"version": "1.2.2",
"version": "2.0.0",
"description": "NativeScript Firebase - Analytics",
"main": "index",
"typings": "index.d.ts",
Expand Down
5 changes: 3 additions & 2 deletions packages/firebase-analytics/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
platform :ios, '10.0'
# Firebase dependencies
if defined?($NSFirebaseAnalyticsWithoutAdIdSupport)
Pod::UI.puts "Using Firebase/AnalyticsWithoutAdIdSupport pod in place of default Firebase/Analytics"

pod 'Firebase/AnalyticsWithoutAdIdSupport','~>8.6'
pod 'Firebase/AnalyticsWithoutAdIdSupport','~>9.0'
else
Pod::UI.puts "Using default Firebase/Analytics with Ad Ids. May require App Tracking Transparency. Not allowed for Kids apps."
Pod::UI.puts "You may set variable `$NSFirebaseAnalyticsWithoutAdIdSupport=true` in Podfile to use analytics without ad ids."
pod 'Firebase/Analytics','~>8.6'
pod 'Firebase/Analytics','~>9.0'
end
7 changes: 3 additions & 4 deletions packages/firebase-app-check-debug/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Object.defineProperty(fb, 'appCheck', {
writable: false,
});

const NSAppCheck = lazy(() => org.nativescript.firebase.app_check_debug.FirebaseAppCheck);
const NSAppCheck = lazy(() => org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug);

export class AppCheckToken implements IAppCheckToken {
#native: com.google.firebase.appcheck.AppCheckToken;
Expand Down Expand Up @@ -66,16 +66,15 @@ export class AppCheck implements IAppCheck {
static setProviderFactory() {}

activate(isTokenAutoRefreshEnabled: boolean) {
this.native.setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled);
this.native.installAppCheckProviderFactory(com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory.getInstance());
this.native.installAppCheckProviderFactory(com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory.getInstance(), isTokenAutoRefreshEnabled);
}

getToken(forceRefresh: boolean): Promise<AppCheckToken> {
return new Promise((resolve, reject) => {
NSAppCheck().getToken(
this.native,
forceRefresh,
new org.nativescript.firebase.app_check_debug.FirebaseAppCheck.Callback({
new org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug.Callback({
onSuccess(param0) {
resolve(AppCheckToken.fromNative(param0));
},
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-app-check-debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-app-check-debug",
"version": "1.2.2",
"version": "2.0.0",
"description": "NativeScript Firebase - App Check",
"main": "index",
"typings": "index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
implementation 'com.google.firebase:firebase-appcheck-debug:16.0.0-beta04'
implementation 'com.google.firebase:firebase-appcheck-debug'
}
2 changes: 1 addition & 1 deletion packages/firebase-app-check-debug/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
platform :ios, '11.0'
pod 'Firebase/AppCheck', '~>8.6'
pod 'Firebase/AppCheck', '~>9.0'

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.firebase:firebase-appcheck-debug:16.0.0-beta04'
def computeFirebaseBomVersion = { ->
project.hasProperty("firebaseBomVersion") ? firebaseBomVersion : "30.0.1" }
implementation platform("com.google.firebase:firebase-bom:${computeFirebaseBomVersion}")
implementation 'com.google.firebase:firebase-appcheck-debug'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,29 @@ declare module org {
export module nativescript {
export module firebase {
export module app_check_debug {
export class FirebaseAppCheck {
public static class: java.lang.Class<org.nativescript.firebase.app_check_debug.FirebaseAppCheck>;
public static Companion: org.nativescript.firebase.app_check_debug.FirebaseAppCheck.Companion;
export class FirebaseAppCheckDebug {
public static class: java.lang.Class<org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug>;
public static Companion: org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug.Companion;
public constructor();
public static getExecutorsCount(): number;
public static getToken(param0: com.google.firebase.appcheck.FirebaseAppCheck, param1: boolean, param2: org.nativescript.firebase.app_check_debug.FirebaseAppCheck.Callback<com.google.firebase.appcheck.AppCheckToken>): void;
public static getToken(param0: com.google.firebase.appcheck.FirebaseAppCheckDebug, param1: boolean, param2: org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug.Callback<com.google.firebase.appcheck.AppCheckToken>): void;
public static setExecutorsCount(param0: number): void;
}
export module FirebaseAppCheck {
export class Callback<T> extends java.lang.Object {
public static class: java.lang.Class<org.nativescript.firebase.app_check_debug.FirebaseAppCheck.Callback<any>>;
export module FirebaseAppCheckDebug {
export class Callback<T> extends java.lang.Object {
public static class: java.lang.Class<org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug.Callback<any>>;
/**
* Constructs a new instance of the org.nativescript.firebase.app_check_debug.FirebaseAppCheck$Callback interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
* Constructs a new instance of the org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug$Callback interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
*/
public constructor(implementation: {
onSuccess(param0: T): void;
onError(param0: any): void;
});
public constructor(implementation: { onSuccess(param0: T): void; onError(param0: any): void });
public constructor();
public onError(param0: any): void;
public onSuccess(param0: T): void;
}
export class Companion {
public static class: java.lang.Class<org.nativescript.firebase.app_check_debug.FirebaseAppCheck.Companion>;
public static class: java.lang.Class<org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug.Companion>;
public setExecutorsCount(param0: number): void;
public getToken(param0: com.google.firebase.appcheck.FirebaseAppCheck, param1: boolean, param2: org.nativescript.firebase.app_check_debug.FirebaseAppCheck.Callback<com.google.firebase.appcheck.AppCheckToken>): void;
public getToken(param0: com.google.firebase.appcheck.FirebaseAppCheckDebug, param1: boolean, param2: org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug.Callback<com.google.firebase.appcheck.AppCheckToken>): void;
public getExecutorsCount(): number;
}
}
Expand All @@ -53,5 +50,4 @@ declare module org {
}

//Generics information:
//org.nativescript.firebase.app_check_debug.FirebaseAppCheck.Callback:1

//org.nativescript.firebase.app_check_debug.FirebaseAppCheckDebug.Callback:1
2 changes: 1 addition & 1 deletion packages/firebase-app-check/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-app-check",
"version": "1.2.2",
"version": "2.0.0",
"description": "NativeScript Firebase - App Check",
"main": "index",
"typings": "index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta02'
implementation 'com.google.firebase:firebase-appcheck-safetynet'
}
2 changes: 1 addition & 1 deletion packages/firebase-app-check/platforms/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
platform :ios, '11.0'
pod 'Firebase/AppCheck', '~>8.6'
pod 'Firebase/AppCheck', '~>9.0'
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ dependencies {
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta02'
def computeFirebaseBomVersion = { ->
project.hasProperty("firebaseBomVersion") ? firebaseBomVersion : "30.0.1" }
implementation platform("com.google.firebase:firebase-bom:${computeFirebaseBomVersion}")
implementation 'com.google.firebase:firebase-appcheck-safetynet'
}
2 changes: 0 additions & 2 deletions packages/firebase-auth/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,6 @@ export class PhoneAuthProvider {
reject();
} else {
this.native.verifyPhoneNumberUIDelegateCompletion(phoneNumber, null, (verificationId, error) => {
console.log('verifyPhoneNumberUIDelegateCompletion', verificationId, error);
console.log(UIApplication.sharedApplication.delegate.respondsToSelector('application:didReceiveRemoteNotification:fetchCompletionHandler'));
if (error) {
reject(FirebaseError.fromNative(error));
} else {
Expand Down
Loading

0 comments on commit 4dc8122

Please sign in to comment.