nativescript-plugin-firebase
Advanced tools
Comparing version 7.6.0 to 7.6.1
@@ -0,1 +1,2 @@ | ||
import { RewardedVideoAdCallbacks } from "./admob"; | ||
export declare const AD_SIZE: { | ||
@@ -20,1 +21,2 @@ SMART_BANNER: string; | ||
}; | ||
export declare const rewardedVideoCallbacks: RewardedVideoAdCallbacks; |
@@ -22,1 +22,17 @@ "use strict"; | ||
}; | ||
exports.rewardedVideoCallbacks = { | ||
onRewarded: function (reward) { return console.warn("onRewarded callback not set - the fallback implementation caught this reward: " + JSON.stringify(reward)); }, | ||
onLeftApplication: function () { | ||
}, | ||
onClosed: function () { | ||
}, | ||
onOpened: function () { | ||
}, | ||
onStarted: function () { | ||
}, | ||
onCompleted: function () { | ||
}, | ||
onLoaded: function () { | ||
}, | ||
onFailedToLoad: function (err) { return console.warn("onFailedToLoad not set - the fallback implementation caught this error: " + err); }, | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { BannerOptions, InterstitialOptions } from "./admob"; | ||
import { BannerOptions, InterstitialOptions, PreloadRewardedVideoAdOptions, ShowRewardedVideoAdOptions } from "./admob"; | ||
import { AD_SIZE } from "./admob-common"; | ||
@@ -7,2 +7,4 @@ export { AD_SIZE }; | ||
export declare function showInterstitial(arg?: InterstitialOptions): Promise<any>; | ||
export declare function preloadRewardedVideoAd(arg: PreloadRewardedVideoAdOptions): Promise<any>; | ||
export declare function showRewardedVideoAd(arg?: ShowRewardedVideoAdOptions): Promise<any>; | ||
export declare function hideBanner(): Promise<any>; |
@@ -14,3 +14,2 @@ "use strict"; | ||
var settings = firebase_common_1.firebase.merge(arg, admob_common_1.BANNER_DEFAULTS); | ||
console.log({ settings: settings }); | ||
if (firebase_common_1.firebase.admob.adView !== null && firebase_common_1.firebase.admob.adView !== undefined) { | ||
@@ -151,2 +150,89 @@ var parent_1 = firebase_common_1.firebase.admob.adView.getParent(); | ||
exports.showInterstitial = showInterstitial; | ||
function preloadRewardedVideoAd(arg) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
var settings = firebase_common_1.firebase.merge(arg, admob_common_1.BANNER_DEFAULTS); | ||
var activity = appModule.android.foregroundActivity || appModule.android.startActivity; | ||
firebase_common_1.firebase.admob.rewardedAdVideoView = com.google.android.gms.ads.MobileAds.getRewardedVideoAdInstance(activity); | ||
admob_common_1.rewardedVideoCallbacks.onLoaded = resolve; | ||
admob_common_1.rewardedVideoCallbacks.onFailedToLoad = reject; | ||
var RewardedVideoAdListener = com.google.android.gms.ads.reward.RewardedVideoAdListener.extend({ | ||
onRewarded: function (reward) { | ||
admob_common_1.rewardedVideoCallbacks.onRewarded({ | ||
amount: reward.getAmount(), | ||
type: reward.getType() | ||
}); | ||
}, | ||
onRewardedVideoAdLeftApplication: function () { | ||
admob_common_1.rewardedVideoCallbacks.onLeftApplication(); | ||
}, | ||
onRewardedVideoAdClosed: function () { | ||
if (firebase_common_1.firebase.admob.rewardedAdVideoView) { | ||
firebase_common_1.firebase.admob.rewardedAdVideoView.setRewardedVideoAdListener(null); | ||
firebase_common_1.firebase.admob.rewardedAdVideoView = null; | ||
} | ||
admob_common_1.rewardedVideoCallbacks.onClosed(); | ||
}, | ||
onRewardedVideoAdFailedToLoad: function (errorCode) { | ||
admob_common_1.rewardedVideoCallbacks.onFailedToLoad(errorCode); | ||
}, | ||
onRewardedVideoAdLoaded: function () { | ||
admob_common_1.rewardedVideoCallbacks.onLoaded(); | ||
}, | ||
onRewardedVideoAdOpened: function () { | ||
admob_common_1.rewardedVideoCallbacks.onOpened(); | ||
}, | ||
onRewardedVideoStarted: function () { | ||
admob_common_1.rewardedVideoCallbacks.onStarted(); | ||
}, | ||
onRewardedVideoCompleted: function () { | ||
admob_common_1.rewardedVideoCallbacks.onCompleted(); | ||
} | ||
}); | ||
firebase_common_1.firebase.admob.rewardedAdVideoView.setRewardedVideoAdListener(new RewardedVideoAdListener()); | ||
var ad = _buildAdRequest(settings); | ||
firebase_common_1.firebase.admob.rewardedAdVideoView.loadAd(settings.androidAdPlacementId, ad); | ||
} | ||
catch (ex) { | ||
console.log("Error in firebase.admob.preloadRewardedVideoAd: " + ex); | ||
reject(ex); | ||
} | ||
}); | ||
} | ||
exports.preloadRewardedVideoAd = preloadRewardedVideoAd; | ||
function showRewardedVideoAd(arg) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
if (!firebase_common_1.firebase.admob.rewardedAdVideoView) { | ||
reject("Please call 'preloadRewardedVideoAd' first"); | ||
return; | ||
} | ||
if (arg.onRewarded) { | ||
admob_common_1.rewardedVideoCallbacks.onRewarded = arg.onRewarded; | ||
} | ||
if (arg.onLeftApplication) { | ||
admob_common_1.rewardedVideoCallbacks.onLeftApplication = arg.onLeftApplication; | ||
} | ||
if (arg.onClosed) { | ||
admob_common_1.rewardedVideoCallbacks.onClosed = arg.onClosed; | ||
} | ||
if (arg.onOpened) { | ||
admob_common_1.rewardedVideoCallbacks.onOpened = arg.onOpened; | ||
} | ||
if (arg.onStarted) { | ||
admob_common_1.rewardedVideoCallbacks.onStarted = arg.onStarted; | ||
} | ||
if (arg.onCompleted) { | ||
admob_common_1.rewardedVideoCallbacks.onCompleted = arg.onCompleted; | ||
} | ||
firebase_common_1.firebase.admob.rewardedAdVideoView.show(); | ||
resolve(); | ||
} | ||
catch (ex) { | ||
console.log("Error in firebase.admob.showRewardedVideoAd: " + ex); | ||
reject(ex); | ||
} | ||
}); | ||
} | ||
exports.showRewardedVideoAd = showRewardedVideoAd; | ||
function hideBanner() { | ||
@@ -172,3 +258,2 @@ return new Promise(function (resolve, reject) { | ||
function _getBannerType(size) { | ||
console.log(">> _getBannerType: " + size); | ||
if (size === admob_common_1.AD_SIZE.BANNER) { | ||
@@ -175,0 +260,0 @@ return com.google.android.gms.ads.AdSize.BANNER; |
@@ -110,2 +110,51 @@ /** | ||
export interface PreloadRewardedVideoAdOptions { | ||
/** | ||
* When true you'll use googles testing iosAdPlacementId and androidAdPlacementId. | ||
*/ | ||
testing?: boolean; | ||
/** | ||
* Something like "ca-app-pub-AAAAAAAA/BBBBBBB". | ||
*/ | ||
androidAdPlacementId?: string; | ||
/** | ||
* Something like "ca-app-pub-XXXXXX/YYYYYY". | ||
*/ | ||
iosAdPlacementId?: string; | ||
/** | ||
* If testing is true, the simulator is allowed to receive test banners. | ||
* Android automatically add the connceted device as test device, but iOS does not. | ||
* If you also want to test on real devices, add it here like this: | ||
* ["ce97330130c9047ce0d4430d37d713b1", ".."] | ||
*/ | ||
iosTestDeviceIds?: string[]; | ||
/** | ||
* Specify keywords for ad targeting | ||
*/ | ||
keywords?: Array<string>; | ||
} | ||
export interface RewardedVideoAdReward { | ||
amount: number; | ||
type: string; | ||
} | ||
export interface RewardedVideoAdCallbacks { | ||
onOpened?: () => void; | ||
onStarted?: () => void; | ||
onCompleted?: () => void; | ||
onClosed?: () => void; | ||
onLeftApplication?: () => void; | ||
onLoaded: () => void, | ||
onFailedToLoad: (err) => void, | ||
onRewarded?: (reward: RewardedVideoAdReward) => void; | ||
} | ||
export interface ShowRewardedVideoAdOptions extends RewardedVideoAdCallbacks { | ||
} | ||
export declare function showBanner(options: BannerOptions): Promise<any>; | ||
@@ -130,1 +179,5 @@ | ||
export declare function showInterstitial(options?: InterstitialOptions): Promise<any>; | ||
export declare function preloadRewardedVideoAd(options: PreloadRewardedVideoAdOptions): Promise<any>; | ||
export declare function showRewardedVideoAd(options?: ShowRewardedVideoAdOptions): Promise<any>; |
@@ -1,2 +0,2 @@ | ||
import { BannerOptions, InterstitialOptions } from "./admob"; | ||
import { BannerOptions, InterstitialOptions, PreloadRewardedVideoAdOptions, ShowRewardedVideoAdOptions } from "./admob"; | ||
import { AD_SIZE } from "./admob-common"; | ||
@@ -7,2 +7,4 @@ export { AD_SIZE }; | ||
export declare function showInterstitial(arg?: InterstitialOptions): Promise<any>; | ||
export declare function preloadRewardedVideoAd(arg: PreloadRewardedVideoAdOptions): Promise<any>; | ||
export declare function showRewardedVideoAd(arg?: ShowRewardedVideoAdOptions): Promise<any>; | ||
export declare function hideBanner(): Promise<any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var firebase_common_1 = require("../firebase-common"); | ||
var platform_1 = require("tns-core-modules/platform/platform"); | ||
var enums_1 = require("tns-core-modules/ui/enums/enums"); | ||
var utils_1 = require("tns-core-modules/utils/utils"); | ||
var firebase_common_1 = require("../firebase-common"); | ||
var admob_common_1 = require("./admob-common"); | ||
exports.AD_SIZE = admob_common_1.AD_SIZE; | ||
var _bannerOptions = null; | ||
var _bannerOptions = undefined; | ||
var _rewardBasedVideoAdDelegate = undefined; | ||
function showBanner(arg) { | ||
@@ -100,3 +101,3 @@ return new Promise(function (resolve, reject) { | ||
catch (ex) { | ||
console.log("Error in firebase.admob.showInterstitial: " + ex); | ||
console.log("Error in firebase.admob.preloadInterstitial: " + ex); | ||
reject(ex); | ||
@@ -161,2 +162,77 @@ } | ||
exports.showInterstitial = showInterstitial; | ||
function preloadRewardedVideoAd(arg) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
if (typeof (GADRequest) === "undefined") { | ||
reject("Enable AdMob first - see the plugin documentation"); | ||
return; | ||
} | ||
var onLoaded = function () { return resolve(); }; | ||
var onError = function (err) { return reject(err); }; | ||
_rewardBasedVideoAdDelegate = GADRewardBasedVideoAdDelegateImpl.new().initWithCallback(onLoaded, onError); | ||
CFRetain(_rewardBasedVideoAdDelegate); | ||
firebase_common_1.firebase.admob.rewardedAdVideoView = GADRewardBasedVideoAd.sharedInstance(); | ||
firebase_common_1.firebase.admob.rewardedAdVideoView.delegate = _rewardBasedVideoAdDelegate; | ||
var settings = firebase_common_1.firebase.merge(arg, admob_common_1.BANNER_DEFAULTS); | ||
var adRequest = GADRequest.request(); | ||
if (settings.testing) { | ||
var testDevices = []; | ||
try { | ||
testDevices.push("Simulator"); | ||
} | ||
catch (ignore) { | ||
} | ||
if (settings.iosTestDeviceIds) { | ||
testDevices = testDevices.concat(settings.iosTestDeviceIds); | ||
} | ||
adRequest.testDevices = testDevices; | ||
} | ||
firebase_common_1.firebase.admob.rewardedAdVideoView.loadRequestWithAdUnitID(adRequest, settings.iosAdPlacementId); | ||
} | ||
catch (ex) { | ||
console.log("Error in firebase.admob.preloadRewardedVideoAd: " + ex); | ||
reject(ex); | ||
} | ||
}); | ||
} | ||
exports.preloadRewardedVideoAd = preloadRewardedVideoAd; | ||
function showRewardedVideoAd(arg) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
if (typeof (GADRequest) === "undefined") { | ||
reject("Enable AdMob first - see the plugin documentation"); | ||
return; | ||
} | ||
if (!firebase_common_1.firebase.admob.rewardedAdVideoView) { | ||
reject("Please call 'preloadRewardedVideoAd' first"); | ||
return; | ||
} | ||
if (arg.onRewarded) { | ||
admob_common_1.rewardedVideoCallbacks.onRewarded = arg.onRewarded; | ||
} | ||
if (arg.onLeftApplication) { | ||
admob_common_1.rewardedVideoCallbacks.onLeftApplication = arg.onLeftApplication; | ||
} | ||
if (arg.onClosed) { | ||
admob_common_1.rewardedVideoCallbacks.onClosed = arg.onClosed; | ||
} | ||
if (arg.onOpened) { | ||
admob_common_1.rewardedVideoCallbacks.onOpened = arg.onOpened; | ||
} | ||
if (arg.onStarted) { | ||
admob_common_1.rewardedVideoCallbacks.onStarted = arg.onStarted; | ||
} | ||
if (arg.onCompleted) { | ||
admob_common_1.rewardedVideoCallbacks.onCompleted = arg.onCompleted; | ||
} | ||
firebase_common_1.firebase.admob.rewardedAdVideoView.presentFromRootViewController(utils_1.ios.getter(UIApplication, UIApplication.sharedApplication).keyWindow.rootViewController); | ||
resolve(); | ||
} | ||
catch (ex) { | ||
console.log("Error in firebase.admob.showRewardedVideoAd: " + ex); | ||
reject(ex); | ||
} | ||
}); | ||
} | ||
exports.showRewardedVideoAd = showRewardedVideoAd; | ||
function hideBanner() { | ||
@@ -240,1 +316,52 @@ return new Promise(function (resolve, reject) { | ||
}(NSObject)); | ||
var GADRewardBasedVideoAdDelegateImpl = (function (_super) { | ||
__extends(GADRewardBasedVideoAdDelegateImpl, _super); | ||
function GADRewardBasedVideoAdDelegateImpl() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
GADRewardBasedVideoAdDelegateImpl.new = function () { | ||
if (GADRewardBasedVideoAdDelegateImpl.ObjCProtocols.length === 0 && typeof (GADRewardBasedVideoAdDelegate) !== "undefined") { | ||
GADRewardBasedVideoAdDelegateImpl.ObjCProtocols.push(GADRewardBasedVideoAdDelegate); | ||
} | ||
return _super.new.call(this); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.initWithCallback = function (loaded, error) { | ||
this._loaded = loaded; | ||
this._error = error; | ||
return this; | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdDidClose = function (rewardBasedVideoAd) { | ||
firebase_common_1.firebase.admob.rewardedAdVideoView = undefined; | ||
admob_common_1.rewardedVideoCallbacks.onClosed(); | ||
setTimeout(function () { | ||
CFRelease(_rewardBasedVideoAdDelegate); | ||
_rewardBasedVideoAdDelegate = undefined; | ||
}); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdDidCompletePlaying = function (rewardBasedVideoAd) { | ||
admob_common_1.rewardedVideoCallbacks.onCompleted(); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdDidFailToLoadWithError = function (rewardBasedVideoAd, error) { | ||
this._error(error.localizedDescription); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdDidOpen = function (rewardBasedVideoAd) { | ||
admob_common_1.rewardedVideoCallbacks.onOpened(); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdDidReceiveAd = function (rewardBasedVideoAd) { | ||
this._loaded(); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdDidRewardUserWithReward = function (rewardBasedVideoAd, reward) { | ||
admob_common_1.rewardedVideoCallbacks.onRewarded({ | ||
amount: reward.amount ? reward.amount.doubleValue : undefined, | ||
type: reward.type | ||
}); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdDidStartPlaying = function (rewardBasedVideoAd) { | ||
admob_common_1.rewardedVideoCallbacks.onStarted(); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.prototype.rewardBasedVideoAdWillLeaveApplication = function (rewardBasedVideoAd) { | ||
admob_common_1.rewardedVideoCallbacks.onLeftApplication(); | ||
}; | ||
GADRewardBasedVideoAdDelegateImpl.ObjCProtocols = []; | ||
return GADRewardBasedVideoAdDelegateImpl; | ||
}(NSObject)); |
export declare module database { | ||
interface DataSnapshot { | ||
exists(): boolean; | ||
key: string | null; | ||
@@ -13,3 +14,3 @@ val(): any; | ||
off(eventType?: string, callback?: (a: DataSnapshot, b?: string | null) => any, context?: Object | null): any; | ||
once(eventType: string, successCallback?: (a: DataSnapshot, b?: string) => any, failureCallbackOrContext?: Object | null, context?: Object | null): Promise<any>; | ||
once(eventType: string, successCallback?: (a: DataSnapshot, b?: string) => any, failureCallbackOrContext?: Object | null, context?: Object | null): Promise<DataSnapshot>; | ||
private getOnValueEventHandler; | ||
@@ -16,0 +17,0 @@ orderByChild(child: string): Query; |
@@ -20,5 +20,4 @@ "use strict"; | ||
key: result.key, | ||
val: function () { | ||
return result.value; | ||
} | ||
val: function () { return result.value; }, | ||
exists: function () { return !!result.value; } | ||
}); | ||
@@ -55,5 +54,4 @@ } | ||
key: result.key, | ||
val: function () { | ||
return result.value; | ||
} | ||
val: function () { return result.value; }, | ||
exists: function () { return !!result.value; } | ||
}); | ||
@@ -70,5 +68,4 @@ }); | ||
key: result.key, | ||
val: function () { | ||
return result.value; | ||
} | ||
val: function () { return result.value; }, | ||
exists: function () { return !!result.value; } | ||
}); | ||
@@ -75,0 +72,0 @@ }); |
{ | ||
"name": "nativescript-plugin-firebase", | ||
"version": "7.6.0", | ||
"version": "7.6.1", | ||
"description": "Fire. Base. Firebase!", | ||
@@ -5,0 +5,0 @@ "main": "firebase", |
@@ -5,2 +5,3 @@ # NativeScript Firebase plugin | ||
[![Downloads][downloads-image]][npm-url] | ||
[![TotalDownloads][total-downloads-image]][npm-url] | ||
[![Twitter Follow][twitter-image]][twitter-url] | ||
@@ -13,2 +14,3 @@ | ||
[downloads-image]:http://img.shields.io/npm/dm/nativescript-plugin-firebase.svg | ||
[total-downloads-image]:http://img.shields.io/npm/dt/nativescript-plugin-firebase.svg?label=total%20downloads | ||
[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me | ||
@@ -113,3 +115,3 @@ [twitter-url]:https://twitter.com/eddyverbruggen | ||
}).then( | ||
function (instance) { | ||
function () { | ||
console.log("firebase.init done"); | ||
@@ -131,3 +133,3 @@ }, | ||
}).then( | ||
instance => { | ||
() => { | ||
console.log("firebase.init done"); | ||
@@ -155,3 +157,3 @@ }, | ||
}).then( | ||
instance => { | ||
() => { | ||
console.log("firebase.init done"); | ||
@@ -158,0 +160,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
874961
14715
309