cordova-plugin-pushizo 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,350 +1,402 @@
1
- <!-- pushizo:header -->
2
- <p align="center">
3
- <a href="https://pushizo.com"><img src="https://raw.githubusercontent.com/pushizo/.github/main/profile/assets/mark.svg" alt="Pushizo" width="56" height="56"></a>
4
- </p>
5
- <p align="center">
6
- <a href="https://docs.pushizo.com/docs/sdk/cordova"><img src="https://img.shields.io/badge/docs-docs.pushizo.com-5b4bdb" alt="Docs"></a>
7
- <a href="https://docs.pushizo.com/docs/api"><img src="https://img.shields.io/badge/API-reference-b44fc4" alt="API reference"></a>
8
- <a href="https://github.com/pushizo/pushizo-cordova/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-16130f" alt="License: MIT"></a>
9
- </p>
10
- <p align="center"><a href="#english">English</a> · <a href="#türkçe">Türkçe</a></p>
11
-
12
- ## English
13
-
14
- **Pushizo Cordova plugin** — Cordova plugin that wraps the native Pushizo Android and iOS SDKs through cordova.exec.
15
-
16
- > **Status:** Publishing to npm is in progress.<br>
17
- > **Durum:** npm yayını hazırlanıyor.
18
-
19
- **Install from GitHub until then · O zamana kadar GitHub'dan kurulum:**
20
-
21
- ```bash
22
- cordova plugin add https://github.com/pushizo/pushizo-cordova.git#v0.1.0
23
- ```
24
-
25
- **After publication · Yayından sonra:**
26
-
27
- ```bash
28
- cordova plugin add cordova-plugin-pushizo
29
- ```
30
-
31
- The detailed guide below is in Turkish; code samples are language-neutral. Full documentation:
32
- [docs.pushizo.com/docs/sdk/cordova](https://docs.pushizo.com/docs/sdk/cordova) · API reference: [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api).
33
-
34
- ## Türkçe
35
- <!-- /pushizo:header -->
36
-
37
- # cordova-plugin-pushizo
38
-
39
- Pushizo'nun Cordova eklentisi. Native Pushizo Android (`com.pushizo:pushizo-android`) ve iOS (`Pushizo` pod) SDK'larını `cordova.exec` köprüsüyle sarar. API yüzeyi plan 06 §6.1, eski sağlayıcı v5 ve `@pushizo/capacitor` ile aynıdır.
40
-
41
- - cordova ≥ 12, cordova-android ≥ 12 (minSdk 24), cordova-ios ≥ 7 (iOS 15+)
42
- - Push aboneliği (FCM/APNs), izin istemi ve izin gözlemcisi
43
- - Bildirim tıklaması (soğuk başlatma dahil), ön plan gösterimini engelleme/erteleme
44
- - Kullanıcı: `login`/`logout` (`identityHash`), tag, alias, dil, e-posta ve SMS aboneliği
45
- - In-app mesajlar (tetik, ekran, duraklatma, tıklama ve yaşam döngüsü olayları; native çizim)
46
- - Konum paylaşımı (yalnızca ön plan, açıklama + izin istemi)
47
- - Bildirim kutusu, özel olay, KVKK/GDPR gizlilik onayı, günlük seviyesi, bildirim tepsisini temizleme
48
-
49
- ## Kurulum
50
-
51
- ```bash
52
- cordova plugin add cordova-plugin-pushizo
53
- # monorepo içinden:
54
- cordova plugin add ../../sdk/cordova
55
- ```
56
-
57
- Eklenti JS'i `window.Pushizo` ve `window.plugins.Pushizo` olarak yüklenir. TypeScript için tipler pakettedir (`types/index.d.ts`).
58
-
59
- ## Kullanım
60
-
61
- ```js
62
- document.addEventListener('deviceready', async () => {
63
- // Tıklama dinleyicisini erken ekleyin; uygulama bildirimden açıldıysa tıklama ilk dinleyiciye teslim edilir.
64
- Pushizo.Notifications.addClickListener((event) => {
65
- console.log(event.notification.title, event.result.actionId, event.result.url);
66
- });
67
-
68
- await Pushizo.initialize('app_xxx', { apiUrl: 'https://api.pushizo.com', logLevel: 'warn' });
69
- await Pushizo.Notifications.requestPermission();
70
- await Pushizo.login('user_42'); // identity verification açıksa: login('user_42', identityHash)
71
- await Pushizo.User.addTags({ plan: 'pro', level: 3 });
72
- await Pushizo.User.addEmail('ali@pushizo.com');
73
- await Pushizo.Session.sendEvent('purchase', { sku: 'A1' }, 49.9);
74
- });
75
- ```
76
-
77
- Tüm metotlar Promise döndürür. Hatalar `PushizoError` örneğidir ve `code` alanı taşır: `INVALID_ARGUMENT`, `NOT_READY`, `NOT_FOUND`, `NOT_IMPLEMENTED` veya sunucu hata kodu.
78
-
79
- ### JWT ile kimlik doğrulama
80
-
81
- App ayarlarında kimlik doğrulama kipi (`identity_verification_mode`) `jwt` veya `both` ise kullanıcı, sunucunuzda
82
- imzalanmış kısa ömürlü bir ES256 JWT ile kimliklendirilir (talepler: `sub` = external_id, `aud` = app_id, `exp`/`iat` zorunlu, en çok 24 saat, yalnızca ES256).
83
-
84
- ```js
85
- await Pushizo.login('user_42', { jwt: jwtFromBackend }); // yalnızca JWT
86
- await Pushizo.login('user_42', { identityHash: hmac, jwt: jwtFromBackend }); // both kipinde ikisi birlikte
87
- await Pushizo.updateUserJwt(refreshedJwt); // süresi dolmadan yenileyin
88
- await Pushizo.logout();
89
- ```
90
-
91
- - JWT yerel SDK'da identity hash ile aynı kalıcı depoda saklanır ve tüm `/sdk/v1/...` isteklerinde
92
- `Authorization: Bearer <jwt>` başlığıyla gider; gövdeye/URL'ye yazılmaz, loglanmaz. `logout` belirteci siler.
93
- - `/config` yanıtında `identity_verification_required` true ise login öncesi kanıt denetlenir: `jwt` kipinde JWT, `hmac`
94
- kipinde `identityHash` zorunludur, `both` kipinde biri yeter; eksikse `login` `NOT_READY` ile reddedilir. Alan gelmeyen
95
- eski sunucularda kip `hmac` sayılır; ikinci argümanı metin olan eski `login(id, identityHash)` çağrıları aynen çalışır.
96
- - `updateUserJwt` giriş yapılmamışsa `NOT_READY` ile reddedilir; başarıda kuyrukta bekleyen işlemler yeni belirteçle
97
- yeniden denenir.
98
-
99
- ### Live Activities (iOS)
100
-
101
- Köprü, iOS SDK'nın genel `PushizoDefaultLiveActivityAttributes` türünü kullanır "Live Activities"). Sunucu etkinliği uzaktan başlatır (push-to-start, iOS 17.2+), günceller ve bitirir;
102
- yerel başlatma iOS 16.1+ ister.
103
-
104
- ```js
105
- await Pushizo.initialize('app_xxx');
106
- await Pushizo.LiveActivities.setupDefaultLiveActivity(); // her açılışta: belirteçler sunucuya kaydedilir
107
- await Pushizo.LiveActivities.startDefaultLiveActivity(
108
- 'order_42', // 1-100 karakter: harf, rakam, _ . : -
109
- { title: 'Sipariş #42' }, // attributes ('pushizo' anahtarı ayrılmıştır)
110
- { status: 'Yolda', eta: 12 }, // contentState
111
- );
112
- ```
113
-
114
- - Değerler metin, sonlu sayı veya boolean; anahtarlar 1-64 karakter. Kurala uymayan girdi köprüye gitmeden `TypeError`/
115
- `RangeError` fırlatır.
116
- - Hata kodları (`PushizoError.code`): `PLATFORM_NOT_SUPPORTED` (iOS 16.1 öncesi; Android'de her zaman), `NOT_READY`
117
- (`initialize` yok), `INVALID_ARGUMENT`, `LIVE_ACTIVITY_FAILED` (Live Activities kapalı, `NSSupportsLiveActivities` yok,
118
- sistem sınırı).
119
- - Xcode: uygulamanın Info.plist'ine `NSSupportsLiveActivities = YES` ekleyin; **Widget Extension** hedefi oluşturun ve
120
- hedefe SPM'de `PushizoExtension` ürününü (`import PushizoExtension`), CocoaPods'ta `pod 'Pushizo/Extension'`
121
- (`import Pushizo`) ekleyin:
122
-
123
- ```swift
124
- ActivityConfiguration(for: PushizoDefaultLiveActivityAttributes.self) { context in
125
- VStack {
126
- Text(context.attributes.data["title"]?.stringValue ?? "")
127
- Text(context.state.data["status"]?.description ?? "")
128
- }
129
- } dynamicIsland: { context in
130
- DynamicIsland { DynamicIslandExpandedRegion(.center) { Text(context.state.data["status"]?.description ?? "") } }
131
- compactLeading: { EmptyView() } compactTrailing: { Text(context.state.data["eta"]?.description ?? "") } minimal: { EmptyView() }
132
- }
133
- ```
134
-
135
- - Dashboard'da (**Live Activities**) veya API'de tür adı tam olarak `PushizoDefaultLiveActivityAttributes` olmalıdır.
136
- Sunucu: `POST /v1/apps/{appId}/live-activities/PushizoDefaultLiveActivityAttributes/start` (`activity_id`,
137
- `attributes`, `content_state`, `target`), `…/update` ve `…/end` (`activity_id`, `content_state`).
138
- - Tip-güvenli kendi türünüz için native tarafta `Pushizo.LiveActivities.register(MyAttributes.self)` kullanın.
139
-
140
- ### Canlı sohbet
141
-
142
- ```ts
143
- await Pushizo.Chat.start({ name: 'Ali' });
144
- const config = await Pushizo.Chat.getConfig(); // online, offlineMessage, ek sınırları
145
- const { messages } = await Pushizo.Chat.getMessages();
146
- Pushizo.Chat.addEventListener('message', ({ message }) => render(message));
147
- Pushizo.Chat.addEventListener('open', ({ conversationId }) => openChat(conversationId)); // bildirime tıklama
148
- await Pushizo.Chat.startListening(); // ekran açıkken; ayrılınca stopListening()
149
- await Pushizo.Chat.sendMessage('Merhaba'); // bot hızlı yanıtı: sendMessage(label, { optionId })
150
- await Pushizo.Chat.sendAttachment({ base64 }, { fileName: 'a.png', mimeType: 'image/png' });
151
- await Pushizo.Chat.markRead(messages[messages.length - 1].seq);
152
- ```
153
-
154
- Ziyaretçi kimliği, çevrimdışı kuyruk (aynı `client_message_id` ile yeniden deneme), canlı akış (SSE; koparsa üstel
155
- geri çekilme + `after_seq` yoklaması) ve push ile gelen temsilci mesajları (`pushizo_chat`) yerel Android/iOS SDK'sındadır;
156
- `start` sonrası login/logout ve push aboneliği değişince bağlama yerel SDK'da yenilenir, logout ziyaretçiyi sıfırlar.
157
- Mesajlar `seq` ile sıralanır; ağ yokken gönderilen mesaj `pending` döner ve gönderilince olayla sunucu kopyası gelir.
158
- Ayrıntı: [android rehberi](https://docs.pushizo.com/docs/sdk/android) / [ios rehberi](https://docs.pushizo.com/docs/sdk/ios) → "Canlı sohbet".
159
-
160
- ### Konum
161
-
162
- Kullanıcı izin verirse cihazın konumu push aboneliğine yazılır; segmentlerde konuma göre hedefleme için
163
- kullanılır. Paylaşım **yalnızca ön planda** çalışır (arka plan konumu yok): native SDK konumu oturum başında ve uygulama
164
- ön plana döndüğünde en sık 5 dakikada bir gönderir. İzin yoksa veya gizlilik onayı (`requiresPrivacyConsent`)
165
- verilmemişse hiçbir şey gönderilmez; tercih kalıcıdır.
166
-
167
- ```js
168
- const granted = await Pushizo.Location.requestPermission('Yakındaki mağazaları göstermek için konumunuzu kullanırız.');
169
- if (granted) await Pushizo.Location.setShared(true);
170
- const shared = await Pushizo.Location.isShared(); // kalıcı tercih (izin durumundan bağımsız)
171
- await Pushizo.Location.setShared(false); // paylaşımı kapatır, sunucudaki konumu siler
172
- ```
173
-
174
- - `requestPermission(rationale?)`: izin yoksa önce açıklama gösterilir (`rationale`; verilmezse SDK'nın Türkçe/İngilizce
175
- varsayılan metni), kullanıcı "Şimdi değil" derse sistem istemi açılmaz. İzin varsa veya verildiyse `true`; reddedildiyse,
176
- uygulama izni tanımlamadıysa ya da vazgeçildiyse `false`. `isShared()` native SDK'daki özelliğin asenkron karşılığıdır.
177
- - `initialize` öncesinde `setShared`/`requestPermission` `NOT_READY` koduyla reddedilir.
178
- - **KVKK:** sunucuya ulaşan ilk konum açık rıza kaydı olarak saklanır. Kullanıcıya konumun neden kullanıldığını
179
- açıklayın ve paylaşımı yalnızca onayıyla açın. `setShared(false)` sunucuya `location: null` gönderir; konum ve rıza
180
- kaydı silinir, henüz gönderilmemiş konum atılır.
181
- - **iOS:** `Info.plist` dosyasına `NSLocationWhenInUseUsageDescription` ekleyin (yoksa `requestPermission` `false` döner);
182
- `config.xml` içinde `<platform name="ios">` altına
183
- `<edit-config file="*-Info.plist" target="NSLocationWhenInUseUsageDescription" mode="merge"><string>…</string></edit-config>`. Yalnızca "Uygulamayı Kullanırken" izni istenir; "Her Zaman" istenmez. Reddedilmiş izin yeniden
184
- sorulamaz, kullanıcı Ayarlar'a yönlendirilmelidir.
185
- - **Android:** eklenti konum iznini manifest'e **otomatik eklemez**; uygulamanın `config.xml` dosyasına kendiniz ekleyin
186
- (yaklaşık konum yeterlidir, hassas konum isteğe bağlıdır; `<widget>` öğesinde
187
- `xmlns:android="http://schemas.android.com/apk/res/android"` tanımlı olmalıdır):
188
-
189
- ```xml
190
- <platform name="android">
191
- <config-file target="AndroidManifest.xml" parent="/manifest">
192
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
193
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
194
- </config-file>
195
- </platform>
196
- ```
197
-
198
- Yalnızca manifest'te tanımlı izinler istenir; hiçbiri yoksa uyarı loglanır ve `false` döner. Açıklama diyaloğu SDK'nın
199
- string kaynaklarını kullanır; sistem izni `cordova.requestPermissions` ile (`Pushizo.Location.PERMISSION_REQUEST_CODE`)
200
- istenir ve sonuç SDK'ya iletilir.
201
-
202
- ### Olaylar
203
-
204
- ```js
205
- Pushizo.Notifications.addForegroundLifecycleListener((event) => {
206
- event.preventDefault(); // ön planda gösterme; sonra göstermek için: event.display()
207
- });
208
- Pushizo.Notifications.addPermissionObserver(({ permission }) => {});
209
- Pushizo.User.pushSubscription.addObserver((state) => {}); // { id, token, optedIn, permission }
210
- Pushizo.InAppMessages.addClickListener((e) => {}); // { message: { id }, result: { actionId, url } }
211
- Pushizo.InAppMessages.addLifecycleListener({ willDisplay() {}, didDismiss() {} });
212
- ```
213
-
214
- `addPermissionObserver` olayları yerel Android/iOS SDK izin gözlemcisinden gelir (izin isteği sonucu ve uygulama ön plana
215
- döndüğünde ayarlardan yapılan değişiklik; yalnızca gerçek değişiklikte).
216
-
217
- Her `add…` çağrısı aboneliği kaldıran bir fonksiyon döndürür. Olaylar native taraftan tek bir `keepCallback` kanalıyla gelir; kanal açılmadan oluşan olaylar (ör. soğuk başlatma tıklaması) native tarafta tamponlanır.
218
-
219
- ### In-app, bildirim kutusu ve diğerleri
220
-
221
- ```js
222
- await Pushizo.InAppMessages.addTrigger('level', 5);
223
- await Pushizo.InAppMessages.setScreen('checkout');
224
- await Pushizo.InAppMessages.setPaused(false);
225
-
226
- const page = await Pushizo.Inbox.list({ limit: 20 }); // { items, unreadCount, nextCursor, hasMore }
227
- await Pushizo.Inbox.markRead(page.items[0].id);
228
- await Pushizo.Inbox.markAllRead();
229
- await Pushizo.Inbox.archive(page.items[0].id);
230
-
231
- // Tercihler (kategori × kanal opt-in; channel verilmezse tüm kanallar). Abonelik yoksa NOT_READY.
232
- const { preferences, categories } = await Pushizo.User.getPreferences();
233
- await Pushizo.User.setPreferences([
234
- { category: 'promo', optedIn: false },
235
- { category: 'news', channel: 'email', optedIn: true },
236
- ]); // güncel listeyi döndürür
237
-
238
- await Pushizo.Notifications.clearAll();
239
- await Pushizo.Notifications.removeGroupedNotifications('orders');
240
- await Pushizo.Notifications.removeNotification(id); // Android: notification.androidNotificationId; iOS: UNNotificationRequest.identifier (metin)
241
- await Pushizo.setConsentGiven(true); // requiresPrivacyConsent: true ile başlatıldıysa
242
- await Pushizo.Debug.setLogLevel('debug');
243
- await Pushizo.logout();
244
- ```
245
-
246
- ### HTML in-app ve carousel
247
-
248
- In-app mesajları yerel Android/iOS SDK'sı çizer; bu paket köprüdür. HTML in-app (sandbox'lı WebView, köprü
249
- `close`/`click`/`addTag`/`trackEvent`) ve carousel blokları yerel SDK'dan olduğu gibi devralınır: ek kod veya
250
- yapılandırma gerekmez, tıklama ve yaşam döngüsü olayları mevcut in-app dinleyicilerine gelir. Yetenek bildirimi
251
- (`supports=html,carousel`) yerel SDK tarafından yapılır; desteklemeyen eski yerel sürümlere sunucu HTML mesaj göndermez
252
- ve carousel bloklarını çıkarır.
253
-
254
- ## Android kurulumu (FCM)
255
-
256
- 1. Firebase konsolunda Android uygulaması ekleyin; `google-services.json` dosyasını proje köküne koyun ve `config.xml` içine ekleyin:
257
-
258
- ```xml
259
- <platform name="android">
260
- <preference name="GradlePluginKotlinEnabled" value="true" />
261
- <preference name="GradlePluginGoogleServicesEnabled" value="true" />
262
- <preference name="GradlePluginGoogleServicesVersion" value="4.4.2" />
263
- <resource-file src="google-services.json" target="app/google-services.json" />
264
- </platform>
265
- ```
266
-
267
- Köprü Kotlin ile yazıldığından `GradlePluginKotlinEnabled` zorunludur.
268
- 2. Pushizo dashboard'unda Firebase servis hesabı JSON'unu yükleyin (kurulum sihirbazında **Cordova** seçilebilir); kayıt sonrası otomatik doğrulanır.
269
- 3. Eklenti `com.pushizo:pushizo-android` artefaktına bağlıdır. Maven Central yayınına kadar `sdk/android` içinde `gradle :pushizo:publishToMavenLocal` çalıştırın; eklenti `mavenLocal()` deposunu ekler.
270
- 4. FCM servisi, `POST_NOTIFICATIONS` izni ve bildirim Activity'si SDK manifestinden birleşir. Bildirim ikonu için `AndroidManifest.xml` içinde `com.pushizo.sdk.default_notification_icon` meta-data'sı verilebilir.
271
-
272
- Eklenti, JS ile yapılan `initialize` ayarlarını (yalnızca uygulama kimliği ve herkese açık ayarlar) saklar; süreç bildirim tıklaması veya FCM mesajıyla yeniden başladığında SDK WebView yüklenmeden başlatılır.
273
-
274
- ## iOS kurulumu (APNs)
275
-
276
- 1. `config.xml`:
277
-
278
- ```xml
279
- <platform name="ios">
280
- <preference name="deployment-target" value="15.0" />
281
- <preference name="SwiftVersion" value="5" />
282
- </platform>
283
- ```
284
-
285
- 2. Eklenti Push Notifications yetkisini (`aps-environment`) ve `remote-notification` arka plan modunu ekler. Pushizo dashboard'unda APNs `.p8` anahtarını veya `.p12` sertifikasını yükleyin.
286
- 3. `Pushizo` pod'u yayınlanana kadar `platforms/ios/Podfile` içinde `pod 'Pushizo', :path => '<repo>/sdk/ios'` kullanın ve `pod install` çalıştırın.
287
- 4. APNs token geri çağrıları (`didRegisterForRemoteNotificationsWithDeviceToken`/`didFailToRegister…`) eklenti yüklenirken AppDelegate sınıfına çalışma zamanında eklenir; AppDelegate'te bu metotlar varsa önce SDK'ya iletilir, sonra sizin kodunuz çalışır.
288
- 5. Pushizo SDK'sı `UNUserNotificationCenter` delegesini üstlenir; başka bir push eklentisiyle (ör. `cordova-plugin-firebasex`) birlikte kullanmayın.
289
-
290
- ### Notification Service Extension (zengin medya, teslim bildirimi)
291
-
292
- Resimli bildirimler, rozet artışı ve uygulama kapalıyken `received` bildirimi için Xcode'da (`platforms/ios/*.xcworkspace`) **File → New → Target → Notification Service Extension** ekleyin (iOS 15), Podfile'a hedefi ekleyin:
293
-
294
- ```ruby
295
- target 'PushizoNSE' do
296
- pod 'Pushizo/Extension', :path => '<repo>/sdk/ios'
297
- end
298
- ```
299
-
300
- ve `NotificationService.swift` dosyasını SDK yardımcısına devredin:
301
-
302
- ```swift
303
- import UserNotifications
304
- import Pushizo
305
-
306
- class NotificationService: UNNotificationServiceExtension {
307
- let hs = PushizoNotificationServiceExtension(appId: "app_xxx", apiUrl: "https://api.pushizo.com",
308
- appGroup: "group.com.pushizo.app.pushizo")
309
-
310
- override func didReceive(_ request: UNNotificationRequest, withContentHandler handler: @escaping (UNNotificationContent) -> Void) {
311
- hs.didReceive(request, withContentHandler: handler)
312
- }
313
-
314
- override func serviceExtensionTimeWillExpire() { hs.serviceExtensionTimeWillExpire() }
315
- }
316
- ```
317
-
318
- Uygulama ve NSE hedeflerinde aynı App Group yeteneğini açın ve uygulamanın `Info.plist` dosyasına `PushizoAppGroup` anahtarıyla yazın (rozet sayacı paylaşımı). `cordova platform rm/add ios` Xcode projesini yeniden oluşturduğundan NSE hedefi yeniden eklenmelidir.
319
-
320
- ## Geliştirme
321
-
322
- ```bash
323
- npm install
324
- npm run typecheck
325
- npm test # vitest: cephe, cordova.exec köprüsü ve native sözleşme denetimi
326
- npm run build # src/*.ts → www/*.js (eklentiyle birlikte yayınlanır, depoda tutulur)
327
- ```
328
-
329
- Adım adım kurulum ve örnek kod: [cordova rehberi](https://docs.pushizo.com/docs/sdk/cordova).
330
-
331
- <!-- pushizo:footer -->
332
- ---
333
-
334
- ## Support · Destek
335
-
336
- - **Guide · Rehber:** [docs.pushizo.com/docs/sdk/cordova](https://docs.pushizo.com/docs/sdk/cordova)
337
- - **API reference & OpenAPI · API referansı ve OpenAPI:** [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api) ·
338
- [pushizo-openapi](https://github.com/pushizo/pushizo-openapi)
339
- - **Bugs & ideas · Hata ve öneri:** [Issues](https://github.com/pushizo/pushizo-cordova/issues)
340
- - **Security · Güvenlik:** please do not open public issues; email [security@pushizo.com](mailto:security@pushizo.com) ·
341
- herkese açık issue açmayın, bu adrese yazın.
342
- - **Help · Destek:** [support@pushizo.com](mailto:support@pushizo.com)
343
-
344
- This repository is mirrored automatically from the Pushizo main repository on every release. Please open an issue
345
- instead of a pull request; fixes land in the main repository and ship with the next release.
346
- Bu depo her sürümde Pushizo ana deposundan otomatik yansıtılır. Pull request yerine issue açın; düzeltmeler ana depoda
347
- yapılır ve bir sonraki sürümle buraya gelir.
348
-
349
- Released under the MIT License · MIT lisanslıdır — [LICENSE](https://github.com/pushizo/pushizo-cordova/blob/main/LICENSE).
350
- <!-- /pushizo:footer -->
1
+ <!-- pushizo:header -->
2
+ <p align="center">
3
+ <a href="https://pushizo.com"><img src="https://raw.githubusercontent.com/pushizo/.github/main/profile/assets/mark.svg" alt="Pushizo" width="56" height="56"></a>
4
+ </p>
5
+ <p align="center">
6
+ <a href="https://docs.pushizo.com/docs/sdk/cordova"><img src="https://img.shields.io/badge/docs-docs.pushizo.com-5b4bdb" alt="Docs"></a>
7
+ <a href="https://docs.pushizo.com/docs/api"><img src="https://img.shields.io/badge/API-reference-b44fc4" alt="API reference"></a>
8
+ <a href="https://github.com/pushizo/pushizo-cordova/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-16130f" alt="License: MIT"></a>
9
+ </p>
10
+ <p align="center"><a href="#english">English</a> · <a href="#türkçe">Türkçe</a></p>
11
+
12
+ ## English
13
+
14
+ **Pushizo Cordova plugin** — Cordova plugin that wraps the native Pushizo Android and iOS SDKs through cordova.exec.
15
+
16
+ ```bash
17
+ cordova plugin add cordova-plugin-pushizo
18
+ ```
19
+
20
+ The detailed guide below is in Turkish; code samples are language-neutral. Full documentation:
21
+ [docs.pushizo.com/docs/sdk/cordova](https://docs.pushizo.com/docs/sdk/cordova) · API reference: [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api).
22
+
23
+ ## Türkçe
24
+ <!-- /pushizo:header -->
25
+
26
+ # cordova-plugin-pushizo
27
+
28
+ Pushizo'nun Cordova eklentisi. Native Pushizo Android (`com.pushizo:pushizo-android`) ve iOS (`Pushizo` pod) SDK'larını `cordova.exec` köprüsüyle sarar. API yüzeyi plan 06 §6.1, eski sağlayıcı v5 ve `@pushizo/capacitor` ile aynıdır.
29
+
30
+ - cordova ≥ 12, cordova-android ≥ 12 (minSdk 24), cordova-ios ≥ 7 (iOS 15+)
31
+ - Push aboneliği (FCM/APNs), izin istemi ve izin gözlemcisi
32
+ - Bildirim tıklaması (soğuk başlatma dahil), ön plan gösterimini engelleme/erteleme
33
+ - Kullanıcı: `login`/`logout` (`identityHash`), tag, alias, dil, e-posta ve SMS aboneliği
34
+ - In-app mesajlar (tetik, ekran, duraklatma, tıklama ve yaşam döngüsü olayları; native çizim)
35
+ - Konum paylaşımı (yalnızca ön plan, açıklama + izin istemi) ve arka plan bölge izleme
36
+ - Özellik bayrakları (`FeatureFlags`) ve gömülü yerleşimler (`Placements`)
37
+ - Bildirim kutusu, özel olay, KVKK/GDPR gizlilik onayı, günlük seviyesi, bildirim tepsisini temizleme
38
+
39
+ ## Kurulum
40
+
41
+ ```bash
42
+ cordova plugin add cordova-plugin-pushizo
43
+ # monorepo içinden:
44
+ cordova plugin add ../../sdk/cordova
45
+ ```
46
+
47
+ Eklenti JS'i `window.Pushizo` ve `window.plugins.Pushizo` olarak yüklenir. TypeScript için tipler pakettedir (`types/index.d.ts`).
48
+
49
+ ## Kullanım
50
+
51
+ ```js
52
+ document.addEventListener('deviceready', async () => {
53
+ // Tıklama dinleyicisini erken ekleyin; uygulama bildirimden açıldıysa tıklama ilk dinleyiciye teslim edilir.
54
+ Pushizo.Notifications.addClickListener((event) => {
55
+ console.log(event.notification.title, event.result.actionId, event.result.url);
56
+ });
57
+
58
+ await Pushizo.initialize('app_xxx', { apiUrl: 'https://api.pushizo.com', logLevel: 'warn' });
59
+ await Pushizo.Notifications.requestPermission();
60
+ await Pushizo.login('user_42'); // identity verification açıksa: login('user_42', identityHash)
61
+ await Pushizo.User.addTags({ plan: 'pro', level: 3 });
62
+ await Pushizo.User.addEmail('ali@pushizo.com');
63
+ await Pushizo.Session.sendEvent('purchase', { sku: 'A1' }, 49.9);
64
+ });
65
+ ```
66
+
67
+ Tüm metotlar Promise döndürür. Hatalar `PushizoError` örneğidir ve `code` alanı taşır: `INVALID_ARGUMENT`, `NOT_READY`, `NOT_FOUND`, `NOT_IMPLEMENTED` veya sunucu hata kodu.
68
+
69
+ ### JWT ile kimlik doğrulama
70
+
71
+ App ayarlarında kimlik doğrulama kipi (`identity_verification_mode`) `jwt` veya `both` ise kullanıcı, sunucunuzda
72
+ imzalanmış kısa ömürlü bir ES256 JWT ile kimliklendirilir (talepler: `sub` = external_id, `aud` = app_id, `exp`/`iat` zorunlu, en çok 24 saat, yalnızca ES256).
73
+
74
+ ```js
75
+ await Pushizo.login('user_42', { jwt: jwtFromBackend }); // yalnızca JWT
76
+ await Pushizo.login('user_42', { identityHash: hmac, jwt: jwtFromBackend }); // both kipinde ikisi birlikte
77
+ await Pushizo.updateUserJwt(refreshedJwt); // süresi dolmadan yenileyin
78
+ await Pushizo.logout();
79
+ ```
80
+
81
+ - JWT yerel SDK'da identity hash ile aynı kalıcı depoda saklanır ve tüm `/sdk/v1/...` isteklerinde
82
+ `Authorization: Bearer <jwt>` başlığıyla gider; gövdeye/URL'ye yazılmaz, loglanmaz. `logout` belirteci siler.
83
+ - `/config` yanıtında `identity_verification_required` true ise login öncesi kanıt denetlenir: `jwt` kipinde JWT, `hmac`
84
+ kipinde `identityHash` zorunludur, `both` kipinde biri yeter; eksikse `login` `NOT_READY` ile reddedilir. Alan gelmeyen
85
+ eski sunucularda kip `hmac` sayılır; ikinci argümanı metin olan eski `login(id, identityHash)` çağrıları aynen çalışır.
86
+ - `updateUserJwt` giriş yapılmamışsa `NOT_READY` ile reddedilir; başarıda kuyrukta bekleyen işlemler yeni belirteçle
87
+ yeniden denenir.
88
+
89
+ ### Live Activities (iOS)
90
+
91
+ Köprü, iOS SDK'nın genel `PushizoDefaultLiveActivityAttributes` türünü kullanır "Live Activities"). Sunucu etkinliği uzaktan başlatır (push-to-start, iOS 17.2+), günceller ve bitirir;
92
+ yerel başlatma iOS 16.1+ ister.
93
+
94
+ ```js
95
+ await Pushizo.initialize('app_xxx');
96
+ await Pushizo.LiveActivities.setupDefaultLiveActivity(); // her açılışta: belirteçler sunucuya kaydedilir
97
+ await Pushizo.LiveActivities.startDefaultLiveActivity(
98
+ 'order_42', // 1-100 karakter: harf, rakam, _ . : -
99
+ { title: 'Sipariş #42' }, // attributes ('pushizo' anahtarı ayrılmıştır)
100
+ { status: 'Yolda', eta: 12 }, // contentState
101
+ );
102
+ ```
103
+
104
+ - Değerler metin, sonlu sayı veya boolean; anahtarlar 1-64 karakter. Kurala uymayan girdi köprüye gitmeden `TypeError`/
105
+ `RangeError` fırlatır.
106
+ - Hata kodları (`PushizoError.code`): `PLATFORM_NOT_SUPPORTED` (iOS 16.1 öncesi; Android'de her zaman), `NOT_READY`
107
+ (`initialize` yok), `INVALID_ARGUMENT`, `LIVE_ACTIVITY_FAILED` (Live Activities kapalı, `NSSupportsLiveActivities` yok,
108
+ sistem sınırı).
109
+ - Xcode: uygulamanın Info.plist'ine `NSSupportsLiveActivities = YES` ekleyin; **Widget Extension** hedefi oluşturun ve
110
+ hedefe SPM'de `PushizoExtension` ürününü (`import PushizoExtension`), CocoaPods'ta `pod 'Pushizo/Extension'`
111
+ (`import Pushizo`) ekleyin:
112
+
113
+ ```swift
114
+ ActivityConfiguration(for: PushizoDefaultLiveActivityAttributes.self) { context in
115
+ VStack {
116
+ Text(context.attributes.data["title"]?.stringValue ?? "")
117
+ Text(context.state.data["status"]?.description ?? "")
118
+ }
119
+ } dynamicIsland: { context in
120
+ DynamicIsland { DynamicIslandExpandedRegion(.center) { Text(context.state.data["status"]?.description ?? "") } }
121
+ compactLeading: { EmptyView() } compactTrailing: { Text(context.state.data["eta"]?.description ?? "") } minimal: { EmptyView() }
122
+ }
123
+ ```
124
+
125
+ - Dashboard'da (**Live Activities**) veya API'de tür adı tam olarak `PushizoDefaultLiveActivityAttributes` olmalıdır.
126
+ Sunucu: `POST /v1/apps/{appId}/live-activities/PushizoDefaultLiveActivityAttributes/start` (`activity_id`,
127
+ `attributes`, `content_state`, `target`), `…/update` ve `…/end` (`activity_id`, `content_state`).
128
+ - Tip-güvenli kendi türünüz için native tarafta `Pushizo.LiveActivities.register(MyAttributes.self)` kullanın.
129
+
130
+ ### Canlı sohbet
131
+
132
+ ```ts
133
+ await Pushizo.Chat.start({ name: 'Ali' });
134
+ const config = await Pushizo.Chat.getConfig(); // online, offlineMessage, ek sınırları
135
+ const { messages } = await Pushizo.Chat.getMessages();
136
+ Pushizo.Chat.addEventListener('message', ({ message }) => render(message));
137
+ Pushizo.Chat.addEventListener('open', ({ conversationId }) => openChat(conversationId)); // bildirime tıklama
138
+ await Pushizo.Chat.startListening(); // ekran açıkken; ayrılınca stopListening()
139
+ await Pushizo.Chat.sendMessage('Merhaba'); // bot hızlı yanıtı: sendMessage(label, { optionId })
140
+ await Pushizo.Chat.sendAttachment({ base64 }, { fileName: 'a.png', mimeType: 'image/png' });
141
+ await Pushizo.Chat.markRead(messages[messages.length - 1].seq);
142
+ ```
143
+
144
+ Ziyaretçi kimliği, çevrimdışı kuyruk (aynı `client_message_id` ile yeniden deneme), canlı akış (SSE; koparsa üstel
145
+ geri çekilme + `after_seq` yoklaması) ve push ile gelen temsilci mesajları (`pushizo_chat`) yerel Android/iOS SDK'sındadır;
146
+ `start` sonrası login/logout ve push aboneliği değişince bağlama yerel SDK'da yenilenir, logout ziyaretçiyi sıfırlar.
147
+ Mesajlar `seq` ile sıralanır; ağ yokken gönderilen mesaj `pending` döner ve gönderilince olayla sunucu kopyası gelir.
148
+ Ayrıntı: [android rehberi](https://docs.pushizo.com/docs/sdk/android) / [ios rehberi](https://docs.pushizo.com/docs/sdk/ios) → "Canlı sohbet".
149
+
150
+ ### Konum
151
+
152
+ Kullanıcı izin verirse cihazın konumu push aboneliğine yazılır; segmentlerde konuma göre hedefleme için
153
+ kullanılır. Paylaşım **yalnızca ön planda** çalışır (arka plan konumu yok): native SDK konumu oturum başında ve uygulama
154
+ ön plana döndüğünde en sık 5 dakikada bir gönderir. İzin yoksa veya gizlilik onayı (`requiresPrivacyConsent`)
155
+ verilmemişse hiçbir şey gönderilmez; tercih kalıcıdır.
156
+
157
+ ```js
158
+ const granted = await Pushizo.Location.requestPermission('Yakındaki mağazaları göstermek için konumunuzu kullanırız.');
159
+ if (granted) await Pushizo.Location.setShared(true);
160
+ const shared = await Pushizo.Location.isShared(); // kalıcı tercih (izin durumundan bağımsız)
161
+ await Pushizo.Location.setShared(false); // paylaşımı kapatır, sunucudaki konumu siler
162
+ ```
163
+
164
+ - `requestPermission(rationale?)`: izin yoksa önce açıklama gösterilir (`rationale`; verilmezse SDK'nın Türkçe/İngilizce
165
+ varsayılan metni), kullanıcı "Şimdi değil" derse sistem istemi açılmaz. İzin varsa veya verildiyse `true`; reddedildiyse,
166
+ uygulama izni tanımlamadıysa ya da vazgeçildiyse `false`. `isShared()` native SDK'daki özelliğin asenkron karşılığıdır.
167
+ - `initialize` öncesinde `setShared`/`requestPermission` `NOT_READY` koduyla reddedilir.
168
+ - **KVKK:** sunucuya ulaşan ilk konum açık rıza kaydı olarak saklanır. Kullanıcıya konumun neden kullanıldığını
169
+ açıklayın ve paylaşımı yalnızca onayıyla açın. `setShared(false)` sunucuya `location: null` gönderir; konum ve rıza
170
+ kaydı silinir, henüz gönderilmemiş konum atılır.
171
+ - **iOS:** `Info.plist` dosyasına `NSLocationWhenInUseUsageDescription` ekleyin (yoksa `requestPermission` `false` döner);
172
+ `config.xml` içinde `<platform name="ios">` altına
173
+ `<edit-config file="*-Info.plist" target="NSLocationWhenInUseUsageDescription" mode="merge"><string>…</string></edit-config>`. Yalnızca "Uygulamayı Kullanırken" izni istenir; "Her Zaman" istenmez. Reddedilmiş izin yeniden
174
+ sorulamaz, kullanıcı Ayarlar'a yönlendirilmelidir.
175
+ - **Android:** eklenti konum iznini manifest'e **otomatik eklemez**; uygulamanın `config.xml` dosyasına kendiniz ekleyin
176
+ (yaklaşık konum yeterlidir, hassas konum isteğe bağlıdır; `<widget>` öğesinde
177
+ `xmlns:android="http://schemas.android.com/apk/res/android"` tanımlı olmalıdır):
178
+
179
+ ```xml
180
+ <platform name="android">
181
+ <config-file target="AndroidManifest.xml" parent="/manifest">
182
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
183
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
184
+ </config-file>
185
+ </platform>
186
+ ```
187
+
188
+ Yalnızca manifest'te tanımlı izinler istenir; hiçbiri yoksa uyarı loglanır ve `false` döner. Açıklama diyaloğu SDK'nın
189
+ string kaynaklarını kullanır; sistem izni `cordova.requestPermissions` ile (`Pushizo.Location.PERMISSION_REQUEST_CODE`)
190
+ istenir ve sonuç SDK'ya iletilir.
191
+
192
+ ### Arka plan bölge izleme
193
+
194
+ Dashboard'da tanımlı coğrafi bölgelere giriş/çıkışı uygulama kapalıyken de yakalar ([ADR-0065](https://github.com/pushizo/pushizo/blob/main/docs/adr/0065-arka-plan-bolge-izleme.md)).
195
+ İzlemeyi işletim sistemi yapar; sunucuya koordinat gitmez, yalnızca giriş/çıkış olayı bildirilir. Varsayılan **kapalıdır**.
196
+
197
+ ```js
198
+ await Pushizo.Location.setGeofencingEnabled(true); // kalıcı tercih
199
+ const on = await Pushizo.Location.isGeofencingEnabled();
200
+ ```
201
+
202
+ - Üç koşul birlikte gerekir: `setGeofencingEnabled(true)`, `setShared(true)` ve arka plan konum izni (iOS "Her Zaman",
203
+ Android `ACCESS_BACKGROUND_LOCATION`). Köprü bu izni **istemez** ve manifest/Info.plist'e **eklemez**; `Info.plist`'e `NSLocationAlwaysAndWhenInUseUsageDescription`, Android manifest'ine `ACCESS_BACKGROUND_LOCATION` eklemek
204
+ (`config.xml` `<config-file>`/`<edit-config>`) ve izni istemek uygulamanın işidir.
205
+ Mağaza beyanları ve aydınlatma metni uygulama geliştiricisinin sorumluluğundadır.
206
+ - `initialize` öncesinde `setGeofencingEnabled` `NOT_READY` ile reddedilir. `setShared(false)` veya gizlilik onayının geri
207
+ alınması kayıtlı bölgeleri kaldırır; tercih korunur.
208
+ - **Android:** uygulamada `com.google.android.gms:play-services-location` bağımlılığı bulunmalıdır; yoksa yerel SDK uyarı
209
+ loglar ve izleme başlamaz.
210
+
211
+ ### Özellik bayrakları
212
+
213
+ Bir özelliği yeni sürüm yayımlamadan açıp kapatın, kademeli yayın yapın veya metin/sayı/JSON değerleri uzaktan yönetin
214
+ ([rehber](https://docs.pushizo.com/docs/guides/feature-flags)). Değerler yerel SDK'da oturum başında yenilenir ve cihazda
215
+ saklanır; ağ yoksa son değer, hiç alınmadıysa koddaki varsayılan döner. Gizlilik onayı beklenirken istek gönderilmez.
216
+
217
+ ```js
218
+ if (await Pushizo.FeatureFlags.isEnabled('yeni_sepet')) showNewCart();
219
+ const limit = await Pushizo.FeatureFlags.getValue('sepet_limiti', 10); // metin, sayı, boolean, nesne veya dizi
220
+ const refreshed = await Pushizo.FeatureFlags.refresh(); // yeni değerler alındıysa true
221
+ ```
222
+
223
+ `isEnabled(key, default = false)` ve `getValue(key, default = null)` yerel önbellekten okur; köprü asenkron olduğundan
224
+ Promise döndürürler. Boş anahtar `TypeError` ile reddedilir.
225
+
226
+ ### Gömülü yerleşimler
227
+
228
+ Uygulamanın ayırdığı bir alana (ana sayfa afişi, liste arası kart) dashboard'dan içerik gönderin
229
+ ([ADR-0068](https://github.com/pushizo/pushizo/blob/main/docs/adr/0068-gomulu-yerlesimler.md)). Köprü yalnızca modeli
230
+ döndürür; çizim uygulamanındır.
231
+
232
+ ```js
233
+ const messages = await Pushizo.Placements.list('home_banner', { limit: 2 }); // InAppMessage[]
234
+ for (const message of messages) {
235
+ render(message.display.blocks); // title/body/image/button/carousel blokları veya display.html
236
+ await Pushizo.Placements.reportImpression(message); // içerik ekrana gelince
237
+ }
238
+ await Pushizo.Placements.reportClick(message, buttonId); // düğme tıklanınca (buttonId: blok/kart düğmesinin id'si)
239
+ await Pushizo.Placements.reportDismiss(message); // kullanıcı kapatınca
240
+ ```
241
+
242
+ - Anahtar `^[a-z][a-z0-9_.-]{0,63}$` kalıbına uymalı, `limit` 1-10 olmalıdır; aksi halde çağrı köprüye gitmeden
243
+ `TypeError`/`RangeError` ile reddedilir. Abonelik yoksa veya gizlilik onayı bekleniyorsa liste boştur.
244
+ - `InAppMessage` alanları yerel modelle aynıdır (`id`, `priority`, `triggers`, `triggerGroups`, `variantId`, `display`,
245
+ `remainingImpressions`, `minIntervalSeconds`, `stopAfterInteraction`, `lastImpressionAt`, `endAt`, `language`); zamanlar
246
+ epoch milisaniyedir. Düğme aksiyonları (`url`, `deeplink`, `tags`, `push_prompt`, `outcome`, `dismiss`) uygulama
247
+ tarafından yürütülür.
248
+ - Rapor çağrıları yerel tarafta son `list` yanıtlarındaki mesajı kimliğiyle bulur (en çok 50 mesaj saklanır); listeden
249
+ gelmeyen bir mesaj için rapor sessizce yok sayılır (debug log).
250
+ - Ağ/sunucu hatasında Android boş liste döndürür; iOS çağrıyı hata koduyla reddeder.
251
+
252
+ ### Olaylar
253
+
254
+ ```js
255
+ Pushizo.Notifications.addForegroundLifecycleListener((event) => {
256
+ event.preventDefault(); // ön planda gösterme; sonra göstermek için: event.display()
257
+ });
258
+ Pushizo.Notifications.addPermissionObserver(({ permission }) => {});
259
+ Pushizo.User.pushSubscription.addObserver((state) => {}); // { id, token, optedIn, permission }
260
+ Pushizo.InAppMessages.addClickListener((e) => {}); // { message: { id }, result: { actionId, url } }
261
+ Pushizo.InAppMessages.addLifecycleListener({ willDisplay() {}, didDismiss() {} });
262
+ ```
263
+
264
+ `addPermissionObserver` olayları yerel Android/iOS SDK izin gözlemcisinden gelir (izin isteği sonucu ve uygulama ön plana
265
+ döndüğünde ayarlardan yapılan değişiklik; yalnızca gerçek değişiklikte).
266
+
267
+ Her `add…` çağrısı aboneliği kaldıran bir fonksiyon döndürür. Olaylar native taraftan tek bir `keepCallback` kanalıyla gelir; kanal açılmadan oluşan olaylar (ör. soğuk başlatma tıklaması) native tarafta tamponlanır.
268
+
269
+ ### In-app, bildirim kutusu ve diğerleri
270
+
271
+ ```js
272
+ await Pushizo.InAppMessages.addTrigger('level', 5);
273
+ await Pushizo.InAppMessages.setScreen('checkout');
274
+ await Pushizo.InAppMessages.setPaused(false);
275
+
276
+ const page = await Pushizo.Inbox.list({ limit: 20 }); // { items, unreadCount, nextCursor, hasMore }
277
+ await Pushizo.Inbox.markRead(page.items[0].id);
278
+ await Pushizo.Inbox.markAllRead();
279
+ await Pushizo.Inbox.archive(page.items[0].id);
280
+
281
+ // Tercihler (kategori × kanal opt-in; channel verilmezse tüm kanallar). Abonelik yoksa NOT_READY.
282
+ const { preferences, categories } = await Pushizo.User.getPreferences();
283
+ await Pushizo.User.setPreferences([
284
+ { category: 'promo', optedIn: false },
285
+ { category: 'news', channel: 'email', optedIn: true },
286
+ ]); // güncel listeyi döndürür
287
+
288
+ await Pushizo.Notifications.clearAll();
289
+ await Pushizo.Notifications.removeGroupedNotifications('orders');
290
+ await Pushizo.Notifications.removeNotification(id); // Android: notification.androidNotificationId; iOS: UNNotificationRequest.identifier (metin)
291
+ await Pushizo.setConsentGiven(true); // requiresPrivacyConsent: true ile başlatıldıysa
292
+ await Pushizo.Debug.setLogLevel('debug');
293
+ await Pushizo.logout();
294
+ ```
295
+
296
+ ### HTML in-app ve carousel
297
+
298
+ In-app mesajları yerel Android/iOS SDK'sı çizer; bu paket köprüdür. HTML in-app (sandbox'lı WebView, köprü
299
+ `close`/`click`/`addTag`/`trackEvent`) ve carousel blokları yerel SDK'dan olduğu gibi devralınır: ek kod veya
300
+ yapılandırma gerekmez, tıklama ve yaşam döngüsü olayları mevcut in-app dinleyicilerine gelir. Yetenek bildirimi
301
+ (`supports=html,carousel`) yerel SDK tarafından yapılır; desteklemeyen eski yerel sürümlere sunucu HTML mesaj göndermez
302
+ ve carousel bloklarını çıkarır.
303
+
304
+ ## Android kurulumu (FCM)
305
+
306
+ 1. Firebase konsolunda Android uygulaması ekleyin; `google-services.json` dosyasını proje köküne koyun ve `config.xml` içine ekleyin:
307
+
308
+ ```xml
309
+ <platform name="android">
310
+ <preference name="GradlePluginKotlinEnabled" value="true" />
311
+ <preference name="GradlePluginGoogleServicesEnabled" value="true" />
312
+ <preference name="GradlePluginGoogleServicesVersion" value="4.4.2" />
313
+ <preference name="android-compileSdkVersion" value="35" />
314
+ <resource-file src="google-services.json" target="app/google-services.json" />
315
+ </platform>
316
+ ```
317
+
318
+ Köprü Kotlin ile yazıldığından `GradlePluginKotlinEnabled` zorunludur. Yerel SDK 0.2.1'in `androidx.work` bağımlılığı
319
+ `compileSdk` 35 ister; cordova-android 13'ün varsayılanı 34 olduğundan `android-compileSdkVersion` tercihi gerekir.
320
+ 2. Pushizo dashboard'unda Firebase servis hesabı JSON'unu yükleyin (kurulum sihirbazında **Cordova** seçilebilir); kayıt sonrası otomatik doğrulanır.
321
+ 3. Eklenti `com.pushizo:pushizo-android:0.2.1` artefaktına bağlıdır (özellik bayrakları, yerleşimler ve bölge izleme bu sürümle gelir). Maven Central yayınına kadar `sdk/android` içinde `gradle :pushizo:publishToMavenLocal` çalıştırın; eklenti `mavenLocal()` deposunu ekler.
322
+ 4. FCM servisi, `POST_NOTIFICATIONS` izni ve bildirim Activity'si SDK manifestinden birleşir. Bildirim ikonu için `AndroidManifest.xml` içinde `com.pushizo.sdk.default_notification_icon` meta-data'sı verilebilir.
323
+
324
+ Eklenti, JS ile yapılan `initialize` ayarlarını (yalnızca uygulama kimliği ve herkese açık ayarlar) saklar; süreç bildirim tıklaması veya FCM mesajıyla yeniden başladığında SDK WebView yüklenmeden başlatılır.
325
+
326
+ ## iOS kurulumu (APNs)
327
+
328
+ 1. `config.xml`:
329
+
330
+ ```xml
331
+ <platform name="ios">
332
+ <preference name="deployment-target" value="15.0" />
333
+ <preference name="SwiftVersion" value="5" />
334
+ </platform>
335
+ ```
336
+
337
+ 2. Eklenti Push Notifications yetkisini (`aps-environment`) ve `remote-notification` arka plan modunu ekler. Pushizo dashboard'unda APNs `.p8` anahtarını veya `.p12` sertifikasını yükleyin.
338
+ 3. `Pushizo` pod'u yayınlanana kadar `platforms/ios/Podfile` içinde `pod 'Pushizo', :path => '<repo>/sdk/ios'` kullanın ve `pod install` çalıştırın.
339
+ 4. APNs token geri çağrıları (`didRegisterForRemoteNotificationsWithDeviceToken`/`didFailToRegister…`) eklenti yüklenirken AppDelegate sınıfına çalışma zamanında eklenir; AppDelegate'te bu metotlar varsa önce SDK'ya iletilir, sonra sizin kodunuz çalışır.
340
+ 5. Pushizo SDK'sı `UNUserNotificationCenter` delegesini üstlenir; başka bir push eklentisiyle (ör. `cordova-plugin-firebasex`) birlikte kullanmayın.
341
+
342
+ ### Notification Service Extension (zengin medya, teslim bildirimi)
343
+
344
+ Resimli bildirimler, rozet artışı ve uygulama kapalıyken `received` bildirimi için Xcode'da (`platforms/ios/*.xcworkspace`) **File → New → Target → Notification Service Extension** ekleyin (iOS 15), Podfile'a hedefi ekleyin:
345
+
346
+ ```ruby
347
+ target 'PushizoNSE' do
348
+ pod 'Pushizo/Extension', :path => '<repo>/sdk/ios'
349
+ end
350
+ ```
351
+
352
+ ve `NotificationService.swift` dosyasını SDK yardımcısına devredin:
353
+
354
+ ```swift
355
+ import UserNotifications
356
+ import Pushizo
357
+
358
+ class NotificationService: UNNotificationServiceExtension {
359
+ let hs = PushizoNotificationServiceExtension(appId: "app_xxx", apiUrl: "https://api.pushizo.com",
360
+ appGroup: "group.com.pushizo.app.pushizo")
361
+
362
+ override func didReceive(_ request: UNNotificationRequest, withContentHandler handler: @escaping (UNNotificationContent) -> Void) {
363
+ hs.didReceive(request, withContentHandler: handler)
364
+ }
365
+
366
+ override func serviceExtensionTimeWillExpire() { hs.serviceExtensionTimeWillExpire() }
367
+ }
368
+ ```
369
+
370
+ Uygulama ve NSE hedeflerinde aynı App Group yeteneğini açın ve uygulamanın `Info.plist` dosyasına `PushizoAppGroup` anahtarıyla yazın (rozet sayacı paylaşımı). `cordova platform rm/add ios` Xcode projesini yeniden oluşturduğundan NSE hedefi yeniden eklenmelidir.
371
+
372
+ ## Geliştirme
373
+
374
+ ```bash
375
+ npm install
376
+ npm run typecheck
377
+ npm test # vitest: cephe, cordova.exec köprüsü ve native sözleşme denetimi
378
+ npm run build # src/*.ts → www/*.js (eklentiyle birlikte yayınlanır, depoda tutulur)
379
+ ```
380
+
381
+ Adım adım kurulum ve örnek kod: [cordova rehberi](https://docs.pushizo.com/docs/sdk/cordova).
382
+
383
+ <!-- pushizo:footer -->
384
+ ---
385
+
386
+ ## Support · Destek
387
+
388
+ - **Guide · Rehber:** [docs.pushizo.com/docs/sdk/cordova](https://docs.pushizo.com/docs/sdk/cordova)
389
+ - **API reference & OpenAPI · API referansı ve OpenAPI:** [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api) ·
390
+ [pushizo-openapi](https://github.com/pushizo/pushizo-openapi)
391
+ - **Bugs & ideas · Hata ve öneri:** [Issues](https://github.com/pushizo/pushizo-cordova/issues)
392
+ - **Security · Güvenlik:** please do not open public issues; email [security@pushizo.com](mailto:security@pushizo.com) ·
393
+ herkese açık issue açmayın, bu adrese yazın.
394
+ - **Help · Destek:** [support@pushizo.com](mailto:support@pushizo.com)
395
+
396
+ This repository is mirrored automatically from the Pushizo main repository on every release. Please open an issue
397
+ instead of a pull request; fixes land in the main repository and ship with the next release.
398
+ Bu depo her sürümde Pushizo ana deposundan otomatik yansıtılır. Pull request yerine issue açın; düzeltmeler ana depoda
399
+ yapılır ve bir sonraki sürümle buraya gelir.
400
+
401
+ Released under the MIT License · MIT lisanslıdır — [LICENSE](https://github.com/pushizo/pushizo-cordova/blob/main/LICENSE).
402
+ <!-- /pushizo:footer -->