diff --git a/src/@ionic-native/plugins/branch-io/index.ts b/src/@ionic-native/plugins/branch-io/index.ts new file mode 100644 index 000000000..49f061bcc --- /dev/null +++ b/src/@ionic-native/plugins/branch-io/index.ts @@ -0,0 +1,235 @@ +import { Injectable } from '@angular/core'; +import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; + +export interface BranchIoPromise { + $identity_id?: number; + $one_time_use?: boolean; + '+click_timestamp'?: number; + '+clicked_branch_link'?: boolean; + '+is_first_session'?: boolean; + '+match_guaranteed'?: boolean; + contentMetadata?: string; + source?: string; + '~campaign'?: string; + '~channel'?: string; + '~creation_source'?: string; + '~feature'?: string; + '~id'?: number; + '~referring_link:'?: string; + [x: string]: any; +} + +export interface BranchIoAnalytics { + channel?: string; + feature?: string; + campaign?: string; + stage?: string; + tags?: string[]; + [x: string]: any; +} + +export interface BranchIoProperties { + contentMetadata?: { + [x: string]: any; + }; + [x: string]: any; +} + +export interface BranchUniversalObject { + generateShortUrl( + analytics: BranchIoAnalytics, + properties: BranchIoProperties + ): Promise; + registerView(): Promise; + showShareSheet( + analytics: BranchIoAnalytics, + properties: BranchIoProperties, + shareText: string + ): Promise; + onShareSheetLaunched(callback: any): void; + onShareSheetDismissed(callback: any): void; + onLinkShareResponse(callback: any): void; + onChannelSelected(callback: any): void; + listOnSpotlight(): Promise; +} + +/** + * @name BranchIo + * @description + * Branch.io is an attribution service for deeplinking and invitation links + * + * @usage + * ``` + * import { BranchIo } from '@ionic-native/branch-io'; + * + * + * constructor(private branch: BranchIo) { } + * + * ``` + * + * @interfaces + * BranchIoPromise + * BranchIoAnalytics + * BranchIoProperties + * BranchUniversalObject + * + */ +@Plugin({ + pluginName: 'BranchIo', + plugin: 'branch-cordova-sdk', + pluginRef: 'Branch', + repo: + 'https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking', + platforms: ['iOS', 'Android'] +}) +@Injectable() +export class BranchIo extends IonicNativePlugin { + /** + * for development and debugging only + * @param {boolean} enable Enable debug + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + setDebug(enable: boolean): Promise { + return; + } + + /** + * Disable tracking + * @param {boolean} disable disable tracking + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + disableTracking(disable: boolean): Promise { + return; + } + + /** + * Initializes Branch + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + initSession(): Promise { + return; + } + + /** + * Set Request Metadata + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + setRequestMetadata(): Promise { + return; + } + + /** + * for better Android matching + * @param {string} linkDomain LinkDomain at branch + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + setCookieBasedMatching(linkDomain: string): Promise { + return; + } + + /** + * First data + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + getFirstReferringParams(): Promise { + return; + } + + /** + * Latest data + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + getLatestReferringParams(): Promise { + return; + } + + /** + * Set identy of user + * @param {string} userId + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + setIdentity(userId: string): Promise { + return; + } + + /** + * Logout user + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + logout(): Promise { + return; + } + + /** + * Registers a custom event + * @param {string} eventName + * @param {any} metaData + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + userCompletedAction(eventName: string, metaData: any): Promise { + return; + } + + /** + * Send Commerce Event + * @param {string} event + * @param {any} metaData + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + sendCommerceEvent(event: string, metaData: any): Promise { + return; + } + + /** + * create a branchUniversalObj variable to reference with other Branch methods + * @param {BranchIoProperties} properties + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + createBranchUniversalObject( + properties: BranchIoProperties + ): Promise { + return; + } + + /** + * Load credits + * @param {any} bucket + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + loadRewards(bucket: any): Promise { + return; + } + + /** + * Redeem Rewards + * @param {string} value + * @param {any} bucket + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + redeemRewards(value: string, bucket: any): Promise { + return; + } + + /** + * Show credit history + * @return {Promise} + */ + @Cordova({ otherPromise: true }) + creditHistory(): Promise { + return; + } +}