react-native-nami-sdk 3.2.0-beta.1 → 3.2.1-beta.2

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.
@@ -50,6 +50,7 @@ export interface INamiPaywallManager {
50
50
  isHidden: () => Promise<boolean>;
51
51
  isPaywallOpen: () => Promise<boolean>;
52
52
  setProductDetails: (productDetails: string, allowOffers: boolean) => void;
53
+ setAppSuppliedVideoDetails: (url: string, name?: string) => void;
53
54
  }
54
55
 
55
56
  const { NamiPaywallManagerBridge, RNNamiPaywallManager } = NativeModules;
@@ -161,13 +162,10 @@ export const NamiPaywallManager: INamiPaywallManager = {
161
162
  isPaywallOpen: () => {
162
163
  return RNNamiPaywallManager.isPaywallOpen();
163
164
  },
164
- setProductDetails: (
165
- productDetails: string,
166
- allowOffers: boolean
167
- ) => {
168
- RNNamiPaywallManager.setProductDetails(
169
- productDetails,
170
- allowOffers,
171
- );
165
+ setProductDetails: (productDetails: string, allowOffers: boolean) => {
166
+ RNNamiPaywallManager.setProductDetails(productDetails, allowOffers);
167
+ },
168
+ setAppSuppliedVideoDetails: (url: string, name?: string) => {
169
+ RNNamiPaywallManager.setAppSuppliedVideoDetails(url, name);
172
170
  },
173
171
  };
@@ -1,61 +1,20 @@
1
+ import { NativeEventEmitter } from 'react-native';
1
2
  import { EmitterSubscription } from 'react-native';
2
- import { NamiSKU } from './types';
3
-
4
- export const NamiPurchaseManager: {
5
- allPurchases: () => NamiPurchase[];
6
- anySkuPurchased: (skuIds: string[]) => boolean;
7
- consumePurchasedSku: (skuId: string) => void;
8
- presentCodeRedemptionSheet: () => void;
9
- restorePurchases: (
10
- callback: (
11
- purchaseState: NamiPurchasesState,
12
- purchases: NamiPurchase[],
13
- error: string,
14
- ) => void,
15
- ) => EmitterSubscription['remove'];
16
- skuPurchased: (skuId: string) => boolean;
17
- registerPurchasesChangedHandler: (
18
- callback: (
19
- purchaseState: NamiPurchasesState,
20
- purchases: NamiPurchase[],
21
- error: string,
22
- ) => void,
23
- ) => EmitterSubscription['remove'];
24
- registerRestorePurchasesHandler: (
25
- callback: (
26
- state: NamiRestorePurchasesState,
27
- newPurchases: NamiPurchase[],
28
- oldPurchases: NamiPurchase[],
29
- ) => void,
30
- ) => EmitterSubscription['remove'];
31
- };
32
-
33
- export type NamiPurchase = {
34
- sku?: NamiSKU;
35
- skuId: string;
36
- transactionIdentifier?: string;
37
- expires?: Date;
38
- purchaseInitiatedTimestamp: Date;
39
- purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';
40
- };
41
-
42
- export enum NamiPurchaseState {
43
- PURCHASED = 'PURCHASED',
44
- FAILED = 'FAILED',
45
- CANCELLED = 'CANCELLEDd',
46
- PENDING = 'PENDING',
47
- UNKNOWN = 'UNKNOWN',
3
+ import { NamiPurchase, NamiPurchasesState, NamiRestorePurchasesState } from './types';
4
+ export declare const NamiPurchaseManagerBridge: any, RNNamiPurchaseManager: any;
5
+ export declare enum NamiPurchaseManagerEvents {
6
+ PurchasesChanged = "PurchasesChanged",
7
+ RestorePurchasesStateChanged = "RestorePurchasesStateChanged"
48
8
  }
49
-
50
- export type NamiRestorePurchasesState = 'started' | 'finished' | 'error';
51
-
52
- export type NamiPurchasesState =
53
- | 'pending'
54
- | 'purchased'
55
- | 'consumed'
56
- | 'resubscribed'
57
- | 'unsubscribed'
58
- | 'deferred'
59
- | 'failed'
60
- | 'cancelled'
61
- | 'unknown';
9
+ export interface INamiPurchaseManager {
10
+ emitter: NativeEventEmitter;
11
+ allPurchases: () => NamiPurchase[];
12
+ anySkuPurchased: (skuIds: string[]) => boolean;
13
+ consumePurchasedSku: (skuId: string) => void;
14
+ presentCodeRedemptionSheet: () => void;
15
+ restorePurchases: (callback: (purchaseState: NamiPurchasesState, purchases: NamiPurchase[], error: string) => void) => EmitterSubscription['remove'];
16
+ skuPurchased: (skuId: string) => boolean;
17
+ registerPurchasesChangedHandler: (callback: (purchaseState: NamiPurchasesState, purchases: NamiPurchase[], error: string) => void) => EmitterSubscription['remove'];
18
+ registerRestorePurchasesHandler: (callback: (state: NamiRestorePurchasesState, newPurchases: NamiPurchase[], oldPurchases: NamiPurchase[]) => void) => EmitterSubscription['remove'];
19
+ }
20
+ export declare const NamiPurchaseManager: INamiPurchaseManager;
package/src/types.d.ts ADDED
@@ -0,0 +1,199 @@
1
+ export type NamiConfiguration = {
2
+ 'appPlatformID-apple': string;
3
+ 'appPlatformID-android': string;
4
+ logLevel: string;
5
+ namiCommands?: string[];
6
+ namiLanguageCode?: NamiLanguageCodes;
7
+ initialConfig?: string;
8
+ };
9
+ export type NamiLanguageCodes = 'af' | 'ar' | 'ar-dz' | 'ast' | 'az' | 'bg' | 'be' | 'bn' | 'br' | 'bs' | 'ca' | 'cs' | 'cy' | 'da' | 'de' | 'dsb' | 'el' | 'en' | 'en-au' | 'en-gb' | 'eo' | 'es' | 'es-ar' | 'es-co' | 'es-mx' | 'es-ni' | 'es-ve' | 'et' | 'eu' | 'fa' | 'fi' | 'fr' | 'fy' | 'ga' | 'gd' | 'gl' | 'he' | 'hi' | 'hr' | 'hsb' | 'hu' | 'hy' | 'ia' | 'id' | 'ig' | 'io' | 'is' | 'it' | 'ja' | 'ka' | 'kab' | 'kk' | 'km' | 'kn' | 'ko' | 'ky' | 'lb' | 'lt' | 'lv' | 'mk' | 'ml' | 'mn' | 'mr' | 'my' | 'nb' | 'ne' | 'nl' | 'nn' | 'os' | 'pa' | 'pl' | 'pt' | 'pt-br' | 'ro' | 'ru' | 'sk' | 'sl' | 'sq' | 'sr' | 'sr-latn' | 'sv' | 'sw' | 'ta' | 'te' | 'tg' | 'th' | 'tk' | 'tr' | 'tt' | 'udm' | 'uk' | 'ur' | 'uz' | 'vi' | 'zh-hans' | 'zh-hant';
10
+ export type NamiSKU = {
11
+ id: string;
12
+ name?: string;
13
+ skuId: string;
14
+ appleProduct?: AppleProduct;
15
+ googleProduct?: GoogleProduct;
16
+ amazonProduct?: AmazonProduct;
17
+ type: NamiSKUType;
18
+ promoId?: string | null;
19
+ promoToken?: string | null;
20
+ };
21
+ export declare enum NamiPurchaseState {
22
+ PENDING = "pending",
23
+ PURCHASED = "purchased",
24
+ CONSUMED = "consumed",
25
+ RESUBSCRIBED = "resubscribed",
26
+ UNSUBSCRIBED = "unsubscribed",
27
+ DEFERRED = "deferred",
28
+ FAILED = "failed",
29
+ CANCELLED = "cancelled",
30
+ UNKNOWN = "unknown"
31
+ }
32
+ export declare enum NamiRestorePurchasesState {
33
+ STARTED = "started",
34
+ FINISHED = "finished",
35
+ ERROR = "error"
36
+ }
37
+ export type NamiSKUType = 'unknown' | 'one_time_purchase' | 'subscription';
38
+ export type AppleProduct = {
39
+ localizedDescription: string;
40
+ localizedMultipliedPrice: string;
41
+ localizedPrice: string;
42
+ localizedTitle: string;
43
+ price: string;
44
+ priceCurrency: string;
45
+ priceLanguage: string;
46
+ };
47
+ export type GoogleProduct = {};
48
+ export type AmazonProduct = {};
49
+ export type NamiCampaign = {
50
+ id: string;
51
+ rule: string;
52
+ segment: string;
53
+ paywall: string;
54
+ type: NamiCampaignRuleType;
55
+ value?: string | null;
56
+ };
57
+ export declare enum NamiCampaignRuleType {
58
+ DEFAULT = "default",
59
+ LABEL = "label",
60
+ UNKNOWN = "unknown",
61
+ URL = "url"
62
+ }
63
+ export declare enum LaunchCampaignError {
64
+ DEFAULT_CAMPAIGN_NOT_FOUND = 0,
65
+ LABELED_CAMPAIGN_NOT_FOUND = 1,
66
+ CAMPAIGN_DATA_NOT_FOUND = 2,
67
+ PAYWALL_ALREADY_DISPLAYED = 3,
68
+ SDK_NOT_INITIALIZED = 4,
69
+ PAYWALL_COULD_NOT_DISPLAY = 5,
70
+ URL_CAMPAIGN_NOT_FOUND = 6,
71
+ PRODUCT_DATA_NOT_FOUND = 7,
72
+ PRODUCT_GROUPS_NOT_FOUND = 8
73
+ }
74
+ export declare enum LaunchCampaignResultAction {
75
+ FAILURE = "FAILURE",
76
+ SUCCESS = "SUCCESS"
77
+ }
78
+ export type FailureResultObject = {
79
+ error: string;
80
+ };
81
+ export type PaywallLaunchContext = {
82
+ productGroups?: string[];
83
+ customAttributes: {
84
+ [key: string]: string;
85
+ };
86
+ customObject?: {
87
+ [key: string]: any;
88
+ };
89
+ };
90
+ export type CustomerJourneyState = {
91
+ formerSubscriber: boolean;
92
+ inGracePeriod: boolean;
93
+ inTrialPeriod: boolean;
94
+ inIntroOfferPeriod: boolean;
95
+ isCancelled: boolean;
96
+ inPause: boolean;
97
+ inAccountHold: boolean;
98
+ };
99
+ export type AccountStateAction = 'login' | 'logout' | 'advertising_id_set' | 'vendor_id_set' | 'customer_data_platform_id_set' | 'nami_device_id_set' | 'advertising_id_cleared' | 'vendor_id_cleared' | 'customer_data_platform_id_cleared' | 'nami_device_id_cleared' | 'anonymous_mode_on' | 'anonymous_mode_off';
100
+ export type NamiEntitlement = {
101
+ activePurchases: NamiPurchase[];
102
+ desc: string;
103
+ name: string;
104
+ namiId: string;
105
+ purchasedSkus: NamiSKU[];
106
+ referenceId: string;
107
+ relatedSkus: NamiSKU[];
108
+ };
109
+ export type NamiPurchaseSuccessApple = {
110
+ product: NamiSKU;
111
+ transactionID: string;
112
+ originalTransactionID: string;
113
+ price: string;
114
+ currencyCode: string;
115
+ };
116
+ export type NamiPurchaseSuccessGooglePlay = {
117
+ product: NamiSKU;
118
+ orderId: string;
119
+ purchaseToken: string;
120
+ };
121
+ export type NamiPurchaseSuccessAmazon = {
122
+ product: NamiSKU;
123
+ receiptId: string;
124
+ localizedPrice: string;
125
+ userId: string;
126
+ marketplace: string;
127
+ };
128
+ export declare enum NamiPaywallAction {
129
+ BUY_SKU = "BUY_SKU",
130
+ SELECT_SKU = "SELECT_SKU",
131
+ RESTORE_PURCHASES = "RESTORE_PURCHASES",
132
+ SIGN_IN = "SIGN_IN",
133
+ CLOSE_PAYWALL = "CLOSE_PAYWALL",
134
+ SHOW_PAYWALL = "SHOW_PAYWALL",
135
+ PURCHASE_SELECTED_SKU = "PURCHASE_SELECTED_SKU",
136
+ PURCHASE_SUCCESS = "PURCHASE_SUCCESS",
137
+ PURCHASE_FAILED = "PURCHASE_FAILED",
138
+ PURCHASE_CANCELLED = "PURCHASE_CANCELLED",
139
+ PURCHASE_PENDING = "PURCHASE_PENDING",
140
+ PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN",
141
+ PURCHASE_DEFERRED = "PURCHASE_DEFERRED",
142
+ DEEPLINK = "DEEPLINK",
143
+ TOGGLE_CHANGE = "TOGGLE_CHANGE",
144
+ PAGE_CHANGE = "PAGE_CHANGE",
145
+ SLIDE_CHANGE = "SLIDE_CHANGE",
146
+ COLLAPSIBLE_DRAWER_OPEN = "COLLAPSIBLE_DRAWER_OPEN",
147
+ COLLAPSIBLE_DRAWER_CLOSE = "COLLAPSIBLE_DRAWER_CLOSE",
148
+ VIDEO_STARTED = "VIDEO_STARTED",
149
+ VIDEO_PAUSED = "VIDEO_PAUSED",
150
+ VIDEO_RESUMED = "VIDEO_RESUMED",
151
+ VIDEO_ENDED = "VIDEO_ENDED",
152
+ VIDEO_CHANGED = "VIDEO_CHANGED",
153
+ VIDEO_MUTED = "VIDEO_MUTED",
154
+ VIDEO_UNMUTED = "VIDEO_UNMUTED",
155
+ UNKNOWN = "UNKNOWN"
156
+ }
157
+ export type NamiPurchase = {
158
+ sku?: NamiSKU;
159
+ skuId: string;
160
+ transactionIdentifier?: string;
161
+ expires?: Date;
162
+ purchaseInitiatedTimestamp: Date;
163
+ purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';
164
+ };
165
+ export type NamiPurchasesState = 'pending' | 'purchased' | 'consumed' | 'resubscribed' | 'unsubscribed' | 'deferred' | 'failed' | 'cancelled' | 'unknown';
166
+ export type NamiPaywallEvent = {
167
+ action: NamiPaywallAction;
168
+ campaignId?: string;
169
+ campaignName?: string;
170
+ campaignType?: string;
171
+ campaignLabel?: string;
172
+ campaignUrl?: string;
173
+ paywallId?: string;
174
+ paywallName?: string;
175
+ componentChange?: NamiPaywallComponentChange;
176
+ segmentId?: string;
177
+ externalSegmentId?: string;
178
+ deeplinkUrl?: string;
179
+ sku?: NamiSKU;
180
+ purchaseError?: string;
181
+ purchases?: NamiPurchase[];
182
+ videoMetadata?: NamiPaywallEventVideoMetadata;
183
+ timeSpentOnPaywall?: number;
184
+ };
185
+ export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
186
+ export type NamiPaywallComponentChange = {
187
+ id?: string;
188
+ name?: string;
189
+ };
190
+ export type NamiPaywallEventVideoMetadata = {
191
+ id?: string;
192
+ name?: string;
193
+ url?: string;
194
+ loopVideo: boolean;
195
+ muteByDefault: boolean;
196
+ autoplayVideo: boolean;
197
+ contentTimecode?: number;
198
+ contentDuration?: number;
199
+ };
package/src/types.ts CHANGED
@@ -151,7 +151,7 @@ export type GoogleProduct = {};
151
151
 
152
152
  export type AmazonProduct = {};
153
153
 
154
- // NameCampaignManager
154
+ // NamiCampaignManager
155
155
  export type NamiCampaign = {
156
156
  id: string;
157
157
  rule: string;
@@ -177,7 +177,7 @@ export enum LaunchCampaignError {
177
177
  PAYWALL_COULD_NOT_DISPLAY = 5,
178
178
  URL_CAMPAIGN_NOT_FOUND = 6,
179
179
  PRODUCT_DATA_NOT_FOUND = 7,
180
- PRODUCT_GROUPS_NOT_FOUND = 8
180
+ PRODUCT_GROUPS_NOT_FOUND = 8,
181
181
  }
182
182
 
183
183
  export enum LaunchCampaignResultAction {
@@ -196,6 +196,10 @@ export type PaywallLaunchContext = {
196
196
  customAttributes: {
197
197
  [key: string]: string;
198
198
  };
199
+ // Custom object used as data source for advanced paywall components
200
+ customObject?: {
201
+ [key: string]: any;
202
+ };
199
203
  };
200
204
 
201
205
  export type CustomerJourneyState = {
@@ -274,6 +278,15 @@ export enum NamiPaywallAction {
274
278
  TOGGLE_CHANGE = 'TOGGLE_CHANGE',
275
279
  PAGE_CHANGE = 'PAGE_CHANGE',
276
280
  SLIDE_CHANGE = 'SLIDE_CHANGE',
281
+ COLLAPSIBLE_DRAWER_OPEN = 'COLLAPSIBLE_DRAWER_OPEN',
282
+ COLLAPSIBLE_DRAWER_CLOSE = 'COLLAPSIBLE_DRAWER_CLOSE',
283
+ VIDEO_STARTED = 'VIDEO_STARTED',
284
+ VIDEO_PAUSED = 'VIDEO_PAUSED',
285
+ VIDEO_RESUMED = 'VIDEO_RESUMED',
286
+ VIDEO_ENDED = 'VIDEO_ENDED',
287
+ VIDEO_CHANGED = 'VIDEO_CHANGED',
288
+ VIDEO_MUTED = 'VIDEO_MUTED',
289
+ VIDEO_UNMUTED = 'VIDEO_UNMUTED',
277
290
  UNKNOWN = 'UNKNOWN',
278
291
  }
279
292
 
@@ -297,3 +310,41 @@ export type NamiPurchasesState =
297
310
  | 'failed'
298
311
  | 'cancelled'
299
312
  | 'unknown';
313
+
314
+ export type NamiPaywallEvent = {
315
+ action: NamiPaywallAction;
316
+ campaignId?: string;
317
+ campaignName?: string;
318
+ campaignType?: string;
319
+ campaignLabel?: string;
320
+ campaignUrl?: string;
321
+ paywallId?: string;
322
+ paywallName?: string;
323
+ componentChange?: NamiPaywallComponentChange;
324
+ segmentId?: string;
325
+ externalSegmentId?: string;
326
+ deeplinkUrl?: string;
327
+ sku?: NamiSKU;
328
+ purchaseError?: string;
329
+ purchases?: NamiPurchase[];
330
+ videoMetadata?: NamiPaywallEventVideoMetadata;
331
+ timeSpentOnPaywall?: number;
332
+ };
333
+
334
+ export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
335
+
336
+ export type NamiPaywallComponentChange = {
337
+ id?: string;
338
+ name?: string;
339
+ };
340
+
341
+ export type NamiPaywallEventVideoMetadata = {
342
+ id?: string;
343
+ name?: string;
344
+ url?: string;
345
+ loopVideo: boolean;
346
+ muteByDefault: boolean;
347
+ autoplayVideo: boolean;
348
+ contentTimecode?: number;
349
+ contentDuration?: number;
350
+ };
package/tsconfig.json CHANGED
@@ -9,10 +9,12 @@
9
9
  "declaration": true, /* Generates corresponding '.d.ts' file. */
10
10
  // "sourceMap": true, /* Generates corresponding '.map' file. */
11
11
  // "outFile": "./", /* Concatenate and emit output to single file. */
12
+ "declarationDir": "src", /* Output directory for generated declaration files. */
12
13
  "outDir": "dist", /* Redirect output structure to the directory. */
13
14
  "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
14
15
  // "removeComments": true, /* Do not emit comments to output. */
15
- "noEmit": true, /* Do not emit outputs. */
16
+ "emitDeclarationOnly": true, /* Only output d.ts files and not js files */
17
+ // "noEmit": true, /* Do not emit outputs. */
16
18
  // "incremental": true, /* Enable incremental compilation */
17
19
  // "importHelpers": true, /* Import emit helpers from 'tslib'. */
18
20
  // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
@@ -57,8 +59,7 @@
57
59
  // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
58
60
  },
59
61
  "include": [
60
- "./src",
61
- ".eslintrc.js"
62
+ "./src"
62
63
  ],
63
64
  "exclude": [
64
65
  "node_modules",