cordova-plugin-pushizo 0.2.0 → 0.3.0

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/www/core.js CHANGED
@@ -4,6 +4,7 @@ exports.PushizoCore = void 0;
4
4
  exports.normalizeNotification = normalizeNotification;
5
5
  const LOG_LEVELS = ['none', 'error', 'warn', 'info', 'debug'];
6
6
  const LIFECYCLE_EVENTS = ['willDisplay', 'didDisplay', 'willDismiss', 'didDismiss'];
7
+ const INBOX_CHANGE_TYPES = ['listed', 'read', 'read_all', 'archived', 'count'];
7
8
  /** Dinleyici hatası diğer dinleyicileri ve native köprüyü etkilemez. */
8
9
  function safeInvoke(listener, event) {
9
10
  try {
@@ -34,6 +35,43 @@ function stringRecord(input, name) {
34
35
  }
35
36
  return out;
36
37
  }
38
+ /** Kullanıcı özelliği anahtarı en çok bu kadar karakterdir (yerel iOS SDK kuralı; daha uzunu orada sessizce yok sayılır). */
39
+ const MAX_PROPERTY_KEY_LENGTH = 64;
40
+ function propertyKey(value) {
41
+ const key = requireString(value, 'key').trim();
42
+ if (key.length > MAX_PROPERTY_KEY_LENGTH) {
43
+ throw new RangeError(`Pushizo: key en fazla ${MAX_PROPERTY_KEY_LENGTH} karakter olabilir.`);
44
+ }
45
+ return key;
46
+ }
47
+ /**
48
+ * `User.setProperty` değeri: metin, sonlu sayı, mantıksal ya da bunların dizisi/düz nesnesi. Yalnızca en üstteki
49
+ * `null`/`undefined` kabul edilir (özelliği siler); iç içe `null` yerel iOS SDK'da tüm yazmayı düşürdüğünden reddedilir.
50
+ */
51
+ function propertyValue(value, name, nested = false) {
52
+ if (value === null || value === undefined) {
53
+ if (nested)
54
+ throw new TypeError(`Pushizo: ${name} null olamaz.`);
55
+ return null;
56
+ }
57
+ if (typeof value === 'string' || typeof value === 'boolean')
58
+ return value;
59
+ if (typeof value === 'number') {
60
+ if (!Number.isFinite(value))
61
+ throw new TypeError(`Pushizo: ${name} sonlu bir sayı olmalı.`);
62
+ return value;
63
+ }
64
+ if (Array.isArray(value))
65
+ return value.map((item, i) => propertyValue(item, `${name}[${i}]`, true));
66
+ const proto = typeof value === 'object' ? Object.getPrototypeOf(value) : undefined;
67
+ if (typeof value !== 'object' || (proto !== Object.prototype && proto !== null)) {
68
+ throw new TypeError(`Pushizo: ${name} metin, sayı, mantıksal, dizi veya düz nesne olmalı.`);
69
+ }
70
+ const out = {};
71
+ for (const [key, item] of Object.entries(value))
72
+ out[key] = propertyValue(item, `${name}.${key}`, true);
73
+ return out;
74
+ }
37
75
  const CHAT_ATTACHMENT_TYPES = ['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'application/pdf', 'text/plain'];
38
76
  /** Sohbet metni: boş olmayan, en çok 4000 karakter (sunucu kuralı). */
39
77
  function chatText(value) {
@@ -109,6 +147,48 @@ function preferenceArgs(input) {
109
147
  return { category, channel, optedIn: p.optedIn };
110
148
  });
111
149
  }
150
+ /** `login` profilini doğrular; etiket değerleri metne çevrilir, boş alanlar köprüye gönderilmez. */
151
+ function profileArgs(input) {
152
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
153
+ throw new TypeError('Pushizo: profile bir nesne olmalı.');
154
+ }
155
+ const out = {};
156
+ if (input.email !== undefined && input.email !== null)
157
+ out.email = requireString(input.email, 'profile.email');
158
+ if (input.sms !== undefined && input.sms !== null)
159
+ out.sms = requireString(input.sms, 'profile.sms');
160
+ if (input.tags !== undefined && input.tags !== null) {
161
+ const tags = stringRecord(input.tags, 'profile.tags');
162
+ if (Object.keys(tags).length > 0)
163
+ out.tags = tags;
164
+ }
165
+ if (input.aliases !== undefined && input.aliases !== null) {
166
+ const aliases = stringRecord(input.aliases, 'profile.aliases');
167
+ if (Object.keys(aliases).length > 0)
168
+ out.aliases = aliases;
169
+ }
170
+ return out;
171
+ }
172
+ /** Native rıza listesini eksik alanlara karşı normalize eder (`updatedAt` epoch milisaniye). */
173
+ function normalizeConsents(raw) {
174
+ if (!Array.isArray(raw))
175
+ return [];
176
+ const out = [];
177
+ for (const item of raw) {
178
+ if (item === null || typeof item !== 'object')
179
+ continue;
180
+ const c = item;
181
+ if (typeof c.purpose !== 'string' || c.purpose === '')
182
+ continue;
183
+ out.push({
184
+ purpose: c.purpose,
185
+ granted: c.granted === true,
186
+ source: typeof c.source === 'string' ? c.source : null,
187
+ updatedAt: typeof c.updatedAt === 'number' && Number.isFinite(c.updatedAt) ? c.updatedAt : null,
188
+ });
189
+ }
190
+ return out;
191
+ }
112
192
  function textMap(value) {
113
193
  const out = {};
114
194
  if (value === null || typeof value !== 'object' || Array.isArray(value))
@@ -122,6 +202,44 @@ function stringArray(value) {
122
202
  return Array.isArray(value) ? value.filter((v) => typeof v === 'string') : [];
123
203
  }
124
204
  /** Native tercih yanıtını eksik alanlara karşı normalize eder (zamanlar epoch milisaniye). */
205
+ const DELIVERY_SETTINGS = ['auto', 'notifications', 'auto_start', 'battery_optimization', 'app_details'];
206
+ function deliverySetting(value) {
207
+ if (value === undefined || value === null)
208
+ return 'auto';
209
+ if (!DELIVERY_SETTINGS.includes(value)) {
210
+ throw new TypeError(`Pushizo: setting ${DELIVERY_SETTINGS.join('|')} olmalı.`);
211
+ }
212
+ return value;
213
+ }
214
+ /** Native teslim durumu; `supported` true değilse (iOS, web, başlatılmamış SDK) "desteklenmiyor / risk yok" durumu. */
215
+ function normalizeDeliveryStatus(raw) {
216
+ const m = raw !== null && raw !== void 0 ? raw : {};
217
+ const supported = m.supported === true;
218
+ const text = (value, fallback) => (supported && typeof value === 'string' ? value : fallback);
219
+ // Native SDK'nın ileride ekleyeceği, bu sürümün tanımadığı ekran atlanır.
220
+ const recommendedSettings = supported
221
+ ? stringArray(m.recommendedSettings).filter((s) => s !== 'auto' && DELIVERY_SETTINGS.includes(s))
222
+ : [];
223
+ return {
224
+ supported,
225
+ manufacturer: text(m.manufacturer, ''),
226
+ brand: text(m.brand, ''),
227
+ vendor: text(m.vendor, 'other'),
228
+ aggressiveVendor: supported && m.aggressiveVendor === true,
229
+ rom: text(m.rom, ''),
230
+ romVersion: supported && typeof m.romVersion === 'string' ? m.romVersion : null,
231
+ notificationsEnabled: !supported || m.notificationsEnabled !== false,
232
+ channelBlocked: supported && m.channelBlocked === true,
233
+ batteryOptimizationExempt: !supported || m.batteryOptimizationExempt !== false,
234
+ backgroundRestricted: supported && m.backgroundRestricted === true,
235
+ standbyBucket: supported && typeof m.standbyBucket === 'string' ? m.standbyBucket : null,
236
+ powerSaveMode: supported && m.powerSaveMode === true,
237
+ dataSaverEnabled: supported && m.dataSaverEnabled === true,
238
+ restricted: supported && m.restricted === true,
239
+ risk: supported && (m.risk === 'high' || m.risk === 'elevated') ? m.risk : 'none',
240
+ recommendedSettings,
241
+ };
242
+ }
125
243
  function normalizePreferences(raw) {
126
244
  const preferences = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.preferences) ? raw.preferences : [];
127
245
  const categories = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.categories) ? raw.categories : [];
@@ -173,6 +291,8 @@ class PushizoCore {
173
291
  this.permissionObservers = new Set();
174
292
  this.inAppClickListeners = new Set();
175
293
  this.inAppLifecycleListeners = new Set();
294
+ this.featureFlagObservers = new Set();
295
+ this.inboxObservers = new Set();
176
296
  /** Dinleyici yokken gelen tıklamalar (soğuk başlatma); ilk dinleyiciye teslim edilir. */
177
297
  this.pendingClicks = [];
178
298
  /** Canlı sohbet dinleyicileri (tür başına). */
@@ -189,6 +309,8 @@ class PushizoCore {
189
309
  /** Dinleyici yokken gelen sohbet bildirimi tıklamaları (soğuk başlatma). */
190
310
  this.pendingChatOpens = [];
191
311
  this.foregroundFlag = false;
312
+ /** Native SDK başlatıldı mı (`initialize` tamamlandı ya da süreç saklanan yapılandırmayla erkenden başlatıldı). */
313
+ this.isInitialized = async () => { var _a; return Boolean((_a = (await this.bridge.call('isInitialized'))) === null || _a === void 0 ? void 0 : _a.initialized); };
192
314
  // --- Kullanıcı ---
193
315
  this.User = {
194
316
  addTag: (key, value) => this.bridge.call('addTags', { tags: stringRecord({ [requireString(key, 'key')]: value }, 'tags') }),
@@ -197,6 +319,11 @@ class PushizoCore {
197
319
  removeTags: (keys) => this.bridge.call('removeTags', { keys: keys.map((k) => requireString(k, 'key')) }),
198
320
  getTags: async () => { var _a; return (_a = (await this.bridge.call('getTags')).tags) !== null && _a !== void 0 ? _a : {}; },
199
321
  setLanguage: (code) => this.bridge.call('setLanguage', { code: requireString(code, 'code') }),
322
+ /**
323
+ * Kullanıcı özelliği yazar (ör. `setProperty('plan', 'pro')`); `null` özelliği siler. Değer metin, sayı, mantıksal ya da
324
+ * bunların dizisi/düz nesnesi olabilir; anahtar 1-64 karakterdir. Çevrimdışıyken yerel SDK kuyruğunda bekler.
325
+ */
326
+ setProperty: (key, value) => this.bridge.call('setUserProperty', { key: propertyKey(key), value: propertyValue(value, 'value') }),
200
327
  addAlias: (label, id) => this.bridge.call('addAliases', { aliases: { [requireString(label, 'label')]: requireString(id, 'id') } }),
201
328
  addAliases: (aliases) => this.bridge.call('addAliases', { aliases: stringRecord(aliases, 'aliases') }),
202
329
  removeAlias: (label) => this.bridge.call('removeAlias', { label: requireString(label, 'label') }),
@@ -217,6 +344,22 @@ class PushizoCore {
217
344
  getPreferences: async () => normalizePreferences(await this.bridge.call('getPreferences')),
218
345
  /** Tercihleri yazar (1-100 kayıt; `channel` verilmezse tüm kanallar); güncel listeyi döndürür. */
219
346
  setPreferences: async (preferences) => normalizePreferences(await this.bridge.call('setPreferences', { preferences: preferenceArgs(preferences) })),
347
+ /**
348
+ * Reklam kişiselleştirme rızası (ADR-0037): `true` iken kullanıcının e-posta/telefon özeti app'in bağladığı reklam
349
+ * platformu kitlelerine gönderilebilir; `false` rızayı geri alır. Güncel tercih listesini döndürür.
350
+ */
351
+ setAdsPersonalizationConsent: async (granted) => {
352
+ if (typeof granted !== 'boolean')
353
+ throw new TypeError('Pushizo: granted boolean olmalı.');
354
+ return normalizePreferences(await this.bridge.call('setAdsPersonalizationConsent', { granted }));
355
+ },
356
+ /** Rıza kayıtları (`ads_personalization` …). Abonelik henüz yoksa `NOT_READY` koduyla reddedilir. */
357
+ getConsents: async () => { var _a; return normalizeConsents((_a = (await this.bridge.call('getConsents'))) === null || _a === void 0 ? void 0 : _a.consents); },
358
+ /**
359
+ * Fire OS ADM kayıt kimliği (yalnızca Android; ana FCM aboneliğinin yerine geçmez). ADM kaydını kendisi yapan
360
+ * uygulamalar içindir. iOS ve web'de etkisizdir.
361
+ */
362
+ registerAdm: (token) => this.bridge.call('registerAdm', { token: requireString(token, 'token') }),
220
363
  pushSubscription: {
221
364
  getState: () => this.bridge.call('getPushSubscription'),
222
365
  getId: async () => { var _a; return (_a = (await this.bridge.call('getPushSubscription')).id) !== null && _a !== void 0 ? _a : null; },
@@ -252,6 +395,29 @@ class PushizoCore {
252
395
  },
253
396
  /** Aynı gruptaki bildirimleri kaldırır (Android `android_group`, iOS `thread-id`). */
254
397
  removeGroupedNotifications: (group) => this.bridge.call('removeGroupedNotifications', { group: requireString(group, 'group') }),
398
+ /**
399
+ * Uygulama rozetini ayarlar; rozet bu cihazda gösterilebiliyorsa true döner. iOS: rozet ve bildirim uzantısıyla
400
+ * paylaşılan sayaç ayarlanır (her zaman true). Android: başlatıcı rozeti için "sayıyı ayarla" API'si yoktur; yerel SDK
401
+ * sayıyı saklar ve sonraki bildirimlere yazar (Android 8 öncesinde, bildirimler ya da kanal rozeti kapalıyken false).
402
+ * Web: App Badging API (yüklü PWA); tarayıcı desteklemiyorsa false.
403
+ */
404
+ setBadgeCount: (count) => {
405
+ if (typeof count !== 'number' || !Number.isInteger(count) || count < 0) {
406
+ throw new RangeError('Pushizo: count negatif olmayan tam sayı olmalı.');
407
+ }
408
+ return this.badge(count);
409
+ },
410
+ /** Rozeti sıfırlar (`setBadgeCount(0)`); sonuç `setBadgeCount` ile aynıdır. */
411
+ clearBadge: () => this.badge(0),
412
+ /**
413
+ * Güncel rozet sayısı. Android: `setBadgeCount` ile saklanan son sayı; iOS: uygulama simgesindeki rozet; web: bu
414
+ * oturumda `setBadgeCount` ile başarıyla ayarlanan son sayı (tarayıcı rozeti okutmaz).
415
+ */
416
+ getBadgeCount: async () => {
417
+ var _a;
418
+ const count = (_a = (await this.bridge.call('getBadgeCount'))) === null || _a === void 0 ? void 0 : _a.count;
419
+ return typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 0;
420
+ },
255
421
  /** Bildirim/düğme tıklaması; soğuk başlatmada bekleyen tıklama ilk dinleyiciye teslim edilir. */
256
422
  addClickListener: (cb) => {
257
423
  const remove = this.listen(this.clickListeners, cb);
@@ -283,14 +449,25 @@ class PushizoCore {
283
449
  };
284
450
  // --- Oturum / olaylar ---
285
451
  this.Session = {
286
- /** Özel olay / outcome; in-app olay tetiklerini de değerlendirir. */
287
- sendEvent: (name, properties, value) => {
452
+ /**
453
+ * Özel olay / outcome; in-app olay tetiklerini de değerlendirir. `options.eventId` tekilleştirme kimliğidir
454
+ * (8-64 karakter; harf, rakam ve `. _ : -`): reklam pikseliyle aynı kimlik verilirse sunucu olayı tekilleşir
455
+ * (ADR-0038). Biçim geçersizse yerel SDK kendi kimliğini üretir.
456
+ */
457
+ sendEvent: (name, properties, value, options) => {
288
458
  const args = { name: requireString(name, 'name'), properties: properties !== null && properties !== void 0 ? properties : {} };
289
459
  if (value !== undefined && value !== null) {
290
460
  if (typeof value !== 'number' || !Number.isFinite(value))
291
461
  throw new TypeError('Pushizo: value sayı olmalı.');
292
462
  args.value = value;
293
463
  }
464
+ const eventId = options === null || options === void 0 ? void 0 : options.eventId;
465
+ if (eventId !== undefined && eventId !== null) {
466
+ if (typeof eventId !== 'string')
467
+ throw new TypeError('Pushizo: eventId metin olmalı.');
468
+ if (eventId !== '')
469
+ args.eventId = eventId;
470
+ }
294
471
  return this.bridge.call('sendEvent', args);
295
472
  },
296
473
  };
@@ -336,11 +513,36 @@ class PushizoCore {
336
513
  /** Öğeyi kutudan kaldırır (sunucuda arşivlenir). */
337
514
  archive: (id) => this.bridge.call('inboxArchive', { id: requireString(id, 'id') }),
338
515
  unreadCount: async () => { var _a; return (_a = (await this.bridge.call('inboxUnreadCount')).unreadCount) !== null && _a !== void 0 ? _a : 0; },
516
+ /**
517
+ * Kutu değişim gözlemcisi (rozet güncellemek için): `read`/`read_all`/`archived` her işlemde, `listed`/`count`
518
+ * yalnızca okunmamış sayısı değiştiğinde bildirilir. Dönen fonksiyon aboneliği kaldırır.
519
+ */
520
+ addObserver: (cb) => this.listen(this.inboxObservers, cb),
521
+ removeObserver: (cb) => {
522
+ this.inboxObservers.delete(cb);
523
+ },
524
+ };
525
+ // --- İçerik kartları (ADR-0082) ---
526
+ this.ContentCards = {
527
+ /** Kart akışı (sabitlenmiş → öncelik → yeni) ve görülmemiş kart sayısı; `limit` 1-100 (varsayılan 50). */
528
+ list: (limit = 50) => {
529
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
530
+ return Promise.reject(new RangeError('Pushizo: limit 1-100 olmalı.'));
531
+ }
532
+ return this.bridge.call('contentCardsList', { limit });
533
+ },
534
+ /** Kart ekranda gösterildi (ilk gösterim kaydedilir). */
535
+ logImpression: (id) => this.cardEvent(id, 'impression'),
536
+ /** Karta tıklandı (gösterim de sayılır). */
537
+ logClick: (id) => this.cardEvent(id, 'click'),
538
+ /** Kart kapatıldı; akıştan kalkar. */
539
+ dismiss: (id) => this.cardEvent(id, 'dismiss'),
339
540
  };
340
541
  // --- Canlı sohbet (ADR-0040) ---
341
542
  /**
342
543
  * Canlı sohbet (Android ve iOS): ziyaretçi kimliği, çevrimdışı kuyruk, canlı akış (SSE + yoklama yedeği) ve push ile
343
- * gelen mesajlar native SDK'dadır; login/logout ve push aboneliği değişince bağlama native SDK'da yenilenir.
544
+ * gelen mesajlar native SDK'dadır; login/logout ve push aboneliği değişince bağlama native SDK'da yenilenir. Hazır
545
+ * arayüz için `show()` / `hide()`; kendi arayüzünüz için diğer çağrılar ve olaylar.
344
546
  */
345
547
  this.Chat = {
346
548
  /** Sohbeti etkinleştirir ve ziyaretçiyi bağlar (giriş yapmış kullanıcı, push aboneliği); konuşma varsa döner. */
@@ -426,8 +628,23 @@ class PushizoCore {
426
628
  stopListening: () => this.bridge.call('chatStopListening'),
427
629
  /** Ek dosyasının adresi; ziyaretçi belirtecini taşır, yalnızca görsel bileşenine verin ve loglamayın. */
428
630
  attachmentUrl: async (attachmentId, download = false) => (await this.bridge.call('chatAttachmentUrl', { attachmentId: requireString(attachmentId, 'attachmentId'), download })).url,
631
+ /** Canlı dinleme açık mı (`startListening` çağrıldı ve akış etkin). */
632
+ isListening: async () => { var _a; return Boolean((_a = (await this.bridge.call('chatIsListening'))) === null || _a === void 0 ? void 0 : _a.listening); },
429
633
  /** Bu cihazın ziyaretçi kimliği (sohbet henüz kullanılmadıysa null). */
430
634
  getVisitorId: async () => { var _a; return (_a = (await this.bridge.call('chatGetVisitorId')).visitorId) !== null && _a !== void 0 ? _a : null; },
635
+ /**
636
+ * Hazır sohbet ekranını açar (Android `HsChatActivity`, iOS `HSChatViewController` modal; web: Web SDK sohbet
637
+ * widget'ı açık pencereyle). Ekran zaten açıksa yenisi açılmaz. `initialize` öncesinde `NOT_READY` ile reddedilir.
638
+ */
639
+ show: async () => {
640
+ await this.bridge.call('chatShow');
641
+ },
642
+ /** `show` ile açılan sohbet ekranını kapatır (açık değilse hiçbir şey yapmaz). */
643
+ hide: async () => {
644
+ await this.bridge.call('chatHide');
645
+ },
646
+ /** `show` ile açılan sohbet ekranı şu an açık mı. */
647
+ isPresented: async () => { var _a; return Boolean((_a = (await this.bridge.call('chatIsPresented'))) === null || _a === void 0 ? void 0 : _a.presented); },
431
648
  /** Sohbet olay dinleyicisi; kaldırma fonksiyonu döner. `open`: sohbet bildirimine tıklama. */
432
649
  addEventListener: (event, listener) => {
433
650
  const set = this.chatListeners[event];
@@ -467,6 +684,14 @@ class PushizoCore {
467
684
  const value = result === null || result === void 0 ? void 0 : result.value;
468
685
  return value === undefined || value === null ? defaultValue : value;
469
686
  },
687
+ /**
688
+ * Bayrak değerleri sunucudan her yenilendiğinde (oturum başı ve `refresh()`) çağrılır; güncel değerler `isEnabled` /
689
+ * `getValue` ile okunur. Dönen fonksiyon aboneliği kaldırır.
690
+ */
691
+ addObserver: (cb) => this.listen(this.featureFlagObservers, cb),
692
+ removeObserver: (cb) => {
693
+ this.featureFlagObservers.delete(cb);
694
+ },
470
695
  };
471
696
  // --- Gömülü yerleşimler (ADR-0068) ---
472
697
  /**
@@ -520,15 +745,102 @@ class PushizoCore {
520
745
  args.rationale = rationale;
521
746
  return Boolean((await this.bridge.call('requestLocationPermission', args)).permission);
522
747
  },
748
+ /**
749
+ * Ön plan konum izni verilmiş mi (Android yaklaşık/hassas, iOS "kullanırken" veya "her zaman"; web: tarayıcı konum
750
+ * izninin son bilinen durumu). İstem açmaz.
751
+ */
752
+ permissionGranted: async () => { var _a; return Boolean((_a = (await this.bridge.call('getLocationPermission'))) === null || _a === void 0 ? void 0 : _a.permission); },
753
+ /** Arka plan konum izni verilmiş mi (Android `ACCESS_BACKGROUND_LOCATION`, iOS "her zaman"). Web'de false. */
754
+ backgroundPermissionGranted: async () => { var _a; return Boolean((_a = (await this.bridge.call('getLocationPermission'))) === null || _a === void 0 ? void 0 : _a.background); },
755
+ /**
756
+ * Arka plan konum iznini ister (bölge izleme için). Android: açıklama diyaloğu (`rationale`; verilmezse SDK metni),
757
+ * ardından `ACCESS_BACKGROUND_LOCATION` (Android 11+ sistem Ayarlar ekranını açar; önce ön plan konum izni verilmiş
758
+ * olmalı). iOS: "her zaman" izni (`rationale` yok sayılır; önce "kullanırken" izni verilmiş olmalı). Sonuç: izin
759
+ * varsa veya verildiyse true; reddedildiyse, uygulama izni tanımlamadıysa veya vazgeçildiyse false. Web'de false.
760
+ */
761
+ requestBackgroundPermission: async (rationale) => {
762
+ if (rationale !== undefined && rationale !== null && typeof rationale !== 'string') {
763
+ throw new TypeError('Pushizo: rationale metin olmalı.');
764
+ }
765
+ const args = {};
766
+ if (typeof rationale === 'string' && rationale.trim() !== '')
767
+ args.rationale = rationale;
768
+ const result = await this.bridge.call('requestBackgroundLocationPermission', args);
769
+ return Boolean(result === null || result === void 0 ? void 0 : result.permission);
770
+ },
771
+ /** `requestBackgroundPermission` ile aynı izin (iOS adı: "her zaman"); iki ad da her platformda çalışır. */
772
+ requestAlwaysPermission: async () => {
773
+ var _a;
774
+ return Boolean((_a = (await this.bridge.call('requestBackgroundLocationPermission', {}))) === null || _a === void 0 ? void 0 : _a.permission);
775
+ },
523
776
  /**
524
777
  * Arka plan bölge izlemeyi açar/kapatır (ADR-0065; kalıcı, varsayılan kapalı). İzlemeyi işletim sistemi yapar,
525
- * sunucuya koordinat gitmez. `setShared(true)` ve arka plan konum izni gerekir; köprü izin istemez ve
526
- * manifest/Info.plist'e izin eklemez.
778
+ * sunucuya koordinat gitmez. `setShared(true)` ve arka plan konum izni gerekir (`requestBackgroundPermission`);
779
+ * köprü manifest/Info.plist'e izin eklemez.
527
780
  */
528
781
  setGeofencingEnabled: (enabled) => this.bridge.call('setGeofencingEnabled', { enabled: Boolean(enabled) }),
529
782
  /** Bölge izleme açık mı (kalıcı tercih; izin durumundan bağımsız). */
530
783
  isGeofencingEnabled: async () => { var _a; return Boolean((_a = (await this.bridge.call('isGeofencingEnabled'))) === null || _a === void 0 ? void 0 : _a.enabled); },
531
784
  };
785
+ // --- Reklam kimliği (ADR-0037) ---
786
+ /**
787
+ * Mobil reklam kimliği (Android GAID, iOS IDFA). SDK reklam kitaplığı ve izin istemi içermez: kimliği uygulama alır
788
+ * (Android `AdvertisingIdClient`, iOS App Tracking Transparency izninden sonra `ASIdentifierManager`) ve buraya verir.
789
+ * Kimlik reklam kitlesine yalnızca `ads_personalization` rızası olan kullanıcıda ve SHA-256 özetiyle gider.
790
+ */
791
+ this.Ads = {
792
+ /** Reklam kimliğini yazar; `null` veya sıfır kimlik sunucudaki kaydı siler. Web'de etkisizdir. */
793
+ setAdvertisingId: (id) => {
794
+ if (id !== null && id !== undefined && typeof id !== 'string') {
795
+ throw new TypeError('Pushizo: id metin veya null olmalı.');
796
+ }
797
+ return this.bridge.call('setAdvertisingId', { id: typeof id === 'string' && id.trim() !== '' ? id : null });
798
+ },
799
+ };
800
+ // --- Android teslimat güçlendirme (ADR-0092) ---
801
+ /**
802
+ * Android teslimat güçlendirme: bazı üreticilerin pil/otomatik başlatma yöneticisi arka plandaki uygulamayı durdurduğu
803
+ * için bildirimler gecikir ya da gelmez. Bu yüzey cihazdaki kısıtları okur ve kullanıcıyı ilgili ayar ekranına götürür.
804
+ * Yalnızca Android'de etkilidir: iOS ve web'de `status()` `supported: false` ve `risk: 'none'` döner, `openSettings` ile
805
+ * `showGuidance` hiçbir şey yapmadan `false` döner.
806
+ */
807
+ this.Delivery = {
808
+ /** Cihazın teslim durumu: üretici, ROM, pil muafiyeti, arka plan kısıtı, risk ve önerilen ayar ekranları. */
809
+ status: async () => normalizeDeliveryStatus(await this.bridge.call('deliveryStatus')),
810
+ /** Hazır açıklama diyaloğu şimdi gösterilmeli mi: teslim riski var ve diyalog son `minIntervalDays` günde gösterilmedi. */
811
+ shouldShowGuidance: async (minIntervalDays = 14) => {
812
+ if (!Number.isInteger(minIntervalDays) || minIntervalDays < 0) {
813
+ throw new RangeError('Pushizo: minIntervalDays negatif olmayan tam sayı olmalı.');
814
+ }
815
+ const result = await this.bridge.call('deliveryShouldShowGuidance', { minIntervalDays });
816
+ return Boolean(result === null || result === void 0 ? void 0 : result.show);
817
+ },
818
+ /**
819
+ * Ayar ekranını açar (`auto`: duruma en uygun ekran). Üreticiye özgü ekran bulunamazsa standart Android ekranına
820
+ * düşülür. Bir ekran açıldıysa true.
821
+ */
822
+ openSettings: async (setting = 'auto') => {
823
+ var _a;
824
+ const args = { setting: deliverySetting(setting) };
825
+ return Boolean((_a = (await this.bridge.call('deliveryOpenSettings', args))) === null || _a === void 0 ? void 0 : _a.opened);
826
+ },
827
+ /**
828
+ * Hazır açıklama diyaloğunu gösterir (22 dil; `message` verilirse SDK metni yerine o gösterilir). Kullanıcı kabul
829
+ * ederse `setting` ekranı açılır. Ayar ekranı açıldıysa true; kullanıcı vazgeçtiyse, ekran açılamadıysa ya da etkin
830
+ * Activity yoksa false. SDK diyaloğu kendiliğinden göstermez; uygun anı uygulama seçer (`shouldShowGuidance`).
831
+ */
832
+ showGuidance: async (options = {}) => {
833
+ var _a;
834
+ const message = options.message;
835
+ if (message !== undefined && message !== null && typeof message !== 'string') {
836
+ throw new TypeError('Pushizo: message metin olmalı.');
837
+ }
838
+ const args = { setting: deliverySetting(options.setting) };
839
+ if (typeof message === 'string' && message.trim() !== '')
840
+ args.message = message;
841
+ return Boolean((_a = (await this.bridge.call('deliveryShowGuidance', args))) === null || _a === void 0 ? void 0 : _a.opened);
842
+ },
843
+ };
532
844
  // --- Live Activities (iOS) ---
533
845
  /**
534
846
  * iOS Live Activities (ADR-0024; iOS 16.1+). Köprü genel `PushizoDefaultLiveActivityAttributes` türünü kullanır;
@@ -624,6 +936,24 @@ class PushizoCore {
624
936
  case 'chatOpen':
625
937
  this.onChatOpen((payload !== null && payload !== void 0 ? payload : {}));
626
938
  break;
939
+ case 'featureFlagsChange':
940
+ this.featureFlagObservers.forEach((l) => safeInvoke(l, undefined));
941
+ break;
942
+ case 'inboxChange': {
943
+ const raw = (payload !== null && payload !== void 0 ? payload : {});
944
+ const type = INBOX_CHANGE_TYPES.find((t) => t === raw.type);
945
+ if (!type)
946
+ return;
947
+ const event = {
948
+ type,
949
+ unreadCount: typeof raw.unreadCount === 'number' && Number.isFinite(raw.unreadCount) ? raw.unreadCount : 0,
950
+ };
951
+ // `itemId` yalnızca tek öğe olaylarında (`read`, `archived`) bulunur; Android `null` gönderir, iOS alanı göndermez.
952
+ if (typeof raw.itemId === 'string' && raw.itemId !== '')
953
+ event.itemId = raw.itemId;
954
+ this.inboxObservers.forEach((l) => safeInvoke(l, event));
955
+ break;
956
+ }
627
957
  default:
628
958
  break;
629
959
  }
@@ -712,16 +1042,20 @@ class PushizoCore {
712
1042
  }
713
1043
  /**
714
1044
  * Anonim kullanıcıyı kimlikli kullanıcıya bağlar. Identity verification açıksa app moduna göre `identityHash`
715
- * (eski imza: ikinci argüman metin) ve/veya JWT gerekir: `login(id, { jwt })`.
1045
+ * (eski imza: ikinci argüman metin) ve/veya JWT gerekir: `login(id, { jwt })`. `profile` verilirse e-posta, SMS,
1046
+ * etiket ve takma adlar aynı çağrıda ayarlanır: `login(id, { profile: { email: 'ali@ornek.com' } })`; geçersiz
1047
+ * e-posta veya telefon girişten önce `INVALID_ARGUMENT` ile reddedilir (yarım kalmış kimlik değişimi olmaz).
716
1048
  */
717
1049
  login(externalId, proof) {
718
1050
  requireString(externalId, 'externalId');
719
- const { identityHash, jwt } = typeof proof === 'string' ? { identityHash: proof } : (proof !== null && proof !== void 0 ? proof : {});
1051
+ const { identityHash, jwt, profile } = typeof proof === 'string' ? { identityHash: proof } : (proof !== null && proof !== void 0 ? proof : {});
720
1052
  const args = { externalId };
721
1053
  if (identityHash !== undefined && identityHash !== null)
722
1054
  args.identityHash = requireString(identityHash, 'identityHash');
723
1055
  if (jwt !== undefined && jwt !== null)
724
1056
  args.jwt = requireString(jwt, 'jwt');
1057
+ if (profile !== undefined && profile !== null)
1058
+ args.profile = profileArgs(profile);
725
1059
  return this.bridge.call('login', args);
726
1060
  }
727
1061
  /** Süresi dolan kimlik JWT'sini yeniler (giriş yapmış kullanıcı için); sonraki SDK istekleri yeni belirteci taşır. */
@@ -732,6 +1066,14 @@ class PushizoCore {
732
1066
  logout() {
733
1067
  return this.bridge.call('logout');
734
1068
  }
1069
+ /** Rozet çağrısı; yanıt vermeyen (eski) native katman başarılı sayılır. */
1070
+ async badge(count) {
1071
+ var _a;
1072
+ return ((_a = (await this.bridge.call('setBadgeCount', { count }))) === null || _a === void 0 ? void 0 : _a.success) !== false;
1073
+ }
1074
+ cardEvent(id, event) {
1075
+ return this.bridge.call('contentCardEvent', { id: requireString(id, 'id'), event });
1076
+ }
735
1077
  /** Native sohbet olayını türüne göre dağıtır. */
736
1078
  onChatEvent(raw) {
737
1079
  var _a, _b, _c;
@@ -19,6 +19,16 @@ export interface LoginOptions {
19
19
  identityHash?: string;
20
20
  /** SDK isteklerinde `Authorization: Bearer` başlığıyla gider; süresi dolunca `updateUserJwt` ile yenilenir. */
21
21
  jwt?: string;
22
+ /** Girişle birlikte ayarlanan profil; geçersiz e-posta veya telefon girişten önce `INVALID_ARGUMENT` ile reddedilir. */
23
+ profile?: UserProfile;
24
+ }
25
+ /** `Pushizo.login` ile tek çağrıda ayarlanan profil alanları (native `HsUserProfile`). */
26
+ export interface UserProfile {
27
+ email?: string;
28
+ /** E.164 biçiminde telefon numarası. */
29
+ sms?: string;
30
+ tags?: Record<string, InAppTriggerValue>;
31
+ aliases?: Record<string, string>;
22
32
  }
23
33
  /** Bildirim içeriği (native `HsNotification` / `HSNotification`). */
24
34
  export interface PushizoNotification {
@@ -103,6 +113,41 @@ export interface InboxPage {
103
113
  nextCursor: string | null;
104
114
  hasMore: boolean;
105
115
  }
116
+ /** İçerik kartı türü (ADR-0082). */
117
+ export type ContentCardType = 'classic' | 'captioned_image' | 'image_only';
118
+ /** İçerik kartı; zamanlar epoch milisaniyedir. Akış sabitlenmiş → öncelik → yeni sırasıyla gelir. */
119
+ export interface ContentCard {
120
+ id: string;
121
+ messageId: string | null;
122
+ type: ContentCardType;
123
+ title: string | null;
124
+ body: string | null;
125
+ url: string | null;
126
+ imageUrl: string | null;
127
+ buttonText: string | null;
128
+ data: Record<string, string>;
129
+ pinned: boolean;
130
+ priority: number;
131
+ viewed: boolean;
132
+ clicked: boolean;
133
+ expiresAt: number | null;
134
+ createdAt: number | null;
135
+ }
136
+ export interface ContentCardFeed {
137
+ cards: ContentCard[];
138
+ unviewedCount: number;
139
+ }
140
+ /** Kart olayı: gösterim, tıklama veya kapatma. */
141
+ export type ContentCardEvent = 'impression' | 'click' | 'dismiss';
142
+ /**
143
+ * `Inbox.addObserver` olayı (yerel `HsInboxChangeEvent` / `HSInboxChangeEvent`, Web SDK `InboxChangeEvent`).
144
+ * `itemId` yalnızca tek öğe olaylarında (`read`, `archived`) bulunur; `unreadCount` güncel okunmamış sayısıdır.
145
+ */
146
+ export interface InboxChangeEvent {
147
+ type: 'listed' | 'read' | 'read_all' | 'archived' | 'count';
148
+ itemId?: string;
149
+ unreadCount: number;
150
+ }
106
151
  export interface InboxListOptions {
107
152
  /** 1-200 (varsayılan 50). */
108
153
  limit?: number;
@@ -137,6 +182,15 @@ export interface UserPreferences {
137
182
  preferences: UserPreference[];
138
183
  categories: PreferenceCategory[];
139
184
  }
185
+ /** Rıza kaydı (`User.getConsents`; ADR-0037): `ads_personalization` gibi ayrılmış amaç anahtarları. */
186
+ export interface UserConsent {
187
+ purpose: string;
188
+ granted: boolean;
189
+ /** Kaydı yazan taraf (`sdk`, `api`, `dashboard` …); kayıt yoksa null. */
190
+ source: string | null;
191
+ /** Epoch milisaniye; kayıt yoksa null. */
192
+ updatedAt: number | null;
193
+ }
140
194
  /** `User.setPreferences` girdisi; `channel` verilmezse veya null ise tüm kanallar. */
141
195
  export interface PreferenceInput {
142
196
  category: string;
@@ -144,6 +198,18 @@ export interface PreferenceInput {
144
198
  channel?: PreferenceChannel | null;
145
199
  }
146
200
  export type InAppTriggerValue = string | number | boolean;
201
+ /**
202
+ * `User.setProperty` değeri: metin, sonlu sayı, mantıksal ya da bunların dizisi/düz nesnesi. En üstteki `null` özelliği
203
+ * siler; iç içe `null` kabul edilmez.
204
+ */
205
+ export type UserPropertyValue = string | number | boolean | null | UserPropertyValue[] | {
206
+ [key: string]: UserPropertyValue;
207
+ };
208
+ /** `Session.sendEvent` seçenekleri. */
209
+ export interface SendEventOptions {
210
+ /** Tekilleştirme kimliği: 8-64 karakter; harf, rakam ve `. _ : -`. Biçim geçersizse yerel SDK kendi kimliğini üretir. */
211
+ eventId?: string;
212
+ }
147
213
  /**
148
214
  * iOS Live Activity alan değeri (`PushizoDefaultLiveActivityAttributes.data` / `ContentState.data`): metin, sonlu
149
215
  * sayı veya mantıksal değer.
@@ -283,6 +349,60 @@ export interface PlacementListOptions {
283
349
  /** 1-10 (varsayılan 1). */
284
350
  limit?: number;
285
351
  }
352
+ /** Bildirim teslim riski (native Android `HsDeliveryRisk`). */
353
+ export type DeliveryRisk = 'none' | 'elevated' | 'high';
354
+ /**
355
+ * `Pushizo.Delivery.openSettings` / `showGuidance` ile açılabilen Android ayar ekranı: `auto` duruma en uygun ekran,
356
+ * `notifications` bildirim ayarları, `auto_start` üreticinin otomatik başlatma yöneticisi, `battery_optimization` pil
357
+ * optimizasyonu, `app_details` uygulama ayrıntıları.
358
+ */
359
+ export type DeliverySetting = 'auto' | 'notifications' | 'auto_start' | 'battery_optimization' | 'app_details';
360
+ /**
361
+ * Cihazın bildirim teslim durumu (`Pushizo.Delivery.status()`; native Android `HsDeliveryStatus`). Kişisel veri içermez.
362
+ * Yalnızca Android'de doludur: iOS'ta, web'de ve Android'de SDK başlatılmadan önce `supported` `false`, `risk` `none` ve
363
+ * `recommendedSettings` boştur.
364
+ */
365
+ export interface DeliveryStatus {
366
+ /** Teşhis bu platformda okunabildi mi. */
367
+ supported: boolean;
368
+ /** `Build.MANUFACTURER` (küçük harf). */
369
+ manufacturer: string;
370
+ /** `Build.BRAND` (küçük harf). */
371
+ brand: string;
372
+ /** Üretici ailesi: `xiaomi`, `huawei`, `honor`, `oppo`, `realme`, `oneplus`, `vivo`, `samsung`, `meizu`, `asus`, `transsion`, `other`. */
373
+ vendor: string;
374
+ /** Üreticinin kendi pil/otomatik başlatma yöneticisi arka plandaki uygulamaları durdurabiliyor mu. */
375
+ aggressiveVendor: boolean;
376
+ /** ROM kimliği: `miui`, `hyperos`, `emui`, `harmonyos`, `magicos`, `coloros`, `oxygenos`, `realmeui`, `funtouchos`, `originos`, `oneui`, `flyme`, `android`. */
377
+ rom: string;
378
+ romVersion: string | null;
379
+ /** Bildirim izni verilmiş ve bildirimler açık mı. */
380
+ notificationsEnabled: boolean;
381
+ /** Varsayılan bildirim kanalı kullanıcı tarafından kapatılmış mı. */
382
+ channelBlocked: boolean;
383
+ /** Uygulama pil optimizasyonundan muaf mı. */
384
+ batteryOptimizationExempt: boolean;
385
+ /** Kullanıcı arka plan etkinliğini kısıtlamış mı. */
386
+ backgroundRestricted: boolean;
387
+ /** Bekleme kovası: `exempted`, `active`, `working_set`, `frequent`, `rare`, `restricted` (okunamadıysa null). */
388
+ standbyBucket: string | null;
389
+ /** Pil tasarrufu kipi açık mı. */
390
+ powerSaveMode: boolean;
391
+ /** Veri tasarrufu uygulamanın arka plan verisini engelliyor mu. */
392
+ dataSaverEnabled: boolean;
393
+ /** Sistem arka plan kısıtı: kullanıcı kısıtlamış ya da uygulama `rare`/`restricted` kovasında. */
394
+ restricted: boolean;
395
+ risk: DeliveryRisk;
396
+ /** Kullanıcının açması önerilen ayar ekranları (önem sırasıyla; öneri yoksa boş). */
397
+ recommendedSettings: DeliverySetting[];
398
+ }
399
+ /** `Pushizo.Delivery.showGuidance` seçenekleri. */
400
+ export interface DeliveryGuidanceOptions {
401
+ /** Kullanıcı kabul edince açılacak ekran (varsayılan `auto`). */
402
+ setting?: DeliverySetting;
403
+ /** SDK'nın yerelleştirilmiş metni yerine gösterilecek açıklama. */
404
+ message?: string;
405
+ }
286
406
  export interface ChatAttachment {
287
407
  id: string;
288
408
  name: string;