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/LICENSE +21 -21
- package/README.md +402 -350
- package/package.json +54 -54
- package/plugin.xml +96 -96
- package/src/android/com/pushizo/cordova/PushizoBridgeCore.kt +610 -493
- package/src/android/com/pushizo/cordova/PushizoConfigStore.kt +41 -41
- package/src/android/com/pushizo/cordova/PushizoCordovaPlugin.kt +141 -141
- package/src/android/com/pushizo/cordova/PushizoInitProvider.kt +34 -34
- package/src/android/pushizo.gradle +6 -6
- package/src/ios/PushizoAppDelegateHook.swift +54 -54
- package/src/ios/PushizoBridgeCore.swift +600 -465
- package/src/ios/PushizoCordovaPlugin.swift +166 -157
- package/types/index.d.ts +64 -54
- package/www/core.d.ts +38 -6
- package/www/core.js +66 -5
- package/www/definitions.d.ts +120 -0
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
cordova
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
##
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
await Pushizo.
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
await Pushizo.
|
|
239
|
-
await Pushizo.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
ve
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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 -->
|