@octane-xplat/ads 0.0.0-nightly.gaffaece
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/package.json +96 -0
- package/src/BannerAd.tsrx +52 -0
- package/src/BannerAd.web.tsrx +12 -0
- package/src/ads.linux.ts +1 -0
- package/src/ads.macos.ts +1 -0
- package/src/ads.ts +59 -0
- package/src/ads.web.ts +14 -0
- package/src/ads.windows.ts +1 -0
- package/src/index.macos.ts +4 -0
- package/src/index.ts +4 -0
- package/src/index.web.ts +4 -0
- package/src/index.windows.ts +4 -0
- package/src/native-elements.d.ts +8 -0
- package/src/props.ts +16 -0
- package/src/types.ts +47 -0
- package/types/generated/.tsrx-typegen-manifest.json +19 -0
- package/types/generated/BannerAd.d.ts +3 -0
- package/types/generated/BannerAd.web.d.ts +2 -0
- package/types/generated/ads.d.ts +2 -0
- package/types/generated/ads.linux.d.ts +1 -0
- package/types/generated/ads.macos.d.ts +1 -0
- package/types/generated/ads.web.d.ts +2 -0
- package/types/generated/ads.windows.d.ts +1 -0
- package/types/generated/index.d.ts +4 -0
- package/types/generated/index.macos.d.ts +4 -0
- package/types/generated/index.web.d.ts +4 -0
- package/types/generated/index.windows.d.ts +4 -0
- package/types/generated/native-elements.d.ts +8 -0
- package/types/generated/props.d.ts +15 -0
- package/types/generated/types.d.ts +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alec Larson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# `@octane-xplat/ads`
|
|
2
|
+
|
|
3
|
+
```sh
|
|
4
|
+
pnpm add @octane-xplat/ads
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Google AdMob — `<BannerAd>` plus interstitial, rewarded, and
|
|
8
|
+
rewarded-interstitial formats through `@nativescript/google-mobile-ads`.
|
|
9
|
+
Mirrors `react-native-google-mobile-ads` naming (Expo's ads packages are
|
|
10
|
+
deprecated). Consent (UMP/ATT) stays in the permissions seam.
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { ads, BannerAd } from '@octane-xplat/ads'
|
|
14
|
+
|
|
15
|
+
await ads.initialize()
|
|
16
|
+
|
|
17
|
+
<BannerAd adUnitId="ca-app-pub-3940256099942544/6300978111" size="anchoredAdaptive" />
|
|
18
|
+
|
|
19
|
+
const rewarded = ads.createRewardedAd('ca-app-pub-3940256099942544/5224354917')
|
|
20
|
+
rewarded.onAdEvent((e) => e.type === 'earned_reward' && grant(e.reward))
|
|
21
|
+
rewarded.load(); rewarded.show()
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Web/desktop report `supported: false` (AdSense is a different product).
|
|
25
|
+
`createAppOpenAd` throws — upstream ships no AppOpenAd wrapper.
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octane-xplat/ads",
|
|
3
|
+
"version": "0.0.0-nightly.gaffaece",
|
|
4
|
+
"description": "Google AdMob ads for Octane xplat — banner, interstitial, rewarded, app-open via @nativescript/google-mobile-ads",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"android",
|
|
7
|
+
"cross-platform",
|
|
8
|
+
"nativescript",
|
|
9
|
+
"octane",
|
|
10
|
+
"xplat",
|
|
11
|
+
"ads",
|
|
12
|
+
"admob",
|
|
13
|
+
"monetization"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/ads",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/octane-xplat/octane-xplat",
|
|
20
|
+
"directory": "packages/ads"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"platforms",
|
|
25
|
+
"types",
|
|
26
|
+
"!src/**/*.test.*",
|
|
27
|
+
"!src/**/*.spec.*"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"macos": {
|
|
33
|
+
"types": "./types/generated/index.macos.d.ts",
|
|
34
|
+
"default": "./src/index.macos.ts"
|
|
35
|
+
},
|
|
36
|
+
"web": {
|
|
37
|
+
"types": "./types/generated/index.web.d.ts",
|
|
38
|
+
"default": "./src/index.web.ts"
|
|
39
|
+
},
|
|
40
|
+
"native": {
|
|
41
|
+
"types": "./types/generated/index.d.ts",
|
|
42
|
+
"default": "./src/index.ts"
|
|
43
|
+
},
|
|
44
|
+
"types": "./types/generated/index.d.ts",
|
|
45
|
+
"default": "./src/index.ts"
|
|
46
|
+
},
|
|
47
|
+
"./*": {
|
|
48
|
+
"types": "./types/generated/*.d.ts",
|
|
49
|
+
"default": "./src/*"
|
|
50
|
+
},
|
|
51
|
+
"./*.ts": {
|
|
52
|
+
"types": "./types/generated/*.d.ts",
|
|
53
|
+
"default": "./src/*.ts"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@nativescript-community/octane": "0.2.5",
|
|
61
|
+
"@nativescript/core": "9.1.3",
|
|
62
|
+
"@nativescript/types": "9.1.4",
|
|
63
|
+
"@tsrx/typescript-plugin": "0.4.11",
|
|
64
|
+
"octane": "0.14.0",
|
|
65
|
+
"tsrx-typegen": "0.4.0",
|
|
66
|
+
"typescript": "5.9.3"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@nativescript-community/octane": ">=0.2.1 <1",
|
|
70
|
+
"@nativescript/core": ">=9.1.0 <10",
|
|
71
|
+
"octane": ">=0.6.3 <1"
|
|
72
|
+
},
|
|
73
|
+
"peerDependenciesMeta": {
|
|
74
|
+
"@nativescript-community/octane": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"@nativescript/core": {
|
|
78
|
+
"optional": true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"nativescript": {
|
|
82
|
+
"platforms": {
|
|
83
|
+
"android": "9.1.0",
|
|
84
|
+
"ios": "9.1.0"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@nativescript/google-mobile-ads": "5.0.4",
|
|
89
|
+
"@octane-xplat/platform": "0.0.0-nightly.gaffaece"
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"typegen": "tsrx-typegen --target octane",
|
|
93
|
+
"pack:check": "tsrx-typegen --pack-check",
|
|
94
|
+
"typecheck": "node ../../scripts/typecheck.ts"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
2
|
+
import { useEffect, useCallback, useRef } from 'octane'
|
|
3
|
+
import { isAndroid } from '@nativescript/core'
|
|
4
|
+
import { registerElement } from '@nativescript-community/octane'
|
|
5
|
+
import { BannerAd as NativeBannerAd, BannerAdSize } from '@nativescript/google-mobile-ads'
|
|
6
|
+
import type { BannerAdProps } from './props'
|
|
7
|
+
|
|
8
|
+
registerElement('xplatbannerad', NativeBannerAd)
|
|
9
|
+
|
|
10
|
+
const SIZES: Record<string, any> = {
|
|
11
|
+
banner: () => (BannerAdSize as any).BANNER,
|
|
12
|
+
largeBanner: () => (BannerAdSize as any).LARGE_BANNER,
|
|
13
|
+
mediumRectangle: () => (BannerAdSize as any).MEDIUM_RECTANGLE,
|
|
14
|
+
fullBanner: () => (BannerAdSize as any).FULL_BANNER,
|
|
15
|
+
leaderboard: () => (BannerAdSize as any).LEADERBOARD,
|
|
16
|
+
adaptiveBanner: () => (BannerAdSize as any).getCurrentOrientationAnchoredAdaptiveBannerAdSize?.(),
|
|
17
|
+
anchoredAdaptive: () => (BannerAdSize as any).getCurrentOrientationAnchoredAdaptiveBannerAdSize?.(),
|
|
18
|
+
fluid: () => (BannerAdSize as any).FLUID,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** AdMob banner — the plugin view owns its own load() on mount. */
|
|
22
|
+
export function BannerAd(props: BannerAdProps) @{
|
|
23
|
+
const host = useRef<any>(null)
|
|
24
|
+
const bindHost = useCallback((v: any) => {
|
|
25
|
+
host.current = v
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const v = host.current
|
|
30
|
+
if (!v) {
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
if (props.onAdEvent) {
|
|
34
|
+
v.onAdEvent((type: any, error?: any, data?: any) =>
|
|
35
|
+
props.onAdEvent?.({ type: String(type) as any, error, reward: data }),
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
const bag = isAndroid ? props.android : props.ios
|
|
39
|
+
if (bag) {
|
|
40
|
+
Object.assign(v, bag)
|
|
41
|
+
}
|
|
42
|
+
}, [])
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const v = host.current
|
|
46
|
+
if (v && props.size) {
|
|
47
|
+
v.size = SIZES[props.size]?.() ?? (BannerAdSize as any).BANNER
|
|
48
|
+
}
|
|
49
|
+
}, [props.size])
|
|
50
|
+
|
|
51
|
+
<xplatbannerad ref={bindHost} unitId={props.adUnitId} style={props.style} className={props.className} />
|
|
52
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Banner ad — web leaf. AdMob has no web product (AdSense is a different
|
|
2
|
+
// integration); renders nothing and reports once via onAdEvent error.
|
|
3
|
+
import { useEffect } from 'octane'
|
|
4
|
+
import type { BannerAdProps } from './props'
|
|
5
|
+
|
|
6
|
+
export function BannerAd(props: BannerAdProps) @{
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
props.onAdEvent?.({ type: 'error', error: new Error('unsupported: AdMob is not available on web') })
|
|
9
|
+
}, [])
|
|
10
|
+
|
|
11
|
+
<div style={props.style} className={props.className} />
|
|
12
|
+
}
|
package/src/ads.linux.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ads } from './ads.web'
|
package/src/ads.macos.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ads } from './ads.web'
|
package/src/ads.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Ads — native leaf over @nativescript/google-mobile-ads. Banner lives in
|
|
2
|
+
// BannerAd.tsrx (a view); this service owns SDK init + fullscreen formats.
|
|
3
|
+
import { InterstitialAd, MobileAds, RewardedAd, RewardedInterstitialAd } from '@nativescript/google-mobile-ads'
|
|
4
|
+
import type { AdEventListener, Ads, LoadedAd } from './types'
|
|
5
|
+
|
|
6
|
+
const EVENT: Record<string, string> = {
|
|
7
|
+
loaded: 'loaded',
|
|
8
|
+
failed_to_load: 'failed_to_load',
|
|
9
|
+
load_failed: 'failed_to_load',
|
|
10
|
+
opened: 'opened',
|
|
11
|
+
closed: 'closed',
|
|
12
|
+
clicked: 'clicked',
|
|
13
|
+
impression: 'impression',
|
|
14
|
+
earned_reward: 'earned_reward',
|
|
15
|
+
error: 'error',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function wrap<T extends { adUnitId: string; loaded: boolean; load(): void; onAdEvent(l: any): void; show(o?: any): void }>(
|
|
19
|
+
ad: T,
|
|
20
|
+
): LoadedAd {
|
|
21
|
+
return {
|
|
22
|
+
adUnitId: ad.adUnitId,
|
|
23
|
+
get loaded() {
|
|
24
|
+
return ad.loaded
|
|
25
|
+
},
|
|
26
|
+
load: () => ad.load(),
|
|
27
|
+
onAdEvent: (listener: AdEventListener) =>
|
|
28
|
+
ad.onAdEvent((type: any, error?: any, data?: any) =>
|
|
29
|
+
listener({
|
|
30
|
+
type: (EVENT[String(type)] ?? String(type)) as any,
|
|
31
|
+
error: error instanceof Error ? error : error ? new Error(String(error)) : undefined,
|
|
32
|
+
reward: data ? { amount: data.amount ?? 0, type: data.type ?? '' } : undefined,
|
|
33
|
+
}),
|
|
34
|
+
),
|
|
35
|
+
show: (options) => ad.show(options),
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const ads: Ads = {
|
|
40
|
+
supported: true,
|
|
41
|
+
|
|
42
|
+
async initialize(): Promise<void> {
|
|
43
|
+
// The plugin's method is spelled `initalize` upstream — try both.
|
|
44
|
+
const m = MobileAds as any
|
|
45
|
+
await (m.initalize?.() ?? m.initialize?.())
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
createInterstitial: (adUnitId, requestOptions) =>
|
|
49
|
+
wrap(InterstitialAd.createForAdRequest(adUnitId, requestOptions as any)),
|
|
50
|
+
createRewardedAd: (adUnitId, requestOptions) =>
|
|
51
|
+
wrap(RewardedAd.createForAdRequest(adUnitId, requestOptions as any)),
|
|
52
|
+
createRewardedInterstitialAd: (adUnitId, requestOptions) =>
|
|
53
|
+
wrap(RewardedInterstitialAd.createForAdRequest(adUnitId, requestOptions as any)),
|
|
54
|
+
// Upstream ships no AppOpenAd wrapper — the format is a documented gap,
|
|
55
|
+
// not silently aliased to interstitial.
|
|
56
|
+
createAppOpenAd: () => {
|
|
57
|
+
throw new Error('unsupported: @nativescript/google-mobile-ads has no AppOpenAd')
|
|
58
|
+
},
|
|
59
|
+
}
|
package/src/ads.web.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Ads — web leaf. AdMob is native-only (AdSense is a different product);
|
|
2
|
+
// supported: false rather than fake parity.
|
|
3
|
+
import type { Ads } from './types'
|
|
4
|
+
|
|
5
|
+
const unsupported = () => { throw new Error('unsupported: AdMob is not available on web') }
|
|
6
|
+
|
|
7
|
+
export const ads: Ads = {
|
|
8
|
+
supported: false,
|
|
9
|
+
initialize: async () => {},
|
|
10
|
+
createInterstitial: unsupported,
|
|
11
|
+
createRewardedAd: unsupported,
|
|
12
|
+
createRewardedInterstitialAd: unsupported,
|
|
13
|
+
createAppOpenAd: unsupported,
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ads } from './ads.web'
|
package/src/index.ts
ADDED
package/src/index.web.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BannerAd } from '@nativescript/google-mobile-ads'
|
|
2
|
+
import type { Attributes } from '@nativescript-community/octane/intrinsics'
|
|
3
|
+
|
|
4
|
+
declare module '@nativescript-community/octane/intrinsics' {
|
|
5
|
+
interface NativeScriptElements {
|
|
6
|
+
xplatbannerad: Attributes<typeof BannerAd>
|
|
7
|
+
}
|
|
8
|
+
}
|
package/src/props.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AdEventListener, BannerAdSizeType } from './types'
|
|
2
|
+
|
|
3
|
+
/** AdMob banner — Google Mobile Ads on iOS/Android. Consent (UMP/ATT) stays
|
|
4
|
+
* in the permissions seam; requestOptions carries request-level flags
|
|
5
|
+
* (tagForChildDirectedTreatment etc.) straight through to the SDK. */
|
|
6
|
+
export interface BannerAdProps {
|
|
7
|
+
className?: any
|
|
8
|
+
style?: any
|
|
9
|
+
adUnitId: string
|
|
10
|
+
size?: BannerAdSizeType
|
|
11
|
+
requestOptions?: Record<string, unknown>
|
|
12
|
+
onAdEvent?: AdEventListener
|
|
13
|
+
ios?: Record<string, any>
|
|
14
|
+
android?: Record<string, any>
|
|
15
|
+
web?: Record<string, any>
|
|
16
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type AdEventType =
|
|
2
|
+
| 'loaded'
|
|
3
|
+
| 'failed_to_load'
|
|
4
|
+
| 'opened'
|
|
5
|
+
| 'closed'
|
|
6
|
+
| 'clicked'
|
|
7
|
+
| 'impression'
|
|
8
|
+
| 'earned_reward'
|
|
9
|
+
| 'error'
|
|
10
|
+
|
|
11
|
+
export interface AdEvent {
|
|
12
|
+
type: AdEventType
|
|
13
|
+
error?: Error
|
|
14
|
+
reward?: { amount: number; type: string }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type AdEventListener = (event: AdEvent) => void
|
|
18
|
+
|
|
19
|
+
export interface LoadedAd {
|
|
20
|
+
readonly adUnitId: string
|
|
21
|
+
readonly loaded: boolean
|
|
22
|
+
load(): void
|
|
23
|
+
onAdEvent(listener: AdEventListener): void
|
|
24
|
+
show(options?: Record<string, unknown>): void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type BannerAdSizeType =
|
|
28
|
+
| 'banner'
|
|
29
|
+
| 'largeBanner'
|
|
30
|
+
| 'mediumRectangle'
|
|
31
|
+
| 'fullBanner'
|
|
32
|
+
| 'leaderboard'
|
|
33
|
+
| 'adaptiveBanner'
|
|
34
|
+
| 'anchoredAdaptive'
|
|
35
|
+
| 'fluid'
|
|
36
|
+
|
|
37
|
+
export interface Ads {
|
|
38
|
+
readonly supported: boolean
|
|
39
|
+
/** Initialize the Google Mobile Ads SDK — call once at app start. */
|
|
40
|
+
initialize(): Promise<void>
|
|
41
|
+
createInterstitial(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
|
|
42
|
+
createRewardedAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
|
|
43
|
+
createRewardedInterstitialAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
|
|
44
|
+
createAppOpenAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare const ads: Ads
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"files": [
|
|
4
|
+
"BannerAd.d.ts",
|
|
5
|
+
"BannerAd.web.d.ts",
|
|
6
|
+
"ads.d.ts",
|
|
7
|
+
"ads.linux.d.ts",
|
|
8
|
+
"ads.macos.d.ts",
|
|
9
|
+
"ads.web.d.ts",
|
|
10
|
+
"ads.windows.d.ts",
|
|
11
|
+
"index.d.ts",
|
|
12
|
+
"index.macos.d.ts",
|
|
13
|
+
"index.web.d.ts",
|
|
14
|
+
"index.windows.d.ts",
|
|
15
|
+
"native-elements.d.ts",
|
|
16
|
+
"props.d.ts",
|
|
17
|
+
"types.d.ts"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ads } from './ads.web.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ads } from './ads.web.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ads } from './ads.web.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BannerAd } from '@nativescript/google-mobile-ads'
|
|
2
|
+
import type { Attributes } from '@nativescript-community/octane/intrinsics'
|
|
3
|
+
|
|
4
|
+
declare module '@nativescript-community/octane/intrinsics' {
|
|
5
|
+
interface NativeScriptElements {
|
|
6
|
+
xplatbannerad: Attributes<typeof BannerAd>
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AdEventListener, BannerAdSizeType } from './types.js';
|
|
2
|
+
/** AdMob banner — Google Mobile Ads on iOS/Android. Consent (UMP/ATT) stays
|
|
3
|
+
* in the permissions seam; requestOptions carries request-level flags
|
|
4
|
+
* (tagForChildDirectedTreatment etc.) straight through to the SDK. */
|
|
5
|
+
export interface BannerAdProps {
|
|
6
|
+
className?: any;
|
|
7
|
+
style?: any;
|
|
8
|
+
adUnitId: string;
|
|
9
|
+
size?: BannerAdSizeType;
|
|
10
|
+
requestOptions?: Record<string, unknown>;
|
|
11
|
+
onAdEvent?: AdEventListener;
|
|
12
|
+
ios?: Record<string, any>;
|
|
13
|
+
android?: Record<string, any>;
|
|
14
|
+
web?: Record<string, any>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type AdEventType = 'loaded' | 'failed_to_load' | 'opened' | 'closed' | 'clicked' | 'impression' | 'earned_reward' | 'error';
|
|
2
|
+
export interface AdEvent {
|
|
3
|
+
type: AdEventType;
|
|
4
|
+
error?: Error;
|
|
5
|
+
reward?: {
|
|
6
|
+
amount: number;
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export type AdEventListener = (event: AdEvent) => void;
|
|
11
|
+
export interface LoadedAd {
|
|
12
|
+
readonly adUnitId: string;
|
|
13
|
+
readonly loaded: boolean;
|
|
14
|
+
load(): void;
|
|
15
|
+
onAdEvent(listener: AdEventListener): void;
|
|
16
|
+
show(options?: Record<string, unknown>): void;
|
|
17
|
+
}
|
|
18
|
+
export type BannerAdSizeType = 'banner' | 'largeBanner' | 'mediumRectangle' | 'fullBanner' | 'leaderboard' | 'adaptiveBanner' | 'anchoredAdaptive' | 'fluid';
|
|
19
|
+
export interface Ads {
|
|
20
|
+
readonly supported: boolean;
|
|
21
|
+
/** Initialize the Google Mobile Ads SDK — call once at app start. */
|
|
22
|
+
initialize(): Promise<void>;
|
|
23
|
+
createInterstitial(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
|
|
24
|
+
createRewardedAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
|
|
25
|
+
createRewardedInterstitialAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
|
|
26
|
+
createAppOpenAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
|
|
27
|
+
}
|
|
28
|
+
export declare const ads: Ads;
|