diff --git a/README.md b/README.md index 18198567..d3d3c572 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -- [@nativescript/firebase-admob](packages/firebase-admob/README.md) - [@nativescript/firebase-analytics](packages/firebase-analytics/README.md) - [@nativescript/firebase-app-check](packages/firebase-app-check/README.md) - [@nativescript/firebase-app-check-debug](packages/firebase-app-check-debug/README.md) diff --git a/apps/demo-angular/package.json b/apps/demo-angular/package.json index 7b018474..4d885186 100644 --- a/apps/demo-angular/package.json +++ b/apps/demo-angular/package.json @@ -7,7 +7,6 @@ "@nativescript/firebase-database": "file:../../dist/packages/firebase-database", "@nativescript/firebase-firestore": "file:../../dist/packages/firebase-firestore", "@nativescript/firebase-analytics": "file:../../dist/packages/firebase-analytics", - "@nativescript/firebase-admob": "file:../../dist/packages/firebase-admob", "@nativescript/firebase-crashlytics": "file:../../dist/packages/firebase-crashlytics", "@nativescript/firebase-app-check": "file:../../dist/packages/firebase-app-check", "@nativescript/firebase-remote-config": "file:../../dist/packages/firebase-remote-config", diff --git a/apps/demo-angular/project.json b/apps/demo-angular/project.json index 2e7235ab..2fddcebb 100644 --- a/apps/demo-angular/project.json +++ b/apps/demo-angular/project.json @@ -12,33 +12,8 @@ "production": true, "uglify": true, "release": true, - "forDevice": true - }, - "dependsOn": [ - { - "target": "build.all", - "dependencies": true - } - ] - }, - "ios": { - "executor": "@nativescript/nx:build", - "options": { - "platform": "ios", - "noHmr": true - }, - "dependsOn": [ - { - "target": "build.all", - "dependencies": true - } - ] - }, - "android": { - "executor": "@nativescript/nx:build", - "options": { - "platform": "android", - "noHmr": true + "forDevice": true, + "tsConfig": "apps/demo-angular/tsconfig.json" }, "dependsOn": [ { @@ -48,13 +23,21 @@ ] }, "clean": { - "executor": "@nativescript/nx:build", - "options": { - "clean": true - } + "executor": "@nativescript/nx:clean", + "options": {} }, "lint": { "executor": "@nx/eslint:lint" + }, + "debug": { + "executor": "@nativescript/nx:debug", + "options": { + "noHmr": true, + "uglify": false, + "release": false, + "forDevice": false, + "prepare": false + } } } } diff --git a/apps/demo-angular/src/app-routing.module.ts b/apps/demo-angular/src/app-routing.module.ts index c440a096..131105c9 100644 --- a/apps/demo-angular/src/app-routing.module.ts +++ b/apps/demo-angular/src/app-routing.module.ts @@ -7,7 +7,6 @@ import { HomeComponent } from './home.component'; const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', component: HomeComponent }, - { path: 'firebase-admob', loadChildren: () => import('./plugin-demos/firebase-admob.module').then((m) => m.FirebaseAdmobModule) }, { path: 'firebase-analytics', loadChildren: () => import('./plugin-demos/firebase-analytics.module').then((m) => m.FirebaseAnalyticsModule) }, { path: 'firebase-app-check', loadChildren: () => import('./plugin-demos/firebase-app-check.module').then((m) => m.FirebaseAppCheckModule) }, { path: 'firebase-app-check-debug', loadChildren: () => import('./plugin-demos/firebase-app-check-debug.module').then((m) => m.FirebaseAppCheckDebugModule) }, diff --git a/apps/demo-angular/src/home.component.ts b/apps/demo-angular/src/home.component.ts index d862ba7c..ba58d650 100644 --- a/apps/demo-angular/src/home.component.ts +++ b/apps/demo-angular/src/home.component.ts @@ -6,9 +6,6 @@ import { Component } from '@angular/core'; }) export class HomeComponent { demos = [ - { - name: 'firebase-admob', - }, { name: 'firebase-analytics', }, diff --git a/apps/demo-angular/src/plugin-demos/firebase-admob.component.html b/apps/demo-angular/src/plugin-demos/firebase-admob.component.html deleted file mode 100644 index 18562dcd..00000000 --- a/apps/demo-angular/src/plugin-demos/firebase-admob.component.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/apps/demo-angular/src/plugin-demos/firebase-admob.component.ts b/apps/demo-angular/src/plugin-demos/firebase-admob.component.ts deleted file mode 100644 index db70f670..00000000 --- a/apps/demo-angular/src/plugin-demos/firebase-admob.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component, NgZone } from '@angular/core'; -import { DemoSharedFirebaseAdmob } from '@demo/shared'; -import { } from '@nativescript/firebase-admob'; - -@Component({ - selector: 'demo-firebase-admob', - templateUrl: 'firebase-admob.component.html', -}) -export class FirebaseAdmobComponent { - - demoShared: DemoSharedFirebaseAdmob; - - constructor(private _ngZone: NgZone) {} - - ngOnInit() { - this.demoShared = new DemoSharedFirebaseAdmob(); - } - -} \ No newline at end of file diff --git a/apps/demo-angular/src/plugin-demos/firebase-admob.module.ts b/apps/demo-angular/src/plugin-demos/firebase-admob.module.ts deleted file mode 100644 index c1add9b9..00000000 --- a/apps/demo-angular/src/plugin-demos/firebase-admob.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; -import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular'; -import { FirebaseAdmobComponent } from './firebase-admob.component'; - -@NgModule({ - imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: FirebaseAdmobComponent }])], - declarations: [FirebaseAdmobComponent], - schemas: [ NO_ERRORS_SCHEMA] -}) -export class FirebaseAdmobModule {} diff --git a/apps/demo-angular/tsconfig.json b/apps/demo-angular/tsconfig.json index c55bd108..6bcd3a50 100644 --- a/apps/demo-angular/tsconfig.json +++ b/apps/demo-angular/tsconfig.json @@ -9,8 +9,6 @@ "@nativescript/firebase-database": ["packages/firebase-database/index.d.ts"], "@nativescript/firebase-firestore": ["packages/firebase-firestore/index.d.ts"], "@nativescript/firebase-analytics": ["packages/firebase-analytics/index.d.ts"], - "@nativescript/firebase-admob": ["packages/firebase-admob/index.d.ts"], - "@nativescript/firebase-admob/angular": ["packages/firebase-admob/angular/index.ts"], "@nativescript/firebase-crashlytics": ["packages/firebase-crashlytics/index.d.ts"], "@nativescript/firebase-app-check": ["packages/firebase-app-check/index.d.ts"], "@nativescript/firebase-remote-config": ["packages/firebase-remote-config/index.d.ts"], diff --git a/apps/demo-vue/app/app.ts b/apps/demo-vue/app/app.ts index 5a4e594c..6371f772 100644 --- a/apps/demo-vue/app/app.ts +++ b/apps/demo-vue/app/app.ts @@ -21,8 +21,6 @@ import '@nativescript/firebase-performance'; import '@nativescript/firebase-remote-config'; import '@nativescript/firebase-storage'; -import { Admob } from '@nativescript/firebase-admob'; - import { AppCheck } from '@nativescript/firebase-app-check-debug'; import { Application } from '@nativescript/core'; @@ -35,8 +33,6 @@ firebase() firebase().crashlytics().setCrashlyticsCollectionEnabled(true); }); -Admob.init(); - const dynamicLinks = firebase().dynamicLinks(); dynamicLinks.onLink((link) => { diff --git a/apps/demo-vue/app/components/Home.vue b/apps/demo-vue/app/components/Home.vue index 4d68dea1..772d30bb 100644 --- a/apps/demo-vue/app/components/Home.vue +++ b/apps/demo-vue/app/components/Home.vue @@ -18,7 +18,6 @@ - - diff --git a/apps/demo-vue/package.json b/apps/demo-vue/package.json index c4208bba..75f8005f 100644 --- a/apps/demo-vue/package.json +++ b/apps/demo-vue/package.json @@ -3,7 +3,6 @@ "description": "NativeScript Application", "dependencies": { "@nativescript/core": "file:../../node_modules/@nativescript/core", - "@nativescript/firebase-admob": "file:../../packages/firebase-admob", "@nativescript/firebase-analytics": "file:../../dist/packages/firebase-analytics", "@nativescript/firebase-app-check": "file:../../packages/firebase-app-check", "@nativescript/firebase-auth": "file:../../packages/firebase-auth", diff --git a/apps/demo-vue/project.json b/apps/demo-vue/project.json index b39ca6a6..e3fcf6a5 100644 --- a/apps/demo-vue/project.json +++ b/apps/demo-vue/project.json @@ -11,33 +11,8 @@ "production": true, "uglify": true, "release": true, - "forDevice": true - }, - "dependsOn": [ - { - "target": "build.all", - "dependencies": true - } - ] - }, - "ios": { - "executor": "@nativescript/nx:build", - "options": { - "platform": "ios", - "noHmr": true - }, - "dependsOn": [ - { - "target": "build.all", - "dependencies": true - } - ] - }, - "android": { - "executor": "@nativescript/nx:build", - "options": { - "platform": "android", - "noHmr": true + "forDevice": true, + "tsConfig": "apps/demo-vue/tsconfig.json" }, "dependsOn": [ { @@ -47,13 +22,21 @@ ] }, "clean": { - "executor": "@nativescript/nx:build", - "options": { - "clean": true - } + "executor": "@nativescript/nx:clean", + "options": {} }, "lint": { "executor": "@nx/eslint:lint" + }, + "debug": { + "executor": "@nativescript/nx:debug", + "options": { + "noHmr": true, + "uglify": false, + "release": false, + "forDevice": false, + "prepare": false + } } } } diff --git a/apps/demo-vue/tsconfig.json b/apps/demo-vue/tsconfig.json index 5fffcfaf..e02a8e7a 100644 --- a/apps/demo-vue/tsconfig.json +++ b/apps/demo-vue/tsconfig.json @@ -11,8 +11,6 @@ "@nativescript/firebase-database": ["../../packages/firebase-database/index.d.ts"], "@nativescript/firebase-firestore": ["../../packages/firebase-firestore/index.d.ts"], "@nativescript/firebase-analytics": ["../../packages/firebase-analytics/index.d.ts"], - "@nativescript/firebase-admob": ["../../packages/firebase-admob/index.d.ts"], - "@nativescript/firebase-admob/angular": ["../../packages/firebase-admob/angular/index.ts"], "@nativescript/firebase-crashlytics": ["../../packages/firebase-crashlytics/index.d.ts"], "@nativescript/firebase-app-check": ["../../packages/firebase-app-check/index.d.ts"], "@nativescript/firebase-remote-config": ["../../packages/firebase-remote-config/index.d.ts"], diff --git a/apps/demo/package.json b/apps/demo/package.json index 961c6101..8c2e8dad 100644 --- a/apps/demo/package.json +++ b/apps/demo/package.json @@ -5,9 +5,9 @@ "repository": "", "dependencies": { "@nativescript/core": "file:../../node_modules/@nativescript/core", - "@nativescript/firebase-admob": "file:../../packages/firebase-admob", "@nativescript/firebase-analytics": "file:../../dist/packages/firebase-analytics", "@nativescript/firebase-app-check": "file:../../packages/firebase-app-check", + "@nativescript/firebase-app-check-debug": "file:../../packages/firebase-app-check-debug", "@nativescript/firebase-auth": "file:../../packages/firebase-auth", "@nativescript/firebase-core": "file:../../packages/firebase-core", "@nativescript/firebase-crashlytics": "file:../../packages/firebase-crashlytics", @@ -18,13 +18,12 @@ "@nativescript/firebase-in-app-messaging": "file:../../packages/firebase-in-app-messaging", "@nativescript/firebase-installations": "file:../../packages/firebase-installations", "@nativescript/firebase-messaging": "file:../../packages/firebase-messaging", + "@nativescript/firebase-messaging-core": "file:../../packages/firebase-messaging-core", "@nativescript/firebase-performance": "file:../../packages/firebase-performance", "@nativescript/firebase-remote-config": "file:../../packages/firebase-remote-config", "@nativescript/firebase-storage": "file:../../packages/firebase-storage", - "@nativescript/google-signin": "~2.1.0", - "@nativescript/firebase-app-check-debug": "file:../../packages/firebase-app-check-debug", - "@nativescript/firebase-messaging-core": "file:../../packages/firebase-messaging-core", - "@nativescript/firebase-ui": "file:../../packages/firebase-ui" + "@nativescript/firebase-ui": "file:../../packages/firebase-ui", + "@nativescript/google-signin": "~2.1.0" }, "devDependencies": { "@nativescript/android": "~8.8.0", diff --git a/apps/demo/project.json b/apps/demo/project.json index f8f4a97f..1c4650e4 100644 --- a/apps/demo/project.json +++ b/apps/demo/project.json @@ -12,33 +12,8 @@ "production": true, "uglify": true, "release": true, - "forDevice": true - }, - "dependsOn": [ - { - "target": "build.all", - "dependencies": true - } - ] - }, - "ios": { - "executor": "@nativescript/nx:build", - "options": { - "platform": "ios", - "noHmr": true - }, - "dependsOn": [ - { - "target": "build.all", - "dependencies": true - } - ] - }, - "android": { - "executor": "@nativescript/nx:build", - "options": { - "platform": "android", - "noHmr": true + "forDevice": true, + "tsConfig": "apps/demo/tsconfig.json" }, "dependsOn": [ { @@ -48,13 +23,21 @@ ] }, "clean": { - "executor": "@nativescript/nx:build", - "options": { - "clean": true - } + "executor": "@nativescript/nx:clean", + "options": {} }, "lint": { "executor": "@nx/eslint:lint" + }, + "debug": { + "executor": "@nativescript/nx:debug", + "options": { + "noHmr": true, + "uglify": false, + "release": false, + "forDevice": false, + "prepare": false + } } } } diff --git a/apps/demo/src/app.ts b/apps/demo/src/app.ts index 33a336b8..543aff3f 100644 --- a/apps/demo/src/app.ts +++ b/apps/demo/src/app.ts @@ -1,4 +1,5 @@ -import { Application, Utils } from '@nativescript/core'; +import { AndroidActivityNewIntentEventData, Application, Utils } from '@nativescript/core'; + import { firebase } from '@nativescript/firebase-core'; import '@nativescript/firebase-analytics'; import '@nativescript/firebase-auth'; @@ -15,8 +16,6 @@ import '@nativescript/firebase-remote-config'; import '@nativescript/firebase-storage'; import '@nativescript/firebase-ui'; -import { Admob } from '@nativescript/firebase-admob'; - import { AppCheck } from '@nativescript/firebase-app-check-debug'; AppCheck.setProviderFactory(); @@ -28,8 +27,6 @@ firebase() firebase().crashlytics().setCrashlyticsCollectionEnabled(true); }); -Admob.init(); - const dynamicLinks = firebase().dynamicLinks(); dynamicLinks.onLink((link) => { diff --git a/apps/demo/src/main-page.ts b/apps/demo/src/main-page.ts index 33d5bbf2..16d94bbc 100644 --- a/apps/demo/src/main-page.ts +++ b/apps/demo/src/main-page.ts @@ -1,12 +1,12 @@ import { EventData, Page } from '@nativescript/core'; import { firebase } from '@nativescript/firebase-core'; import { MainViewModel } from './main-view-model'; - +import { MessagingCore } from '@nativescript/firebase-messaging-core'; let didFire = false; export function navigatingTo(args: EventData) { const page = args.object; page.bindingContext = new MainViewModel(); - + /* if (global.isAndroid && !didFire) { firebase() .messaging() @@ -25,4 +25,22 @@ export function navigatingTo(args: EventData) { }); didFire = true; } + */ + + if (global.isAndroid && !didFire) { + MessagingCore.getInstance() + .requestPermission() + .then(() => { + console.log('requestPermission', 'done'); + MessagingCore.getInstance() + .registerDeviceForRemoteMessages() + .catch((e) => { + console.error('registerDeviceForRemoteMessages', e); + }); + }) + .catch((e) => { + console.error('requestPermission', e); + }); + didFire = true; + } } diff --git a/apps/demo/src/main-view-model.ts b/apps/demo/src/main-view-model.ts index d28ba3a1..13b7b070 100644 --- a/apps/demo/src/main-view-model.ts +++ b/apps/demo/src/main-view-model.ts @@ -2,9 +2,6 @@ import { Observable, Frame } from '@nativescript/core'; export class MainViewModel extends Observable { demos = [ - { - name: 'firebase-admob', - }, { name: 'firebase-analytics', }, diff --git a/apps/demo/src/plugin-demos/firebase-admob.ts b/apps/demo/src/plugin-demos/firebase-admob.ts deleted file mode 100644 index fe98f107..00000000 --- a/apps/demo/src/plugin-demos/firebase-admob.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { Observable, EventData, Page, View, Label } from '@nativescript/core'; -import { DemoSharedFirebaseAdmob } from '@demo/shared'; -import { AdChoicesPlacement, NativeAdEventType, AdEventType, InterstitialAd, RewardedInterstitialAd, RewardedAd, BannerAd, BannerAdSize, Admob, AdsConsent, NativeAd, NativeAdLoader, NativeAdView } from '@nativescript/firebase-admob'; - -export function navigatingTo(args: EventData) { - const page = args.object; - page.bindingContext = new DemoModel(); -} - -export class DemoModel extends DemoSharedFirebaseAdmob { - get bannerAdUnit() { - if (global.isAndroid) { - return 'ca-app-pub-3940256099942544/6300978111'; - } else { - return 'ca-app-pub-3940256099942544/2934735716'; - } - } - - constructor() { - super(); - //this.interstitial(); - //this.rewardedInterstitial(); - //this.rewarded(); - // ATTrackingManager.requestTrackingAuthorizationWithCompletionHandler((status) => { - // console.log('ATTrackingManager', status); - // }); - const testDevices = []; - if (global.isIOS) { - testDevices.push('b70c144077402b91cf8ecc5b93ac7791', 'EMULATOR'); - } else { - testDevices.push('EMULATOR'); - } - Admob.getInstance().requestConfiguration = { testDevices }; - } - - nativeAdLayoutChanged(event) { - const view = event.object; - const hlv = view.getViewById('headLineView') as Label; - const mv = view.getViewById('mediaView'); - const bv = view.getViewById('bodyView'); - const iv = view.getViewById('iconView'); - } - nativeAdLoaded(event) { - const view = event.object; - const loader = new NativeAdLoader('ca-app-pub-3940256099942544/3986624511', null, { - nativeAdOptions: { - adChoicesPlacement: AdChoicesPlacement.BOTTOM_LEFT, - }, - }); - loader.onAdEvent((event, error, data) => { - if (event === NativeAdEventType.LOADED) { - const ad = data as NativeAd; - const hlv = view.getViewById('headLineView') as Label; - hlv.text = ad.headline; - const mv = view.getViewById('mediaView'); - view.mediaView = mv; - mv.mediaContent = ad.mediaContent; - const bv = view.getViewById('bodyView'); - bv.text = ad.body; - const iv = view.getViewById('iconView'); - iv.src = ad.icon.image; - view.nativeAd = ad; - console.log('nativead loaded'); - } else if (event === 'adFailedToLoad') { - console.error('nativead failed to load', error); - } - }); - loader.load(); - } - - bannerLoaded(event) { - const bannerAd = event.object as BannerAd; - - bannerAd.on('adLoaded', (args) => { - console.log('bannerad loaded'); - }); - bannerAd.on('adFailedToLoad', (args) => { - console.log('bannerad failed to load', args.error); - }); - bannerAd.size = BannerAdSize.FULL_BANNER; - bannerAd.load(); - } - - interstitial() { - const ad = InterstitialAd.createForAdRequest('ca-app-pub-3940256099942544/4411468910'); - ad.onAdEvent((event, error, data) => { - if (event === AdEventType.LOADED) { - console.log('loaded'); - ad.show(); - } else if (event === AdEventType.FAILED_TO_LOAD_EVENT) { - console.error('loading error', error); - } - }); - ad.load(); - } - - rewardedInterstitial() { - const ad = RewardedInterstitialAd.createForAdRequest('ca-app-pub-3940256099942544/6978759866'); - ad.onAdEvent((event, error, data) => { - if (event === AdEventType.LOADED) { - console.log('loaded'); - ad.show(); - } else if (event === AdEventType.FAILED_TO_LOAD_EVENT) { - console.error('loading error', error); - } - }); - ad.load(); - } - - rewarded() { - const ad = RewardedAd.createForAdRequest('ca-app-pub-3940256099942544/1712485313'); - ad.onAdEvent((event, error, data) => { - if (event === AdEventType.LOADED) { - console.log('rewarded', 'loaded'); - ad.show(); - } else if (event === AdEventType.FAILED_TO_LOAD_EVENT) { - console.error('loading error', error); - } - }); - ad.load(); - } -} diff --git a/apps/demo/src/plugin-demos/firebase-admob.xml b/apps/demo/src/plugin-demos/firebase-admob.xml deleted file mode 100644 index 78fde495..00000000 --- a/apps/demo/src/plugin-demos/firebase-admob.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/apps/demo/tsconfig.json b/apps/demo/tsconfig.json index 04555be8..154dc74f 100644 --- a/apps/demo/tsconfig.json +++ b/apps/demo/tsconfig.json @@ -11,8 +11,6 @@ "@nativescript/firebase-database": ["../../packages/firebase-database/index.d.ts"], "@nativescript/firebase-firestore": ["../../packages/firebase-firestore/index.d.ts"], "@nativescript/firebase-analytics": ["../../packages/firebase-analytics/index.d.ts"], - "@nativescript/firebase-admob": ["../../packages/firebase-admob/index.d.ts"], - "@nativescript/firebase-admob/angular": ["../../packages/firebase-admob/angular/index.ts"], "@nativescript/firebase-crashlytics": ["../../packages/firebase-crashlytics/index.d.ts"], "@nativescript/firebase-app-check": ["../../packages/firebase-app-check/index.d.ts"], "@nativescript/firebase-remote-config": ["../../packages/firebase-remote-config/index.d.ts"], diff --git a/migrations.json b/migrations.json index b38e8f1b..a5031b2f 100644 --- a/migrations.json +++ b/migrations.json @@ -1,7 +1 @@ -{ - "migrations": [ - { "cli": "nx", "version": "5.2.0", "description": "Migrate tools to 5.2.0", "implementation": "./src/migrations/update-5-2-0/update-5-2-0", "package": "@nativescript/plugin-tools", "name": "update-to-5.2.0" }, - { "cli": "nx", "version": "5.3.0", "description": "Migrate tools to 5.3.0", "implementation": "./src/migrations/update-5-3-0/update-5-3-0", "package": "@nativescript/plugin-tools", "name": "update-to-5.3.0" }, - { "cli": "nx", "version": "5.4.0", "description": "Migrate tools to 5.4.0", "implementation": "./src/migrations/update-5-4-0/update-5-4-0", "package": "@nativescript/plugin-tools", "name": "update-to-5.4.0" } - ] -} +{ "migrations": [{ "cli": "nx", "version": "5.5.0", "description": "Migrate tools to 5.5.0", "implementation": "./src/migrations/update-5-5-0/update-5-5-0", "package": "@nativescript/plugin-tools", "name": "update-to-5.5.0" }] } diff --git a/nx.json b/nx.json index 4e56d29d..8902bfa8 100644 --- a/nx.json +++ b/nx.json @@ -32,5 +32,21 @@ "useDaemonProcess": false, "parallel": 1, "useInferencePlugins": false, - "defaultBase": "master" + "defaultBase": "master", + "release": { + "releaseTagPattern": "{version}-{projectName}", + "projects": ["packages/*"], + "projectsRelationship": "independent", + "changelog": { + "workspaceChangelog": false, + "projectChangelogs": { + "renderOptions": { + "authors": true, + "commitReferences": true, + "versionTitleDate": true + } + } + } + }, + "useLegacyCache": true } diff --git a/package.json b/package.json index 993358f8..4dd9168c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plugins", - "version": "3.4.0-alpha.1", + "version": "4.0.0", "license": "MIT", "scripts": { "postinstall": "husky && npx ts-patch install", @@ -17,36 +17,41 @@ }, "private": true, "devDependencies": { - "@angular-devkit/build-angular": "^18.0.0", - "@angular/animations": "^18.0.0", - "@angular/common": "^18.0.0", - "@angular/compiler": "^18.0.0", - "@angular/compiler-cli": "^18.0.0", - "@angular/core": "^18.0.0", - "@angular/forms": "^18.0.0", - "@angular/platform-browser": "^18.0.0", - "@angular/platform-browser-dynamic": "^18.0.0", - "@angular/router": "^18.0.0", - "@nativescript/angular": "^18.0.0", + "@angular-devkit/build-angular": "^19.0.0", + "@angular/animations": "^19.0.0", + "@angular/common": "^19.0.0", + "@angular/compiler": "^19.0.0", + "@angular/compiler-cli": "^19.0.0", + "@angular/core": "^19.0.0", + "@angular/forms": "^19.0.0", + "@angular/platform-browser": "^19.0.0", + "@angular/platform-browser-dynamic": "^19.0.0", + "@angular/router": "^19.0.0", + "@nativescript/angular": "^19.0.0", "@nativescript/core": "~8.8.0", - "@nativescript/plugin-tools": "5.4.1", + "@nativescript/plugin-tools": "5.5.1", "@nativescript/types": "~8.8.0", "@nativescript/webpack": "~5.0.5", - "@ngtools/webpack": "^18.0.0", + "@ngtools/webpack": "^19.0.0", + "@typescript-eslint/eslint-plugin": "^8.13.0", + "@typescript-eslint/parser": "^8.13.0", + "@typescript-eslint/utils": "^8.13.0", "conventional-changelog-cli": "^2.2.2", "husky": "~9.0.0", "nativescript-vue": "~2.9.0", "nativescript-vue-template-compiler": "~2.9.0", - "ng-packagr": "^18.0.0", + "ng-packagr": "^19.0.0", "rxjs": "~7.8.0", "stacktrace-js": "~2.0.2", - "typescript": "~5.5.0", + "typescript": "~5.6.0", "vue": "~2.6.12", - "zone.js": "~0.14.0" + "zone.js": "~0.15.0" }, "lint-staged": { "**/*.{js,ts,scss,json,html}": [ "npx prettier --write" ] - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e", + "dependencies": {} } diff --git a/packages/firebase-admob/.eslintrc.json b/packages/firebase-admob/.eslintrc.json deleted file mode 100644 index be41074b..00000000 --- a/packages/firebase-admob/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*", "node_modules/**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/packages/firebase-admob/README.md b/packages/firebase-admob/README.md deleted file mode 100644 index c691411b..00000000 --- a/packages/firebase-admob/README.md +++ /dev/null @@ -1,725 +0,0 @@ -# @nativescript/firebase-admob - -A plugin that allows you to monetize your NativeScript app by integrating the [Google Mobile Ads SDK](https://developers.google.com/admob/android/sdk) into the app. - -> **Note:** Before you use this plugin, if you haven't already, setup your app for Firebase by following the instructions at [@nativescript/firebase-core](../firebase-core/). - -The `@nativescript/firebase-admob` plugin currently supports loading and displaying the following ad types: - -- [Banner](#banner-ads) -- [Interstitial (full-screen)](#interstitial-ad) -- [Native](#native-ads) -- [Rewarded](#rewarded-ads) - -## Contents - -- [Installation](#installation) -- [Setup Admob for iOS](#setup-admob-for-ios) -- [Setup Admob for Android](#setup-admob-for-android) -- [Use @nativescript/firebase-admob](#use-nativescriptfirebase-admob) - - [Initialize the Mobile Ads SDK](#1-initialize-the-mobile-ads-sdk) - - [Add your preferred ad format to the app](#2-add-your-preferred-ad-format-to-the-app) - - [Banner ads](#banner-ads) - - [Testing Banner ads in development mode](#testing-banner-ads-in-development-mode) - - [Instantiate a Banner ad](#instantiate-a-banner-ad) - - [Add Banner ad in NativeScript Core](#add-banner-ad-in-nativescript-core) - - [Add Banner ad in NativeScript Angular](#add-banner-ad-in-nativescript-angular) - - [Add Banner ad in NativeScript Vue](#add-banner-ad-in-nativescript-vue) - - [Customize the banner ad size](#customize-the-banner-ad-size) - - [Listen to a banner ad lifecycle events](#listen-to-a-banner-ad-lifecycle-events) - - [Display a banner ad to the user](#display-a-banner-ad-to-the-user) - - [Add an Interstitial ad](#add-an-interstitial-ad) - - [Testing Interstitial ads in development](#testing-an-interstitial-ads-in-development) - - [Display an Interstitial ad to the user](#display-an-interstitial-ad-to-the-user) - - [Next steps](#next-steps) - - [Native ads](#native-ads) - - [Add a Native ad to your app](#add-a-native-ad-to-your-app) - - [Adding a Native ad in NativeScript Core](#adding-a-native-ad-in-nativescript-core) - - [Testing Native ads in development mode](#testing-native-ads-in-development-mode) - - [NativeAdOptions interface](#nativeadoptions-interface) - - [Next steps](#next-steps-1) - - [Rewarded Ads](#rewarded-ads) - - [Testing Rewarded ads in development mode](#testing-rewarded-ads-in-development-mode) - - [Display a Rewarded ad](#display-a-rewarded-ad) - - [Rewarded ad Events](#rewarded-ad-events) - - [Targeting](#targeting) - - [Child-directed setting](#child-directed-setting) - - [For users under the age of consent](#for-users-under-the-age-of-consent) - - [Ad content filtering](#ad-content-filtering) - - - -## Installation - -To install `@nativescript/firebase-admob`, run the following command in the root directory of the project: - -```cli -npm install @nativescript/firebase-admob -``` - -## Setup Admob for iOS - -Update your `Info.plist` file at `App_Resources/iOS` with a `GADApplicationIdentifier` key with a string value of your AdMob app ID ([identified in the AdMob UI](https://support.google.com/admob/answer/7356431)). - -```xml -GADApplicationIdentifier -ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy -``` - -For more information about configuring the `Info.plist` and setting up your App ID, see [Update your Info.plist](https://developers.google.com/admob/ios/quick-start#update%5C_your%5C_infoplist). - -## Setup Admob for Android - -Add AdMob App ID ([identified in the AdMob UI](https://support.google.com/admob/answer/7356431)) to the app's `AndroidManifest.xml` file, found at `App_Resources/Android/src/main`. Failure to do so will result in a crash on app launch. Add the ID by adding a `` tag with name `com.google.android.gms.ads.APPLICATION_ID`, as shown below. For `android:value` insert your own AdMob App ID in quotes. - -```xml - - - - -``` - -See step 3. of [Configure your app](https://developers.google.com/admob/android/quick-start#import_the_mobile_ads_sdk) for more information about configuring AndroidManifest.xml and setting up the App ID. - -## Use @nativescript/firebase-admob - -To use the `@nativescript/firebase-admob` plugin, follow the steps below: - -### 1. Initialize the Mobile Ads SDK - -Before loading ads, initialize the Mobile Ads SDK by calling the static [init](#init) method on the Admob class. Call this method once, ideally right before the app boots, in the `main.ts` file. - -```ts -import { Admob } from '@nativescript/firebase-admob'; - -Admob.init(); -``` - -### 2. Add your preferred ad format to the app - -The Mobile Ads SDK is now imported and you're ready to implement an ad. Click any of the links below to get detailed implementation steps for your desired ad format. - -- [Banner](#add-a-banner-ad) -- [Interstitial (full-screen)](#interstitial-ad) -- [Native](#native-ads) -- [Rewarded](#rewarded-ads) - -### Banner ads - -Banner ads are rectangular ads that appear at the top or bottom of the device screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period. If you're new to mobile advertising, they're a great place to start. - -#### Testing Banner ads in development mode - -> **Note:** When developing your app, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account. Make sure you replace the test unit ID with your ad unit ID before publishing your app. - -To enable dedicated test ad unit ID for banners, visit the links below: - -- [Android demo units](https://developers.google.com/admob/android/test-ads#demo_ad_units) -- [iOS demo units](https://developers.google.com/admob/ios/test-ads#demo_ad_units) - -Below are examples of adding a Banner ad in several NativeScript flavors. - -#### Add Banner ad in NativeScript Core - -Register the plugin namespace in the Page element under a prefix(`ui` for example), access the `BannerAd` view from the namespace via the prefix and add it to your XML. - -The `BannerAd` requires the following attributes to be set: - -- `unitId` -- `BannerAdSize`: You can set this value in the callback function of the `layoutChanged` event. For more information, see [Customize the banner ad size](#customize-the-banner-ad-size) -- `height` and `width` - - - -```xml - - - - - - -``` - -```js -import { BannerAdSize } from '@nativescript/firebase-admob'; - -export function loadBanner(args) { - const banner = args.object; - banner.size = new BannerAdSize(100, 100); - banner.load(); -} -``` - -#### Add Banner ad in NativeScript Angular - -Register the `BannerAd` view by adding its `AdmobModule` to the `imports` array of the `@NgModule` decorator of the component where you want to use the view. - -```ts -import { AdmobModule } from '@nativescript/firebase-admob/angular'; - -@NgModule({ - imports: [ - AdmobModule - ], - declarations: [ - AppComponent - ], - bootstrap: [AppComponent] -}) -``` - -Next, add the `BannerAd` view to HTML. The `BannerAd` requires the following attributes to be set: - -- `unitId` -- `BannerAdSize`: You can set this value in the callback function of the `layoutChanged` event. For more information, see [Customize the banner ad size](#customize-the-banner-ad-size) -- `height` and `width` - -```html - -``` - -#### Add Banner ad in NativeScript Vue - -Register the `BannerAd` view in the `app.ts` file as follows: - -```ts -import { createApp } from 'nativescript-vue'; -import Admob from '@nativescript/firebase-admob/vue'; -import Home from './components/Home.vue'; - -const app = createApp(Home); -app.use(Admob); -``` - -And then add it to markup as follows. The `BannerAd` requires the following attributes to be set: - -- `unitId` -- `BannerAdSize`: You can set this value in the callback function of the `layoutChanged` event. For more information, see [Customize the banner ad size](#customize-the-banner-ad-size) -- `height` and `width` - -```xml - -``` - -#### Customize the banner ad size - -To define a custom banner size, you have 2 options: - -- Instantiate the `BannerAdSize` class with the desired width and height and set it to the `size` attribute of `BannerAd`. - -```ts -import { BannerAdSize } from '@nativescript/firebase-admob'; - -banner.size = new BannerAdSize(300, 50); -``` - -- Set the `size` to any of the constants of the `BannerAdSize` class. - -The table below lists the available constants and the sizes they represent. - -| AdSize Constant | Size in dp (WxH) | Description | -| :------------------------------------------------- | :------------------------------- | :--------------- | -| `BANNER` | `320x50` | Standard Banner | -| `LARGE_BANNER` | `320x100` | Large Banner | -| `MEDIUM_RECTANGLE` | `320x250` | Medium Rectangle | -| `FULL_BANNER` | `468x60` | Full-Size Banner | -| `LEADERBOARD` | `728x90` | Leaderboard | -| `createAnchoredAdaptiveBanner(width, orientation)` | Provided width x Adaptive height | Adaptive Banner | -| `createInLineAdaptiveBanner(width, orientation)` | Provided width x Adaptive height | Adaptive Banner | - -#### Listen to a banner ad lifecycle events - -The plugin enables you to listen to different lifecycle events of an ad, such as when an ad is loaded. Register the events handlers before calling the `load` method. - -```ts -const bannerView = event.object; - -// Called when an ad is successfully received. -bannerView.on('adLoaded', (args) => { - console.log('Ad loaded.'); -}); - -// Called when an ad request failed. -bannerView.on('adFailedToLoad', (args) => { - console.log('Ad failed to load: ', args.error); -}); - -// Called when the user removes an overlay that covers the screen. -bannerView.on('adClosed', (args) => { - console.log('Ad closed.'); -}); - -// Called when an impression occurs on the ad. -bannerView.on('adImpression', (args) => { - console.log('Ad impression.'); -}); - -// Called when an tap/touch/click occurs on the ad. -bannerView.on('adClicked', (args) => { - console.log('Ad tapped'); -}); -``` - -### Display a banner ad to the user - -To display a banner ad to the user, get the reference to the `BannerAd` view and call the `load` method on it. - -```ts -bannerView.load(); -``` - -### Add an Interstitial ad - -Interstitial ads are full-screen ads that cover the interface of an app until closed by the user. They're best used at natural pauses in the flow of an app's execution, such as between levels of a game or just after a task is completed. - -#### Testing Interstitial ads in development - -> **Note:** When your app is in development mode, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account. Make sure you replace the test unit ID with your ad unit ID before publishing your app. -> To enable dedicated test ad unit ID, visit the links below: - -- [Android demo units](https://developers.google.com/admob/android/test-ads#demo_ad_units) -- [iOS demo units](https://developers.google.com/admob/ios/test-ads#demo_ad_units) - -### Display an Interstitial ad to the user - -To display an Interstitial ad to the user, follow the steps below: - -1. Import the `InterstitialAd` class from `@nativescript/firebase-admob`. - -```ts -import { InterstitialAd } from '@nativescript/firebase-admob'; -``` - -2. Create an Interstitial ad instance. - -Create an Interstitial ad instance by calling the static `createForAdRequest` on the class. The `createForAdRequest` method requires an adUnitId and you can optionally pass a [RequestOptions]() object. - -```ts -import { InterstitialAd } from '@nativescript/firebase-admob'; -const ad = InterstitialAd.createForAdRequest('ca-app-pub-xxxxxxxxxxxxxxxx/yyyyyyyyyy'); -``` - -3. Listen to the ad lifecycle events - -To listen for the ad lifecycle events, such as when the ad is display or dismissed, call the `onAdEvent` method on the ad instance, before displaying the ad, passing it a callback function to handle the events. - -```ts -import { InterstitialAd } from '@nativescript/firebase-admob'; - -const ad = InterstitialAd.createForAdRequest('ca-app-pub-xxxxxxxxxxxxxxxx/yyyyyyyyyy'); - -ad.onAdEvent((event, error, data) => { - switch (event) { - case AdEventType.LOADED: - break; - case AdEventType.CLOSED: - break; - case AdEventType.OPENED: - break; - case AdEventType.IMPRESSION: - break; - case AdEventType.FAILED_TO_SHOW_FULL_SCREEN_CONTENT: - break; - } -}); -``` - -4. Load the ad - You load the ad by calling the `load` method on the ad instance. - -```ts -import { InterstitialAd } from '@nativescript/firebase-admob'; - -const ad = InterstitialAd.createForAdRequest('ca-app-pub-xxxxxxxxxxxxxxxx/yyyyyyyyyy'); - -ad.onAdEvent((event, error, data) => { - switch (event) { - case AdEventType.LOADED: - break; - case AdEventType.CLOSED: - break; - case AdEventType.OPENED: - break; - case AdEventType.IMPRESSION: - break; - case AdEventType.FAILED_TO_SHOW_FULL_SCREEN_CONTENT: - break; - } -}); - -ad.load(); -``` - -5. Display the the ad - -To display the ad, call the `show` method on the ad instance. This method is called after the `load` method. - -```ts -import { InterstitialAd } from '@nativescript/firebase-admob'; - -const ad = InterstitialAd.createForAdRequest('ca-app-pub-xxxxxxxxxxxxxxxx/yyyyyyyyyy'); - -ad.onAdEvent((event, error, data) => { - switch (event) { - case AdEventType.LOADED: - break; - case AdEventType.CLOSED: - ad.show(); - break; - case AdEventType.OPENED: - break; - case AdEventType.IMPRESSION: - break; - case AdEventType.FAILED_TO_SHOW_FULL_SCREEN_CONTENT: - break; - } -}); - -ad.load(); -``` - -#### Next steps - -- See [Interstitial best practices](https://www.youtube.com/watch?v=r2RgFD3Apyo&index=5&list=PLOU2XLYxmsIKX0pUJV3uqp6N3NeHwHh0c) and [interstitial ad guidance](https://support.google.com/admob/answer/6066980). -- Check out an [Interstitial ads case study](https://admob.google.com/home/resources/freaking-math-powers-revenue-increase-with-google-admob-support/). -- If you haven't already, create your own interstitial ad unit in the [AdMob UI](https://apps.admob.com/). - -## Native Ads - -Native ads are ad assets that are presented to users via UI components that are native to the platform. They're shown using the same types of views with which you're already building your layouts, and can be formatted to match the visual design of the user experience in which they live. In coding terms, this means that when a native ad loads, your app receives a NativeAd object that contains its assets, and the app (rather than the Google Mobile Ads SDK) is then responsible for displaying them. - -### Adding a Native ad in NativeScript Core - -To add a Native ad to your {N} Core app, follow these steps: - -1. Register the plugin namespace under a prefix, `ui` (this can be any name), with the Page element. - -```xml - -``` - -2. Use the prefix to access the `NativeAdView` and add it to markup. - -```xml - - - - - - -``` - -### Testing Native ads in development mode - -> **Note:** When developing your app, make sure you use test ad unit IDs rather than live, production ads. Failure to do so can lead to suspension of your account. Just make sure you replace the test ad unit ID with your own ad unit ID before publishing your app. - -To enable dedicated test ad unit ID, visit the links below: - -- [Android demo units](https://developers.google.com/admob/android/test-ads#demo_ad_units) -- [iOS demo units](https://developers.google.com/admob/ios/test-ads#demo_ad_units) - -3. Import the `NativeAdLoader` class from `@nativescript/firebase-admob` in the view model file. - -```ts -import { NativeAdLoader } from '@nativescript/firebase-admob'; -``` - -The `NativeAdLoader` class is an interface for managing the the Native ad. - -4. Instantiate `NativeAdLoader`. - Create an instance of `NativeAdLoader` by calling its constructor function. The constructor function accepts 3 parameters. The required adUnitId as the first parameter, optional RequestOptions and NativeAdOptions objects as the second and third parameter, respectively. - -```ts -const loader = new NativeAdLoader('ca-app-pub-xxxxxxxxxxxxxxxx/yyyyyyyyyy', null, { - nativeAdOptions: { - adChoicesPlacement: AdChoicesPlacement.TOP_RIGHT, - }, -}); -``` - -5. Listen to the Native ad lifecycle events - -To listen to the Native ad [lifecycle events](), call the `onAdEvent` method on the `NativeAdLoader` instance when the `NativeAdView` has loaded. - -```xml - - -