mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-08-04 00:00:08 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe96b472fd |
@@ -36,16 +36,6 @@ export interface AppsflyerOptions {
|
||||
* time for the sdk to wait before launch - IOS 14 ONLY!
|
||||
*/
|
||||
waitForATTUserAuthorization?: number;
|
||||
|
||||
/**
|
||||
* For iOS only, to test uninstall in Sandbox environment
|
||||
*/
|
||||
useUninstallSandbox?: boolean;
|
||||
|
||||
/**
|
||||
* Prevents the SDK from sending the launch request after calling initSdk(...). When using this property, the app needs to manually trigger the startSdk() API to report the app launch. default=true
|
||||
*/
|
||||
shouldStartSdk?: boolean;
|
||||
}
|
||||
|
||||
export interface AppsflyerEvent {
|
||||
@@ -60,87 +50,6 @@ export interface AppsflyerInviteOptions {
|
||||
};
|
||||
}
|
||||
|
||||
export interface AppsflyerConsent {
|
||||
/**
|
||||
* Indicates whether GDPR regulations apply to the user. Also serves as a flag for compliance with relevant aspects of DMA regulations.
|
||||
*/
|
||||
isUserSubjectToGDPR: boolean | null;
|
||||
|
||||
/**
|
||||
* Indicates whether the user has consented to use their data for advertising purposes.
|
||||
*/
|
||||
hasConsentForDataUsage: boolean | null;
|
||||
|
||||
/**
|
||||
* Indicates whether the user has consented to use their data for personalized advertising.
|
||||
*/
|
||||
hasConsentForAdsPersonalization: boolean | null;
|
||||
|
||||
/**
|
||||
* Indicates whether the user has provided consent for the storage of their advertising data.
|
||||
*/
|
||||
hasConsentForAdStorage: boolean | null;
|
||||
}
|
||||
|
||||
export interface AppsflyerPurchaseDetails {
|
||||
/**
|
||||
* The purchase type: "subscription" or "one_time_purchase"
|
||||
*/
|
||||
purchaseType: string;
|
||||
|
||||
/**
|
||||
* The purchase token from Google Play Store (Android) or transaction ID (iOS)
|
||||
*/
|
||||
purchaseToken: string;
|
||||
|
||||
/**
|
||||
* The product identifier
|
||||
*/
|
||||
productId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mediation network values accepted by logAdRevenue's AppsflyerAdRevenueData.mediationNetwork field.
|
||||
*/
|
||||
export enum AppsflyerMediationNetwork {
|
||||
IRONSOURCE = 'ironsource',
|
||||
APPLOVIN_MAX = 'applovinmax',
|
||||
GOOGLE_ADMOB = 'googleadmob',
|
||||
FYBER = 'fyber',
|
||||
APPODEAL = 'appodeal',
|
||||
ADMOST = 'Admost',
|
||||
TOPON = 'Topon',
|
||||
TRADPLUS = 'Tradplus',
|
||||
YANDEX = 'Yandex',
|
||||
CHARTBOOST = 'chartboost',
|
||||
UNITY = 'Unity',
|
||||
TOPON_PTE = 'toponpte',
|
||||
CUSTOM_MEDIATION = 'customMediation',
|
||||
DIRECT_MONETIZATION_NETWORK = 'directMonetizationNetwork',
|
||||
}
|
||||
|
||||
export interface AppsflyerAdRevenueData {
|
||||
/**
|
||||
* The monetization network name
|
||||
*/
|
||||
monetizationNetwork: string;
|
||||
|
||||
/**
|
||||
* The mediation network used
|
||||
*/
|
||||
mediationNetwork: AppsflyerMediationNetwork;
|
||||
|
||||
/**
|
||||
* ISO 4217 currency code
|
||||
*/
|
||||
currencyIso4217Code: string;
|
||||
|
||||
/**
|
||||
* The ad revenue amount
|
||||
*/
|
||||
revenue: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Appsflyer
|
||||
* @description
|
||||
@@ -162,9 +71,6 @@ export interface AppsflyerAdRevenueData {
|
||||
* AppsflyerOptions
|
||||
* AppsflyerEvent
|
||||
* AppsflyerInviteOptions
|
||||
* AppsflyerConsent
|
||||
* AppsflyerPurchaseDetails
|
||||
* AppsflyerAdRevenueData
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Appsflyer',
|
||||
@@ -303,276 +209,4 @@ export class Appsflyer extends AwesomeCordovaNativePlugin {
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
logCrossPromotionAndOpenStore(appId: string, campaign: string, options: object): void {}
|
||||
|
||||
/**
|
||||
* Starts the SDK. Must call initSdk first in order to make this work. Used together with the AppsflyerOptions.shouldStartSdk option.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
startSdk(): void {}
|
||||
|
||||
/**
|
||||
* Register Unified deep link listener. Must be called before initSdk() and it overrides registerOnAppOpenAttribution.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
registerDeepLink(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the currency code used for in-app purchase events.
|
||||
*
|
||||
* @param {string} currencyId ISO 4217 Currency Codes, default 'USD'
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setCurrencyCode(currencyId: string): void {}
|
||||
|
||||
/**
|
||||
* Get the current SDK version
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getSdkVersion(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated deprecated since 6.4.0. Use setSharingFilterForPartners instead
|
||||
* Used by advertisers to exclude all networks/integrated partners from getting data
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setSharingFilterForAllPartners(): void {}
|
||||
|
||||
/**
|
||||
* @deprecated deprecated since 6.4.0. Use setSharingFilterForPartners instead
|
||||
* Used by advertisers to exclude specified networks/integrated partners from getting data
|
||||
*
|
||||
* @param {string[]} networks Array of partners that need to be excluded
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setSharingFilter(networks: string[]): void {}
|
||||
|
||||
/**
|
||||
* Used by advertisers to exclude specified networks/integrated partners from getting data
|
||||
*
|
||||
* @param {string[]} networks Array of partners that need to be excluded
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setSharingFilterForPartners(networks: string[]): void {}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in the future. Please use validateAndLogInAppPurchaseV2.
|
||||
* Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported.
|
||||
*
|
||||
* @param {AppsflyerEvent} purchaseInfo In-App Purchase parameters
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
validateAndLogInAppPurchase(purchaseInfo: AppsflyerEvent): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported. This method uses V2 API.
|
||||
*
|
||||
* @param {AppsflyerPurchaseDetails} purchaseDetails Purchase details object containing productId, purchaseToken and purchaseType
|
||||
* @param {AppsflyerEvent} additionalParameters Additional parameters to include with the purchase event (optional)
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
validateAndLogInAppPurchaseV2(
|
||||
purchaseDetails: AppsflyerPurchaseDetails,
|
||||
additionalParameters?: AppsflyerEvent
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* In app purchase receipt validation Apple environment (production or sandbox)
|
||||
*
|
||||
* @param {boolean} isSandbox true if In app purchase is done with sandbox
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
setUseReceiptValidationSandbox(isSandbox: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* (iOS only) AppsFlyer SDK dynamically loads the Apple iAd.framework. This framework is required to record and measure the performance of Apple Search Ads in your app. If you don't want AppsFlyer to dynamically load this framework, set this property to true.
|
||||
*
|
||||
* @param {boolean} collectASA If you don't want AppsFlyer to dynamically load iAd.framework, set this property to true
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
disableCollectASA(collectASA: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable collection of Apple, Google, Amazon and Open advertising ids (IDFA, GAID, AAID, OAID).
|
||||
*
|
||||
* @param {boolean} disableAdvertisingIdentifier Disable collection of advertising ids
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
setDisableAdvertisingIdentifier(disableAdvertisingIdentifier: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Onelink custom/branded domains. Use this API during the SDK Initialization to indicate branded domains.
|
||||
*
|
||||
* @param {string[]} domains String array of branded domains
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
setOneLinkCustomDomains(domains: string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support deferred deep linking from Facebook Ads. Use this API before initSdk().
|
||||
*
|
||||
* @param {boolean} isEnabled enable support deferred deep linking from Facebook Ads
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
enableFacebookDeferredApplinks(isEnabled: boolean): void {}
|
||||
|
||||
/**
|
||||
* Set user emails for FB Advanced Matching
|
||||
*
|
||||
* @param {string[]} emails String array of emails
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
setUserEmails(emails: string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set phone number for FB Advanced Matching
|
||||
*
|
||||
* @param {string} phoneNumber String phone number
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
setPhoneNumber(phoneNumber: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom host prefix and host name
|
||||
*
|
||||
* @param {string} hostPrefix host prefix
|
||||
* @param {string} hostName host name
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setHost(hostPrefix: string, hostName: string): void {}
|
||||
|
||||
/**
|
||||
* Provides app owners with a flexible interface for configuring how deep links are extracted from push notification payloads. Must be called before initSdk().
|
||||
*
|
||||
* @param {string[]} path strings array of the path
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
addPushNotificationDeepLinkPath(path: string[]): void {}
|
||||
|
||||
/**
|
||||
* Use this API to get the OneLink from click domains that launch the app. Make sure to call this API before SDK initialization.
|
||||
*
|
||||
* @param {string[]} urls strings array of domains
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setResolveDeepLinkURLs(urls: string[]): void {}
|
||||
|
||||
/**
|
||||
* Enable or disable SKAD support. Set true if you want to disable it. Must be called before initSdk() and for iOS only.
|
||||
*
|
||||
* @param {boolean} isDisabled disable or enable SKAD support
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
disableSKAD(isDisabled: boolean): void {}
|
||||
|
||||
/**
|
||||
* Set the language of the device. The data will be displayed in Raw Data Reports. Must be called before initSdk() and for iOS only.
|
||||
*
|
||||
* @param {string} language The device language
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setCurrentDeviceLanguage(language: string): void {}
|
||||
|
||||
/**
|
||||
* Allows you to add custom data to events sent from the SDK. Typically used to integrate on the SDK level with several external partner platforms.
|
||||
*
|
||||
* @param {AppsflyerEvent} additionalData custom data
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setAdditionalData(additionalData: AppsflyerEvent): void {}
|
||||
|
||||
/**
|
||||
* Allows sending custom data for partner integration purposes.
|
||||
*
|
||||
* @param {string} partnerId ID of the partner (usually suffixed with "_int")
|
||||
* @param {AppsflyerEvent} data Customer data, depends on the integration configuration with the specific partner
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setPartnerData(partnerId: string, data: AppsflyerEvent): void {}
|
||||
|
||||
/**
|
||||
* Measure and get data from push-notification campaigns.
|
||||
*
|
||||
* @param {AppsflyerEvent} pushData JSON object contains the push data
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendPushNotificationData(pushData: AppsflyerEvent): void {}
|
||||
|
||||
/**
|
||||
* Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device.
|
||||
*
|
||||
* @param {boolean} disable Defaults to false
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setDisableNetworkData(disable: boolean): void {}
|
||||
|
||||
/**
|
||||
* Set consent fields manually (e.g. by prompting user and collecting results). Use this API to provide the consent data directly to the SDK when GDPR applies to the user and your app does not use a CMP compatible with TCF v2.2.
|
||||
*
|
||||
* @param {AppsflyerConsent} appsFlyerConsent Consent data
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setConsentData(appsFlyerConsent: AppsflyerConsent): void {}
|
||||
|
||||
/**
|
||||
* Instruct the SDK to collect the TCF data from the device.
|
||||
*
|
||||
* @param {boolean} enable enable/disable TCF data collection
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
enableTCFDataCollection(enable: boolean): void {}
|
||||
|
||||
/**
|
||||
* Log ad revenue event.
|
||||
*
|
||||
* @param {AppsflyerAdRevenueData} adRevenueData the ad revenue data
|
||||
* @param {AppsflyerEvent} additionalParameters additional params data (optional)
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
logAdRevenue(adRevenueData: AppsflyerAdRevenueData, additionalParameters?: AppsflyerEvent): void {}
|
||||
|
||||
/**
|
||||
* (Android only) Disables App Set ID collection (enabled by default).
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
disableAppSetId(): void {}
|
||||
|
||||
/**
|
||||
* (iOS) Log deep linking. Add a function 'handleOpenUrl' to your root and call this to track deeplinks with AppsFlyer attribution data.
|
||||
*
|
||||
* @param {string} url the opened url
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
handleOpenUrl(url: string): void {}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,196 @@
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface BackgroundFetchConfig {
|
||||
/**
|
||||
* Authorization status of the Background Fetch API. Returned by `BackgroundFetch#configure` and `BackgroundFetch#status`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
export enum BackgroundFetchStatus {
|
||||
/**
|
||||
* Background fetch updates are unavailable and the user cannot enable them again.
|
||||
* For example, this status can occur when parental controls are in effect for the current user.
|
||||
*/
|
||||
STATUS_RESTRICTED = 0,
|
||||
/**
|
||||
* The user explicitly disabled background behavior for this app or for the whole system.
|
||||
*/
|
||||
STATUS_DENIED = 1,
|
||||
/**
|
||||
* Background fetch is available and enabled.
|
||||
*/
|
||||
STATUS_AVAILABLE = 2,
|
||||
}
|
||||
|
||||
/**
|
||||
* [Android only] Network type constraint for scheduled tasks. Used with `BackgroundFetchConfig#requiredNetworkType`
|
||||
* and `BackgroundFetchTaskConfig#requiredNetworkType`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
export enum BackgroundFetchNetworkType {
|
||||
/**
|
||||
* No network constraint. The task will run regardless of network state.
|
||||
*/
|
||||
NONE = 0,
|
||||
/**
|
||||
* The task requires any active network connection.
|
||||
*/
|
||||
ANY = 1,
|
||||
/**
|
||||
* The task requires an unmetered (e.g. Wi-Fi) network connection.
|
||||
*/
|
||||
UNMETERED = 2,
|
||||
/**
|
||||
* The task requires a non-roaming network connection.
|
||||
*/
|
||||
NOT_ROAMING = 3,
|
||||
/**
|
||||
* The task requires a cellular (mobile data) network connection.
|
||||
*/
|
||||
CELLULAR = 4,
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration properties shared by both `BackgroundFetchConfig` and `BackgroundFetchTaskConfig`.
|
||||
*
|
||||
* Aside from `stopOnTerminate`, all properties are Android-only. iOS manages background execution
|
||||
* through its own system-controlled Background Fetch mechanism and does not support these constraints.
|
||||
*/
|
||||
export interface BackgroundFetchAbstractConfig {
|
||||
/**
|
||||
* Set true to cease background-fetch from operating after user "closes" the app. Defaults to true.
|
||||
*/
|
||||
stopOnTerminate?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Set `true` to initiate background-fetch events when the device is rebooted. Defaults to `false`.
|
||||
* NOTE: `startOnBoot` requires `stopOnTerminate: false`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
startOnBoot?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Set `true` to enable the Headless mechanism for handling fetch events after app termination.
|
||||
* Defaults to `false`. NOTE: Requires `stopOnTerminate: false`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
enableHeadless?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] By default, the plugin uses Android's `JobScheduler` when possible and falls back to
|
||||
* `AlarmManager` for older devices. Set `true` to always use `AlarmManager` regardless of API level.
|
||||
* Defaults to `false`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
forceAlarmManager?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Specify the kind of network connectivity required to run this task. Defaults to
|
||||
* `BackgroundFetchNetworkType.NONE`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
requiredNetworkType?: BackgroundFetchNetworkType;
|
||||
|
||||
/**
|
||||
* [Android only] Set `true` to require the device's battery level to be above the "low battery" threshold
|
||||
* before running this task. Defaults to `false`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
requiresBatteryNotLow?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Set `true` to require the device's available storage to be above the "low storage"
|
||||
* threshold before running this task. Defaults to `false`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
requiresStorageNotLow?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Set `true` to require the device to be charging (or connected to permanent power, such
|
||||
* as an Android TV device) before running this task. Defaults to `false`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
requiresCharging?: boolean;
|
||||
|
||||
/**
|
||||
* [Android only] Set `true` to require the device to be idle (not actively used) before running this task.
|
||||
* Defaults to `false`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
requiresDeviceIdle?: boolean;
|
||||
}
|
||||
|
||||
export interface BackgroundFetchConfig extends BackgroundFetchAbstractConfig {
|
||||
/**
|
||||
* The minimum interval in **minutes** between background-fetch events. Defaults to `15` minutes. The
|
||||
* minimum allowed value is `15` minutes.
|
||||
*
|
||||
* NOTE: The OS does not guarantee fetch events will fire at exactly this interval. iOS adjusts the
|
||||
* interval based on usage patterns and system conditions. This value is a *minimum*, not a schedule.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
minimumFetchInterval?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for a custom scheduled task, provided to `BackgroundFetch#scheduleTask`.
|
||||
*
|
||||
* @since 7.0.0
|
||||
*/
|
||||
export interface BackgroundFetchTaskConfig extends BackgroundFetchAbstractConfig {
|
||||
/**
|
||||
* A unique identifier for this task. Use the same `taskId` with `BackgroundFetch#finish` to signal
|
||||
* completion and with `BackgroundFetch#stopTask` to cancel it. Use reverse-domain notation to avoid
|
||||
* collisions (e.g. `'com.foo.sync'`).
|
||||
*/
|
||||
taskId: string;
|
||||
|
||||
/**
|
||||
* The minimum delay in **milliseconds** before this task runs.
|
||||
*
|
||||
* NOTE: On iOS, the system may delay the task beyond this value depending on device conditions. On
|
||||
* Android, `JobScheduler` treats this as a minimum delay.
|
||||
*/
|
||||
delay: number;
|
||||
|
||||
/**
|
||||
* Set `true` to schedule a repeating task. Defaults to `false` (one-shot).
|
||||
*/
|
||||
periodic?: boolean;
|
||||
|
||||
/**
|
||||
* [iOS only] Set `true` to require a network connection before running this task. On Android, use
|
||||
* `requiredNetworkType` instead.
|
||||
*/
|
||||
requiresNetworkConnectivity?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Background Fetch
|
||||
* @description
|
||||
* iOS Background Fetch Implementation. See: https://developer.apple.com/reference/uikit/uiapplication#1657399
|
||||
* iOS Background Fetch is basically an API which wakes up your app about every 15 minutes (during the user's prime-time hours) and provides your app exactly 30s of background running-time. This plugin will execute your provided callbackFn whenever a background-fetch event occurs. There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible value of UIApplicationBackgroundFetchIntervalMinimum -- iOS determines the rate automatically based upon device usage and time-of-day (ie: fetch-rate is about ~15min during prime-time hours; less frequently when the user is presumed to be sleeping, at 3am for example).
|
||||
* Cross-platform Background Fetch implementation. This plugin will execute your provided callbackFn
|
||||
* whenever a background-fetch event occurs.
|
||||
*
|
||||
* ### iOS
|
||||
* There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the
|
||||
* most frequent possible value -- iOS determines the rate automatically based upon device usage and
|
||||
* time-of-day (ie: fetch-rate is about ~15min during prime-time hours; less frequently when the user is
|
||||
* presumed to be sleeping).
|
||||
*
|
||||
* ### Android
|
||||
* Uses `JobScheduler` (API 21+) or `AlarmManager` to schedule periodic callbacks. Additional constraints
|
||||
* (network, charging, idle) can be set via `BackgroundFetchConfig`.
|
||||
*
|
||||
* For more detail, please see https://github.com/transistorsoft/cordova-plugin-background-fetch
|
||||
* @usage
|
||||
*
|
||||
@@ -23,17 +201,23 @@ export interface BackgroundFetchConfig {
|
||||
* constructor(private backgroundFetch: BackgroundFetch) {
|
||||
*
|
||||
* const config: BackgroundFetchConfig = {
|
||||
* minimumFetchInterval: 15,
|
||||
* stopOnTerminate: false, // Set true to cease background-fetch from operating after user "closes" the app. Defaults to true.
|
||||
* }
|
||||
*
|
||||
* backgroundFetch.configure(config)
|
||||
* .then(() => {
|
||||
* console.log('Background Fetch initialized');
|
||||
* backgroundFetch.configure(config, (taskId: string) => {
|
||||
*
|
||||
* this.backgroundFetch.finish();
|
||||
* console.log('Background Fetch event received', taskId);
|
||||
*
|
||||
* })
|
||||
* .catch(e => console.log('Error initializing background fetch', e));
|
||||
* this.backgroundFetch.finish(taskId);
|
||||
*
|
||||
* }, (taskId: string) => {
|
||||
* // OS has signalled that remaining background time is about to expire.
|
||||
* console.log('Background Fetch TIMEOUT', taskId);
|
||||
* this.backgroundFetch.finish(taskId);
|
||||
* }).then((status) => {
|
||||
* console.log('Background Fetch initialized', status);
|
||||
* }).catch(e => console.log('Error initializing background fetch', e));
|
||||
*
|
||||
* // Start the background-fetch API. Your callbackFn provided to #configure will be executed each time a background-fetch event occurs. NOTE the #configure method automatically calls #start. You do not have to call this method after you #configure the plugin
|
||||
* backgroundFetch.start();
|
||||
@@ -47,26 +231,38 @@ export interface BackgroundFetchConfig {
|
||||
* ```
|
||||
* @interfaces
|
||||
* BackgroundFetchConfig
|
||||
* BackgroundFetchTaskConfig
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BackgroundFetch',
|
||||
plugin: 'cordova-plugin-background-fetch',
|
||||
pluginRef: 'BackgroundFetch',
|
||||
repo: 'https://github.com/transistorsoft/cordova-plugin-background-fetch',
|
||||
platforms: ['iOS'],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BackgroundFetch extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Configures the plugin's fetch callbackFn
|
||||
* Configures the plugin's fetch callbackFn.
|
||||
*
|
||||
* Calling `configure` automatically starts background-fetch (equivalent to calling `#start` immediately
|
||||
* after configuration).
|
||||
*
|
||||
* @param {BackgroundFetchConfig} config Configuration for plugin
|
||||
* @param {Function} [onEvent] Callback fired when a background-fetch event is received. The `taskId`
|
||||
* string identifies which task fired -- pass it to `#finish` when done. Required as of plugin `7.0.0`.
|
||||
* @param {Function} [onTimeout] Callback fired when the OS signals that remaining background time is
|
||||
* about to expire. Call `#finish` immediately. Added in plugin `7.0.0`.
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
otherPromise: true,
|
||||
})
|
||||
configure(config: BackgroundFetchConfig): Promise<any> {
|
||||
configure(
|
||||
config: BackgroundFetchConfig,
|
||||
onEvent?: (taskId: string) => void,
|
||||
onTimeout?: (taskId: string) => void
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,4 +306,33 @@ export class BackgroundFetch extends AwesomeCordovaNativePlugin {
|
||||
status(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a custom one-shot or periodic background task in addition to the default fetch callback
|
||||
* registered with `#configure`.
|
||||
*
|
||||
* Custom tasks fire the same callback registered via `#configure`'s `onEvent` argument, with their
|
||||
* unique `taskId`. Use `#finish` with that `taskId` to signal completion.
|
||||
*
|
||||
* @param {BackgroundFetchTaskConfig} config Task configuration, including a unique `taskId` and a
|
||||
* minimum `delay` in milliseconds.
|
||||
* @returns {Promise<any>}
|
||||
* @since 7.0.0
|
||||
*/
|
||||
@Cordova()
|
||||
scheduleTask(config: BackgroundFetchTaskConfig): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a specific task previously scheduled via `#scheduleTask`, identified by its `taskId`.
|
||||
*
|
||||
* @param taskId The identifier of the scheduled task to stop.
|
||||
* @returns {Promise<any>}
|
||||
* @since 7.0.0
|
||||
*/
|
||||
@Cordova()
|
||||
stopTask(taskId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user