@virex-tech/paywallo-sdk 2.0.0 → 2.0.1
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.
- package/dist/index.js +38 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -30
- package/dist/index.mjs.map +1 -1
- package/ios/PaywalloNotifications.m +4 -1
- package/ios/PaywalloNotifications.swift +60 -73
- package/package.json +1 -1
- package/ios/PaywalloNotificationsSwizzle.swift +0 -126
package/dist/index.js
CHANGED
|
@@ -4424,8 +4424,15 @@ var init_NativePushBridge = __esm({
|
|
|
4424
4424
|
const mod = import_react_native17.NativeModules.PaywalloNotifications;
|
|
4425
4425
|
if (!mod) return -1;
|
|
4426
4426
|
const status = await mod.requestPermission(options ?? {});
|
|
4427
|
+
if (status === "granted" || status === "provisional") {
|
|
4428
|
+
try {
|
|
4429
|
+
await mod.registerForPush();
|
|
4430
|
+
} catch {
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4427
4433
|
return mapStatusToNumber(status);
|
|
4428
|
-
} catch {
|
|
4434
|
+
} catch (err) {
|
|
4435
|
+
console.warn("[NativePushBridge] requestPermission error:", err instanceof Error ? err.message : String(err));
|
|
4429
4436
|
return -1;
|
|
4430
4437
|
}
|
|
4431
4438
|
}
|
|
@@ -4800,11 +4807,18 @@ var init_PermissionManager = __esm({
|
|
|
4800
4807
|
const platform = this.platformOverride ?? getPlatform();
|
|
4801
4808
|
if (this.debug) console.warn("[paywallo-push] platform detected:", platform.OS, "version:", String(platform.Version ?? "n/a"));
|
|
4802
4809
|
if (platform.OS === "ios") {
|
|
4803
|
-
if (this.debug) console.
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4810
|
+
if (this.debug) console.warn("[paywallo-push] requestPermission iOS \u2014 calling bridge...");
|
|
4811
|
+
try {
|
|
4812
|
+
const raw2 = await this.bridge.requestPermission(options);
|
|
4813
|
+
if (this.debug) console.warn("[paywallo-push] bridge returned raw:", raw2);
|
|
4814
|
+
const status2 = mapPermissionStatus(raw2);
|
|
4815
|
+
if (this.debug) console.warn("[paywallo-push] mapped status:", status2);
|
|
4816
|
+
this.emitOsEvent(status2);
|
|
4817
|
+
return status2;
|
|
4818
|
+
} catch (err) {
|
|
4819
|
+
console.warn("[paywallo-push] requestPermission iOS CRASHED:", err instanceof Error ? err.message : String(err));
|
|
4820
|
+
throw err;
|
|
4821
|
+
}
|
|
4808
4822
|
}
|
|
4809
4823
|
if (!needsAndroidRuntimePermission(platform)) {
|
|
4810
4824
|
if (this.debug) console.log("[paywallo-push] Android <13: auto-granted");
|
|
@@ -5018,8 +5032,8 @@ var init_utils = __esm({
|
|
|
5018
5032
|
// src/core/version.ts
|
|
5019
5033
|
function resolveVersion() {
|
|
5020
5034
|
try {
|
|
5021
|
-
if ("2.0.
|
|
5022
|
-
return "2.0.
|
|
5035
|
+
if ("2.0.1") {
|
|
5036
|
+
return "2.0.1";
|
|
5023
5037
|
}
|
|
5024
5038
|
} catch {
|
|
5025
5039
|
}
|
|
@@ -5297,14 +5311,23 @@ var init_NotificationsManager = __esm({
|
|
|
5297
5311
|
}
|
|
5298
5312
|
/** Requests OS permission and, on success, captures + registers the push token. */
|
|
5299
5313
|
async requestPushPermission(options) {
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5314
|
+
if (this.debug) console.warn("[Paywallo PUSH] requestPushPermission called");
|
|
5315
|
+
try {
|
|
5316
|
+
const status = await this.permissionManager.requestPermission(options);
|
|
5317
|
+
if (this.debug) console.warn("[Paywallo PUSH] permissionManager returned:", status);
|
|
5318
|
+
this.permissionStatus = status;
|
|
5319
|
+
if (status === "granted" || status === "provisional") {
|
|
5320
|
+
if (this.debug) console.warn("[Paywallo PUSH] permission granted \u2014 capturing token...");
|
|
5321
|
+
await this.captureAndRegisterToken();
|
|
5322
|
+
if (this.debug) console.warn("[Paywallo PUSH] token capture complete");
|
|
5323
|
+
} else {
|
|
5324
|
+
if (this.debug) console.warn("[Paywallo PUSH] permission not granted, skipping token register:", status);
|
|
5325
|
+
}
|
|
5326
|
+
return status;
|
|
5327
|
+
} catch (err) {
|
|
5328
|
+
console.warn("[Paywallo PUSH] requestPushPermission CRASHED:", err instanceof Error ? err.message : String(err));
|
|
5329
|
+
throw err;
|
|
5306
5330
|
}
|
|
5307
|
-
return status;
|
|
5308
5331
|
}
|
|
5309
5332
|
async captureAndRegisterToken() {
|
|
5310
5333
|
await captureAndRegisterToken(
|
|
@@ -7332,17 +7355,14 @@ async function resolveSessionFlags(state, keys, apiClient, distinctId) {
|
|
|
7332
7355
|
}
|
|
7333
7356
|
}
|
|
7334
7357
|
async function doInit(state, config) {
|
|
7335
|
-
console.warn("[Paywallo INIT] starting... debug=" + String(config.debug) + " env=" + String(config.environment ?? "auto"));
|
|
7336
7358
|
const environment = config.environment ?? (typeof __DEV__ !== "undefined" && __DEV__ ? "Sandbox" : "Production");
|
|
7337
7359
|
const offlineQueueEnabled = config.offlineQueueEnabled !== false;
|
|
7338
|
-
if (config.debug) console.warn("[Paywallo INIT] step 1: network + queue");
|
|
7339
7360
|
await Promise.all([
|
|
7340
7361
|
networkMonitor.initialize({ debug: config.debug }),
|
|
7341
7362
|
offlineQueue.initialize({ debug: config.debug }).then(
|
|
7342
7363
|
() => offlineQueue.clearItemsWithInvalidAppKey(config.appKey)
|
|
7343
7364
|
)
|
|
7344
7365
|
]);
|
|
7345
|
-
if (config.debug) console.warn("[Paywallo INIT] step 1 done");
|
|
7346
7366
|
const apiClient = new ApiClient(
|
|
7347
7367
|
config.appKey,
|
|
7348
7368
|
config.apiUrl ?? DEFAULT_API_URL2,
|
|
@@ -7365,9 +7385,7 @@ async function doInit(state, config) {
|
|
|
7365
7385
|
cacheTTL: config.subscriptionCacheTTL,
|
|
7366
7386
|
debug: config.debug
|
|
7367
7387
|
});
|
|
7368
|
-
if (config.debug) console.warn("[Paywallo INIT] step 2: identity");
|
|
7369
7388
|
await identityManager.initialize(apiClient, config.debug);
|
|
7370
|
-
if (config.debug) console.warn("[Paywallo INIT] step 2 done");
|
|
7371
7389
|
if (state.pendingIdentifies.length > 0) {
|
|
7372
7390
|
for (const pending of state.pendingIdentifies) {
|
|
7373
7391
|
try {
|
|
@@ -7410,22 +7428,18 @@ async function doInit(state, config) {
|
|
|
7410
7428
|
...attribution && Object.keys(attribution).length > 0 && { attribution }
|
|
7411
7429
|
};
|
|
7412
7430
|
});
|
|
7413
|
-
if (config.debug) console.warn("[Paywallo INIT] step 3: session");
|
|
7414
7431
|
await sessionManager.initialize(
|
|
7415
7432
|
apiClient,
|
|
7416
7433
|
config.sessionConfig,
|
|
7417
7434
|
config.debug,
|
|
7418
7435
|
() => identityManager.getDistinctId()
|
|
7419
7436
|
);
|
|
7420
|
-
if (config.debug) console.warn("[Paywallo INIT] step 3 done");
|
|
7421
7437
|
const eventPipeline = createEventPipelineBridge(apiClient);
|
|
7422
7438
|
onboardingManager.injectDeps({
|
|
7423
7439
|
pipeline: eventPipeline,
|
|
7424
7440
|
debug: config.debug
|
|
7425
7441
|
});
|
|
7426
|
-
if (config.debug) console.warn("[Paywallo INIT] step 4: notifications");
|
|
7427
7442
|
setupNotifications(apiClient, config, environment, eventPipeline);
|
|
7428
|
-
if (config.debug) console.warn("[Paywallo INIT] step 4 done");
|
|
7429
7443
|
if (config.autoStartSession !== false) {
|
|
7430
7444
|
sessionManager.startSession().catch((err) => {
|
|
7431
7445
|
if (config.debug) console.warn("[Paywallo INIT] autoStart session error", err);
|
|
@@ -7736,29 +7750,23 @@ var init_PaywalloClient = __esm({
|
|
|
7736
7750
|
}
|
|
7737
7751
|
async init(config) {
|
|
7738
7752
|
const s = this.state;
|
|
7739
|
-
console.warn("[Paywallo SDK] init() called, debug=" + String(config.debug) + ", appKey=" + (config.appKey ? config.appKey.substring(0, 8) + "..." : "EMPTY"));
|
|
7740
7753
|
if (!s.readyPromise) s.readyPromise = new Promise((resolve) => {
|
|
7741
7754
|
s.resolveReady = resolve;
|
|
7742
7755
|
});
|
|
7743
7756
|
if (s.config && s.apiClient) {
|
|
7744
|
-
console.warn("[Paywallo SDK] init() skipped \u2014 already initialized");
|
|
7745
7757
|
return;
|
|
7746
7758
|
}
|
|
7747
7759
|
if (s.initPromise) {
|
|
7748
|
-
console.warn("[Paywallo SDK] init() skipped \u2014 already in progress");
|
|
7749
7760
|
await s.initPromise;
|
|
7750
7761
|
return;
|
|
7751
7762
|
}
|
|
7752
7763
|
if (!config.appKey) throw new ClientError(CLIENT_ERROR_CODES.MISSING_APP_KEY, "appKey is required");
|
|
7753
7764
|
s.pendingConfig = config;
|
|
7754
7765
|
s.initAttempts = 0;
|
|
7755
|
-
console.warn("[Paywallo SDK] init() calling initWithRetry...");
|
|
7756
7766
|
s.initPromise = initWithRetry(s, config);
|
|
7757
7767
|
try {
|
|
7758
7768
|
await s.initPromise;
|
|
7759
|
-
console.warn("[Paywallo SDK] init() completed successfully");
|
|
7760
7769
|
} catch (error) {
|
|
7761
|
-
console.warn("[Paywallo SDK] init() FAILED:", error instanceof Error ? error.message : String(error));
|
|
7762
7770
|
s.initPromise = null;
|
|
7763
7771
|
s.config = null;
|
|
7764
7772
|
s.apiClient = null;
|