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 | |
|---|---|---|---|
|
|
7517aa234f |
@@ -111,6 +111,26 @@ export interface FirebaseUser {
|
||||
* name
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* whether the user is anonymous
|
||||
*/
|
||||
isAnonymous?: boolean;
|
||||
|
||||
/**
|
||||
* account creation timestamp in milliseconds
|
||||
*/
|
||||
creationTimestamp?: number;
|
||||
|
||||
/**
|
||||
* last sign-in timestamp in milliseconds
|
||||
*/
|
||||
lastSignInTimestamp?: number;
|
||||
|
||||
/**
|
||||
* array of linked provider info objects
|
||||
*/
|
||||
providers?: any[];
|
||||
}
|
||||
export interface MessagePayloadAps {
|
||||
alert?: {
|
||||
@@ -133,6 +153,59 @@ export interface MessagePayload {
|
||||
tap?: 'background' | 'foreground';
|
||||
aps?: MessagePayloadAps;
|
||||
}
|
||||
|
||||
export interface OnDeviceConversionUserIdentifier {
|
||||
/**
|
||||
* The user's email address. Mutually exclusive with phoneNumber.
|
||||
*/
|
||||
emailAddress?: string;
|
||||
|
||||
/**
|
||||
* The user's phone number in E.164 format. Mutually exclusive with emailAddress.
|
||||
*/
|
||||
phoneNumber?: string;
|
||||
}
|
||||
|
||||
export interface EnrollSecondAuthFactorOptions {
|
||||
/**
|
||||
* A display name for this factor. Auto-generated (masking all but the last 4 digits of the phone number) if not provided.
|
||||
*/
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export interface VerifySecondAuthFactorParams {
|
||||
/**
|
||||
* Index of the enrolled factor to verify (for an MFA sign-in challenge).
|
||||
*/
|
||||
selectedIndex?: number;
|
||||
|
||||
/**
|
||||
* The verification ID from phone verification.
|
||||
*/
|
||||
verificationId?: string;
|
||||
|
||||
/**
|
||||
* The SMS verification code entered by the user.
|
||||
*/
|
||||
code?: string;
|
||||
}
|
||||
|
||||
export interface EnrolledSecondAuthFactor {
|
||||
/**
|
||||
* The factor's index.
|
||||
*/
|
||||
index: number;
|
||||
|
||||
/**
|
||||
* The enrolled phone number.
|
||||
*/
|
||||
phoneNumber: string;
|
||||
|
||||
/**
|
||||
* The display name for this factor, if set.
|
||||
*/
|
||||
displayName?: string;
|
||||
}
|
||||
/**
|
||||
* @name Firebase X
|
||||
* @description
|
||||
@@ -160,6 +233,10 @@ export interface MessagePayload {
|
||||
* ```
|
||||
* @interfaces
|
||||
* IChannelOptions
|
||||
* OnDeviceConversionUserIdentifier
|
||||
* EnrollSecondAuthFactorOptions
|
||||
* VerifySecondAuthFactorParams
|
||||
* EnrolledSecondAuthFactor
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FirebaseX',
|
||||
@@ -190,6 +267,66 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getId(). Returns the current Firebase Installation ID (FID).
|
||||
*
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getInstallationId(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid Firebase Installation auth token (always force-refreshed).
|
||||
*
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getInstallationToken(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the current Firebase Installation ID and all associated data. Firebase will generate a new FID on next access.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
deleteInstallationId(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a listener that is called whenever the Firebase Installation ID changes.
|
||||
*
|
||||
* @param {Function} fn - callback function to invoke with the new installation ID string
|
||||
*/
|
||||
@Cordova()
|
||||
registerInstallationIdChangeListener(fn: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a listener that is called when the application transitions to the foreground (iOS applicationDidBecomeActive / Android onResume).
|
||||
*
|
||||
* @param {Function} fn - callback function to invoke when the app becomes active
|
||||
*/
|
||||
@Cordova()
|
||||
registerApplicationDidBecomeActiveListener(fn: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a listener that is called when the application transitions to the background (iOS applicationDidEnterBackground / Android onPause).
|
||||
*
|
||||
* @param {Function} fn - callback function to invoke when the app enters the background
|
||||
*/
|
||||
@Cordova()
|
||||
registerApplicationDidEnterBackgroundListener(fn: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current FCM user.
|
||||
*
|
||||
@@ -261,6 +398,20 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* iOS 12+ only.
|
||||
* Get notified when the user taps the notification settings action in the system notification settings.
|
||||
* Requires UNAuthorizationOptionProvidesAppNotificationSettings.
|
||||
*
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
onOpenSettings(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant permission to receive push notifications (will trigger prompt) and return hasPermission: true. iOS only (Android will always return true).
|
||||
*
|
||||
@@ -273,6 +424,19 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* iOS 12+ only. Grant critical alert permission (bypasses Do Not Disturb and the ringer switch). Requires a special Apple entitlement.
|
||||
* On Android this is a no-op and returns false.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
grantCriticalPermission(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permission to receive push notifications and return hasPermission: true. iOS only (Android will always return true).
|
||||
*
|
||||
@@ -283,6 +447,16 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* iOS 12+ only. Check whether the app has critical alert permission. On Android this always returns false.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
hasCriticalPermission(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister from firebase, used to stop receiving push notifications. Call this when you logout user from your app.
|
||||
*/
|
||||
@@ -428,6 +602,16 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current analytics data collection enabled state.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isAnalyticsCollectionEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable Crashlytics collection.
|
||||
*
|
||||
@@ -439,6 +623,16 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current Crashlytics data collection enabled state.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isCrashlyticsCollectionEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable performance collection.
|
||||
*
|
||||
@@ -450,6 +644,16 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current performance data collection enabled state.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isPerformanceCollectionEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an event using Analytics
|
||||
*
|
||||
@@ -496,6 +700,20 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* iOS only. Initiates on-device conversion measurement using an email address or phone number.
|
||||
* Only one identifier type may be provided per call.
|
||||
*
|
||||
* @param {OnDeviceConversionUserIdentifier} userIdentifier
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
initiateOnDeviceConversionMeasurement(userIdentifier: OnDeviceConversionUserIdentifier): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Crashlytics user identifier.
|
||||
* To diagnose an issue, it’s often helpful to know which of your users experienced a given crash.
|
||||
@@ -512,6 +730,18 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom key-value pair for Crashlytics crash reports. Appears in the "Keys" tab of a crash report.
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {string | number | boolean} value
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
setCrashlyticsCustomKey(key: string, value: string | number | boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulates (causes) a fatal native crash which causes a crash event to be sent to Crashlytics (useful for testing).
|
||||
* See the Firebase documentation regarding crash testing.
|
||||
@@ -552,6 +782,16 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the app crashed during the previous execution.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
didCrashOnPreviousExecution(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests verification of a phone number in order to authenticate a user and sign then into Firebase in your app.
|
||||
*
|
||||
@@ -583,6 +823,57 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrolls a phone number as a second authentication factor (MFA) for the current user.
|
||||
*
|
||||
* @param {string} number - phone number to enroll as a second factor, in E.164 format
|
||||
* @param {EnrollSecondAuthFactorOptions} [opts] - optional parameters
|
||||
* @returns {Promise<any>} resolves with the enrollment result (contains verificationId for SMS code entry)
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
enrollSecondAuthFactor(number: string, opts?: EnrollSecondAuthFactorOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a second authentication factor during an MFA sign-in challenge or enrollment.
|
||||
*
|
||||
* @param {VerifySecondAuthFactorParams} params
|
||||
* @param {object} [opts] - reserved for future use
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
verifySecondAuthFactor(params: VerifySecondAuthFactorParams, opts?: object): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists the second authentication factors enrolled for the current user.
|
||||
*
|
||||
* @returns {Promise<EnrolledSecondAuthFactor[]>}
|
||||
*/
|
||||
@Cordova()
|
||||
listEnrolledSecondAuthFactors(): Promise<EnrolledSecondAuthFactor[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an enrolled second authentication factor from the current user.
|
||||
*
|
||||
* @param {number} selectedIndex - index of the enrolled factor to remove (from listEnrolledSecondAuthFactors())
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
unenrollSecondAuthFactor(selectedIndex: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch current authentification system language, for example, the phone sms code.
|
||||
*
|
||||
@@ -626,6 +917,19 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an email/password credential without signing in. The returned credential can be used with
|
||||
* signInWithCredential(), linkUserWithCredential(), or reauthenticateWithCredential().
|
||||
*
|
||||
* @param email
|
||||
* @param password
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
authenticateUserWithEmailAndPassword(email: string, password: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs in user with custom token.
|
||||
*
|
||||
@@ -666,6 +970,43 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates the user with Microsoft Sign-In via Firebase OAuthProvider. Returns a credential for use with signInWithCredential().
|
||||
*
|
||||
* @param locale - optional locale to pass to the Microsoft sign-in provider
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
authenticateUserWithMicrosoft(locale?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates the user with Facebook using an access token obtained from the Facebook SDK.
|
||||
* Returns a credential for use with signInWithCredential().
|
||||
*
|
||||
* @param accessToken - a Facebook access token obtained via the Facebook Login SDK
|
||||
*/
|
||||
@Cordova()
|
||||
authenticateUserWithFacebook(accessToken: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates the user with a generic OAuth provider via Firebase OAuthProvider. Returns a credential for use with signInWithCredential().
|
||||
*
|
||||
* @param providerId - the OAuth provider ID (e.g. "github.com", "twitter.com", "yahoo.com")
|
||||
* @param customParameters - optional custom OAuth parameters to send to the provider
|
||||
* @param scopes - optional OAuth scopes to request from the provider
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
authenticateUserWithOAuth(providerId: string, customParameters?: object, scopes?: string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Links the user account to an existing Firebase user account with credentials obtained using verifyPhoneNumber().
|
||||
* See the Android- and iOS-specific Firebase documentation for more info.
|
||||
@@ -691,6 +1032,16 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlinks a provider from the currently signed-in user, removing that sign-in method.
|
||||
*
|
||||
* @param {string} providerId - the provider ID to unlink (e.g. "google.com", "password", "phone")
|
||||
*/
|
||||
@Cordova()
|
||||
unlinkUserWithProvider(providerId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is a current Firebase user signed into the app.
|
||||
*/
|
||||
@@ -729,6 +1080,17 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a verification email to the specified new email address before updating.
|
||||
* The email is only updated after the user clicks the verification link.
|
||||
*
|
||||
* @param email - the new email address to verify
|
||||
*/
|
||||
@Cordova()
|
||||
verifyBeforeUpdateEmail(email: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a verification email to the currently configured email address of the current Firebase user signed into the app.
|
||||
* When the user opens the contained link, their email address will have been verified.
|
||||
@@ -777,6 +1139,37 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback that fires whenever the user's ID token changes (sign-in, sign-out, and token refresh events).
|
||||
*
|
||||
* @param {Function} fn - callback function to invoke when the ID token changes
|
||||
*/
|
||||
@Cordova()
|
||||
registerAuthIdTokenChangeListener(fn: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures Firebase Auth to connect to a local Auth emulator for testing. Must be called before any other auth operations.
|
||||
*
|
||||
* @param {string} host - the emulator host (e.g. "localhost" or "10.0.2.2" for Android emulator)
|
||||
* @param {number} port - the emulator port (e.g. 9099)
|
||||
*/
|
||||
@Cordova()
|
||||
useAuthEmulator(host: string, port: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the custom claims from the current user's ID token. Custom claims are set server-side using the Firebase Admin SDK.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getClaims(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Remote Config parameter values for your app.
|
||||
*
|
||||
@@ -809,6 +1202,16 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all Remote Config values back to defaults. Note: not currently available on iOS.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
resetRemoteConfig(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Map of Firebase Remote Config key value pairs.
|
||||
*
|
||||
@@ -834,6 +1237,7 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Android only. Retrieve a Remote Config byte array.
|
||||
*
|
||||
* @deprecated Removed upstream in cordova-plugin-firebasex 20.0.0 (modular plugin rewrite); no longer present in the Remote Config API.
|
||||
* @param {string} key
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@@ -1033,6 +1437,86 @@ export class FirebaseX extends AwesomeCordovaNativePlugin {
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a document exists in a Firestore collection.
|
||||
*
|
||||
* @param {string} documentId - document ID of the document to check.
|
||||
* @param {string} collection - name of top-level collection to check.
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
documentExistsInFirestoreCollection(documentId: string, collection: string): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a real-time listener on a single document in a Firestore collection.
|
||||
* The success callback is called multiple times: first with {eventType: "id", id: listenerId},
|
||||
* then with {eventType: "change", snapshot, source, fromCache} on each change.
|
||||
* Call removeFirestoreListener() with the returned listener ID to stop listening.
|
||||
*
|
||||
* @param {string} documentId - document ID of the document to listen to.
|
||||
* @param {string} collection - name of top-level collection to listen to.
|
||||
* @param {boolean} includeMetadata - whether to include metadata-only changes.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
})
|
||||
listenToDocumentInFirestoreCollection(
|
||||
documentId: string,
|
||||
collection: string,
|
||||
includeMetadata?: boolean
|
||||
): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a real-time listener on an entire Firestore collection, optionally filtered.
|
||||
* The success callback is called multiple times: first with {eventType: "id", id: listenerId},
|
||||
* then with {eventType: "change", documents: {...}} on each change.
|
||||
* Call removeFirestoreListener() with the returned listener ID to stop listening.
|
||||
*
|
||||
* @param {string} collection - name of top-level collection to listen to.
|
||||
* @param {Array} filters - filters to apply to the collection (same format as fetchFirestoreCollection()).
|
||||
* @param {boolean} includeMetadata - whether to include metadata-only changes.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
})
|
||||
listenToFirestoreCollection(collection: string, filters?: any[], includeMetadata?: boolean): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a previously registered Firestore snapshot listener.
|
||||
*
|
||||
* @param {string} listenerId - the listener ID returned in the initial listener response.
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
removeFirestoreListener(listenerId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes an HTTPS-callable Cloud Function by name.
|
||||
*
|
||||
* @param {string} name - the name of the Cloud Function to call.
|
||||
* @param {any} args - arguments to pass to the function (any JSON-serialisable value).
|
||||
* @returns {Promise<any>} the function's return value
|
||||
*/
|
||||
@Cordova()
|
||||
functionsHttpsCallable(name: string, args: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new V2 consent mode
|
||||
*
|
||||
|
||||
@@ -14,14 +14,6 @@ export interface IAPAdapter {
|
||||
|
||||
isSupported: boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the adapter can skip the native finish method for a transaction.
|
||||
*
|
||||
* Some platforms (e.g. Apple AppStore) require explicit acknowledgement of a purchase so it can be removed from
|
||||
* the queue of pending transactions, regardless of whether the transaction is acknowledged or consumed already.
|
||||
*/
|
||||
canSkipFinish?: boolean;
|
||||
|
||||
initialize(): Promise<IAPError | undefined>;
|
||||
|
||||
loadProducts(products: IAPProductOptions[]): Promise<(IAPProduct | IAPError)[]>;
|
||||
@@ -39,7 +31,7 @@ export interface IAPAdapter {
|
||||
handleReceiptValidationResponse(receipt: IAPReceipt, response: object): Promise<void>;
|
||||
|
||||
requestPayment(
|
||||
payment: IAPPaymentRequest,
|
||||
payment: PaymentRequest,
|
||||
additionalData?: IAPAdditionalData
|
||||
): Promise<IAPError | IAPTransaction | undefined>;
|
||||
|
||||
@@ -50,14 +42,6 @@ export interface IAPAdapter {
|
||||
checkSupport(functionality: string): boolean;
|
||||
|
||||
restorePurchases(): Promise<IAPError | undefined>;
|
||||
|
||||
/**
|
||||
* Retrieve the billing country code from the platform's storefront.
|
||||
*
|
||||
* Returns an ISO 3166-1 alpha-2 country code (e.g., "US", "FR"),
|
||||
* or undefined if the storefront information is not available.
|
||||
*/
|
||||
getStorefront?(): Promise<string | undefined>;
|
||||
}
|
||||
|
||||
export interface IAPProductOptions {
|
||||
@@ -75,26 +59,9 @@ export interface IAPProductOptions {
|
||||
* @see {@link InAppPurchase3.requestPayment}
|
||||
*/
|
||||
export interface IAPAdditionalData {
|
||||
/**
|
||||
* The application's user identifier, will be obfuscated with md5 to fill `accountId` if necessary
|
||||
*
|
||||
* @deprecated Set {@link InAppPurchase3.applicationUsername} instead. The per-transaction value is
|
||||
* ignored by upstream adapters, which always read the store-level username so receipt validation later
|
||||
* (which doesn't have access to the original additionalData) sees the same value that was sent to the
|
||||
* native API at purchase time.
|
||||
*/
|
||||
/** The application's user identifier, will be obfuscated with md5 to fill `accountId` if necessary */
|
||||
applicationUsername?: string;
|
||||
|
||||
/**
|
||||
* Quantity of items to purchase.
|
||||
*
|
||||
* Only supported on platforms that report the `'orderQuantity'` capability.
|
||||
* Platforms without support will ignore this field.
|
||||
*
|
||||
* @see {@link InAppPurchase3.checkSupport}
|
||||
*/
|
||||
quantity?: number;
|
||||
|
||||
/** GooglePlay specific additional data. See cordova-plugin-purchase documentation.*/
|
||||
googlePlay?: object;
|
||||
|
||||
@@ -160,10 +127,9 @@ export interface IAPPricingPhase {
|
||||
|
||||
priceMicros: number;
|
||||
|
||||
currency?: string;
|
||||
currency: string;
|
||||
|
||||
/** ISO 8601 duration of the period (https://en.wikipedia.org/wiki/ISO_8601#Durations) */
|
||||
billingPeriod?: string;
|
||||
billingPeriod?: number;
|
||||
|
||||
billingCycles?: number;
|
||||
|
||||
@@ -239,17 +205,6 @@ export interface IAPTransaction {
|
||||
|
||||
currency?: string;
|
||||
|
||||
/**
|
||||
* Quantity of items purchased in a single transaction.
|
||||
*
|
||||
* For consumable products, this value represents the number of items purchased.
|
||||
* For non-consumable products and subscriptions, this value is always 1.
|
||||
*
|
||||
* Supported on Android (Google Play) and iOS (Apple AppStore).
|
||||
* Use `additionalData.quantity` when placing an order to purchase multiple units in a single transaction.
|
||||
*/
|
||||
quantity?: number;
|
||||
|
||||
products: { id: string; offerId?: string }[];
|
||||
|
||||
/**
|
||||
@@ -288,21 +243,12 @@ export interface IAPVerifiedPurchase {
|
||||
|
||||
purchaseId?: string;
|
||||
|
||||
/** Identifier of the last transaction (optional) */
|
||||
transactionId?: string;
|
||||
|
||||
purchaseDate?: number;
|
||||
|
||||
expiryDate?: number;
|
||||
|
||||
isExpired?: boolean;
|
||||
|
||||
/** True when a purchase has been acknowledged to the platform. */
|
||||
isAcknowledged?: boolean;
|
||||
|
||||
/** True when a purchase has been consumed (for consumable products). */
|
||||
isConsumed?: boolean;
|
||||
|
||||
renewalIntent?: string;
|
||||
|
||||
renewalIntentChangeDate?: number;
|
||||
@@ -320,14 +266,6 @@ export interface IAPVerifiedPurchase {
|
||||
priceConsentStatus?: PriceConsentStatus;
|
||||
|
||||
lastRenewalDate?: number;
|
||||
|
||||
/**
|
||||
* Quantity of items purchased in a single transaction.
|
||||
*
|
||||
* For consumable products, this value represents the number of items purchased.
|
||||
* For non-consumable products and subscriptions, this value is always 1.
|
||||
*/
|
||||
quantity?: number;
|
||||
}
|
||||
|
||||
export interface IAPProductEvents {
|
||||
@@ -383,17 +321,6 @@ export interface IAPProductEvents {
|
||||
* If no platforms have any receipts (user made no purchase), this will also get called.
|
||||
*/
|
||||
receiptsVerified(cb: Callback<void>, callbackName?: string): IAPProductEvents;
|
||||
|
||||
/**
|
||||
* Register a function called when a platform's storefront country code changes.
|
||||
*
|
||||
* Fires when a platform's cached value transitions to a different non-empty
|
||||
* string. Does not fire for no-op refreshes, failed refreshes, or transitions
|
||||
* to undefined (the cache preserves the last-known value).
|
||||
*
|
||||
* @param cb - Callback invoked with the updated {@link IAPStorefront}
|
||||
*/
|
||||
storefrontUpdated(cb: Callback<IAPStorefront>, callbackName?: string): IAPProductEvents;
|
||||
}
|
||||
|
||||
export interface IAPPaymentRequest {
|
||||
@@ -444,67 +371,6 @@ export interface IAPPaymentRequest {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of a call to {@link InAppPurchase3.requestPayment}.
|
||||
*
|
||||
* A chainable set of event registration methods, each returning the same instance.
|
||||
*
|
||||
* @example
|
||||
* store.requestPayment(paymentRequest)
|
||||
* .cancelled(() => { // user cancelled by closing the window
|
||||
* })
|
||||
* .failed(error => { // payment request failed
|
||||
* })
|
||||
* .initiated(transaction => { // transaction initiated
|
||||
* })
|
||||
* .approved(transaction => { // transaction approved
|
||||
* })
|
||||
* .finished(transaction => { // transaction finished
|
||||
* });
|
||||
*/
|
||||
export interface IAPPaymentRequestPromise {
|
||||
/** Register a function called when the payment request failed. */
|
||||
failed(callback: Callback<IAPError>): IAPPaymentRequestPromise;
|
||||
|
||||
/** Register a function called when the payment request has been initiated. */
|
||||
initiated(callback: Callback<IAPTransaction>): IAPPaymentRequestPromise;
|
||||
|
||||
/** Register a function called when the payment request has been approved. */
|
||||
approved(callback: Callback<IAPTransaction>): IAPPaymentRequestPromise;
|
||||
|
||||
/** Register a function called when the payment request has been finished. */
|
||||
finished(callback: Callback<IAPTransaction>): IAPPaymentRequestPromise;
|
||||
|
||||
/** Register a function called when the payment request was cancelled by the user. */
|
||||
cancelled(callback: Callback<void>): IAPPaymentRequestPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* A storefront country code, scoped to a specific payment platform.
|
||||
*
|
||||
* @see {@link InAppPurchase3.getStorefront}
|
||||
*/
|
||||
export interface IAPStorefront {
|
||||
/** The platform this storefront belongs to. */
|
||||
platform: Platform;
|
||||
|
||||
/**
|
||||
* ISO 3166-1 alpha-2 country code (e.g., "US", "FR").
|
||||
*
|
||||
* Undefined if the value has not been fetched yet, or if the fetch failed.
|
||||
*/
|
||||
countryCode?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obfuscation strategy for the application username.
|
||||
*
|
||||
* Controls how `applicationUsername` is transformed before being sent to each platform's native API.
|
||||
*
|
||||
* @see {@link InAppPurchase3.obfuscator}
|
||||
*/
|
||||
export type Obfuscator = 'legacy' | 'uuid' | 'disabled' | ((applicationUsername: string, platform: Platform) => string);
|
||||
|
||||
/**
|
||||
* Purchase platforms supported by the plugin
|
||||
*/
|
||||
@@ -526,9 +392,6 @@ export enum Platform {
|
||||
|
||||
/** Test platform */
|
||||
TEST = 'test',
|
||||
|
||||
/** Iaptic.js */
|
||||
IAPTIC_JS = 'iaptic-js',
|
||||
}
|
||||
|
||||
/** Types of In-App Products */
|
||||
@@ -649,91 +512,11 @@ export enum LogLevel {
|
||||
DEBUG = 4,
|
||||
}
|
||||
|
||||
/**
|
||||
* Error codes returned by the plugin.
|
||||
*
|
||||
* @see {@link IAPError.code}
|
||||
* @see https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#error-codes
|
||||
*/
|
||||
export enum ErrorCode {
|
||||
/** Error: Failed to intialize the in-app purchase library */
|
||||
SETUP,
|
||||
/** Error: Failed to load in-app products metadata */
|
||||
LOAD,
|
||||
/** Error: Failed to make a purchase */
|
||||
PURCHASE,
|
||||
/** Error: Failed to load the purchase receipt */
|
||||
LOAD_RECEIPTS,
|
||||
/** Error: Client is not allowed to issue the request */
|
||||
CLIENT_INVALID,
|
||||
/** Error: Purchase flow has been cancelled by user */
|
||||
PAYMENT_CANCELLED,
|
||||
/** Error: Something is suspicious about a purchase */
|
||||
PAYMENT_INVALID,
|
||||
/** Error: The user is not allowed to make a payment */
|
||||
PAYMENT_NOT_ALLOWED,
|
||||
/** Error: Unknown error */
|
||||
UNKNOWN,
|
||||
/** Error: Failed to refresh the purchase receipt */
|
||||
REFRESH_RECEIPTS,
|
||||
/** Error: The product identifier is invalid */
|
||||
INVALID_PRODUCT_ID,
|
||||
/** Error: Cannot finalize a transaction or acknowledge a purchase */
|
||||
FINISH,
|
||||
/** Error: Failed to communicate with the server */
|
||||
COMMUNICATION,
|
||||
/** Error: Subscriptions are not available */
|
||||
SUBSCRIPTIONS_NOT_AVAILABLE,
|
||||
/** Error: Purchase information is missing token */
|
||||
MISSING_TOKEN,
|
||||
/** Error: Verification of store data failed */
|
||||
VERIFICATION_FAILED,
|
||||
/** Error: Bad response from the server */
|
||||
BAD_RESPONSE,
|
||||
/** Error: Failed to refresh the store */
|
||||
REFRESH,
|
||||
/** Error: Payment has expired */
|
||||
PAYMENT_EXPIRED,
|
||||
/** Error: Failed to download the content */
|
||||
DOWNLOAD,
|
||||
/** Error: Failed to update a subscription */
|
||||
SUBSCRIPTION_UPDATE_NOT_AVAILABLE,
|
||||
/** Error: The requested product is not available in the store. */
|
||||
PRODUCT_NOT_AVAILABLE,
|
||||
/** Error: The user has not allowed access to Cloud service information */
|
||||
CLOUD_SERVICE_PERMISSION_DENIED,
|
||||
/** Error: The device could not connect to the network. */
|
||||
CLOUD_SERVICE_NETWORK_CONNECTION_FAILED,
|
||||
/** Error: The user has revoked permission to use this cloud service. */
|
||||
CLOUD_SERVICE_REVOKED,
|
||||
/** Error: The user has not yet acknowledged Apple's privacy policy */
|
||||
PRIVACY_ACKNOWLEDGEMENT_REQUIRED,
|
||||
/** Error: The app is attempting to use a property for which it does not have the required entitlement. */
|
||||
UNAUTHORIZED_REQUEST_DATA,
|
||||
/** Error: The offer identifier is invalid. */
|
||||
INVALID_OFFER_IDENTIFIER,
|
||||
/** Error: The price you specified in App Store Connect is no longer valid. */
|
||||
INVALID_OFFER_PRICE,
|
||||
/** Error: The signature in a payment discount is not valid. */
|
||||
INVALID_SIGNATURE,
|
||||
/** Error: Parameters are missing in a payment discount. */
|
||||
MISSING_OFFER_PARAMS,
|
||||
/** Error: The store is blocked (e.g. Google Play blocking purchases). */
|
||||
STORE_BLOCKED,
|
||||
/**
|
||||
* Server code used when a subscription expired.
|
||||
*
|
||||
* @deprecated Validator should now return the transaction in the collection as expired.
|
||||
*/
|
||||
VALIDATOR_SUBSCRIPTION_EXPIRED = 6778003,
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export class IAPError {
|
||||
isError: true;
|
||||
/** @see {@link ErrorCode} */
|
||||
code: number;
|
||||
message: string;
|
||||
platform: Platform | null;
|
||||
@@ -1091,8 +874,6 @@ export class IAPError {
|
||||
* IAPVerifiedPurchase
|
||||
* IAPProductEvents
|
||||
* IAPPaymentRequest
|
||||
* IAPPaymentRequestPromise
|
||||
* IAPStorefront
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
@@ -1133,38 +914,18 @@ export class InAppPurchase3 extends AwesomeCordovaNativePlugin {
|
||||
@CordovaProperty()
|
||||
verbosity: number;
|
||||
|
||||
/**
|
||||
* Return the identifier of the user for your application.
|
||||
*
|
||||
* This value is obfuscated according to {@link InAppPurchase3.obfuscator} before being
|
||||
* sent to the native platform API.
|
||||
*/
|
||||
/** Return the identifier of the user for your application */
|
||||
@CordovaProperty()
|
||||
applicationUsername: string | (() => string | undefined) | undefined;
|
||||
applicationUsername: string | (() => string);
|
||||
|
||||
/**
|
||||
* Get the application username as a string by either calling or returning {@link InAppPurchase3.applicationUsername}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
getApplicationUsername(): string | undefined {
|
||||
getApplicationUsername(): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obfuscation strategy for the application username.
|
||||
*
|
||||
* Controls how `applicationUsername` is transformed before being sent
|
||||
* to each platform's native API. `'uuid'` is the recommended setting
|
||||
* for new integrations; the default `'legacy'` exists only for
|
||||
* backward compatibility with server-side modules that already
|
||||
* correlate against the raw 32-hex MD5 value.
|
||||
*
|
||||
* @default 'legacy'
|
||||
* @see {@link Obfuscator}
|
||||
*/
|
||||
@CordovaProperty()
|
||||
obfuscator: Obfuscator | undefined;
|
||||
|
||||
/**
|
||||
* URL or implementation of the receipt validation service
|
||||
*
|
||||
@@ -1210,7 +971,12 @@ export class InAppPurchase3 extends AwesomeCordovaNativePlugin {
|
||||
*/
|
||||
@CordovaProperty()
|
||||
validator_privacy_policy:
|
||||
'fraud' | 'support' | 'analytics' | 'tracking' | ('fraud' | 'support' | 'analytics' | 'tracking')[] | undefined;
|
||||
| 'fraud'
|
||||
| 'support'
|
||||
| 'analytics'
|
||||
| 'tracking'
|
||||
| ('fraud' | 'support' | 'analytics' | 'tracking')[]
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* Register a product.
|
||||
@@ -1237,10 +1003,10 @@ export class InAppPurchase3 extends AwesomeCordovaNativePlugin {
|
||||
* Call to initialize the in-app purchase plugin.
|
||||
*
|
||||
* @param platforms - List of payment platforms to initialize, default to Store.defaultPlatform().
|
||||
* @returns {Promise<IAPError[]>}
|
||||
* @returns {Promise<IAPError | undefined>}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
initialize(platforms?: (Platform | { platform: Platform; options?: object })[]): Promise<IAPError[]> {
|
||||
initialize(platforms: (Platform | { platform: Platform; options?: object })[]): Promise<IAPError | undefined> {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1404,7 +1170,7 @@ export class InAppPurchase3 extends AwesomeCordovaNativePlugin {
|
||||
* @param {IAPAdditionalData?} additionalData Additional parameters
|
||||
*/
|
||||
@Cordova({ sync: false })
|
||||
requestPayment(paymentRequest: IAPPaymentRequest, additionalData?: IAPAdditionalData): IAPPaymentRequestPromise {
|
||||
requestPayment(paymentRequest: IAPPaymentRequest, additionalData?: IAPAdditionalData): object {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1456,34 +1222,9 @@ export class InAppPurchase3 extends AwesomeCordovaNativePlugin {
|
||||
* @example
|
||||
* if (purchase.isBillingRetryPeriod)
|
||||
* store.manageBilling(purchase.platform);
|
||||
* @param {Platform?} platform
|
||||
*/
|
||||
@Cordova({ sync: false })
|
||||
manageBilling(platform?: Platform): Promise<IAPError | undefined> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the billing country code from the platform's storefront.
|
||||
*
|
||||
* Returns a `IAPStorefront` object with the platform and its ISO 3166-1
|
||||
* alpha-2 country code (e.g., "US", "FR"). The country code may be
|
||||
* undefined if the underlying fetch has not yet completed or failed —
|
||||
* the platform is still reported. Returns `undefined` only when no
|
||||
* matching adapter is ready.
|
||||
*
|
||||
* @param platform - Optional platform. If omitted, returns the first
|
||||
* cached non-empty storefront, or a `{ platform, countryCode: undefined }`
|
||||
* object for the first ready adapter.
|
||||
*
|
||||
* @example
|
||||
* const storefront = store.getStorefront();
|
||||
* if (storefront?.countryCode) {
|
||||
* console.log(`Billing country: ${storefront.countryCode}`);
|
||||
* }
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
getStorefront(platform?: Platform): IAPStorefront | undefined {
|
||||
manageBilling(): Promise<IAPError | undefined> {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user