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.
@@ -1,157 +1,166 @@
1
- #if canImport(Cordova)
2
- import Cordova
3
- #endif
4
- import Foundation
5
- import Pushizo
6
- #if canImport(PushizoCore)
7
- import PushizoCore
8
- #endif
9
- import UIKit
10
-
11
- /**
12
- Cordova → Pushizo iOS SDK köprüsü (`cordova.exec` servisi "Pushizo", `onload` ile uygulama açılışında
13
- yüklenir). Metotlar `PushizoBridgeCore` üzerinden SDK'ya iletilir. SDK olayları JS'in `setEventCallback`
14
- ile açtığı tek `keepCallback` kanalından `{ type, payload }` olarak gönderilir; kanal açılmadan gelen olaylar
15
- tamponlanır. APNs token geri çağrıları `PushizoAppDelegateHook` ile yakalanır.
16
- */
17
- @objc(PushizoCordovaPlugin)
18
- class PushizoCordovaPlugin: CDVPlugin {
19
- // CDVCommandStatus üye adları cordova-ios sürümleri arasında farklı (Swift adı); ham değerler sabittir.
20
- private static let statusNoResult = CDVCommandStatus(rawValue: 0)!
21
- private static let statusOk = CDVCommandStatus(rawValue: 1)!
22
- private static let statusError = CDVCommandStatus(rawValue: 9)!
23
- private static let maxBufferedEvents = 50
24
-
25
- private var core: PushizoBridgeCore!
26
- private var eventCallbackId: String?
27
- private var bufferedEvents: [[String: Any]] = []
28
-
29
- override func pluginInitialize() {
30
- super.pluginInitialize()
31
- core = PushizoBridgeCore { [weak self] type, payload in
32
- DispatchQueue.main.async { self?.sendEvent(["type": type, "payload": payload]) }
33
- }
34
- PushizoAppDelegateHook.install()
35
- // Daha önce JS ile başlatıldıysa SDK hemen kayıtlı ayarlarla başlatılır; bildirimden açılış tıklaması kaybolmaz.
36
- if !Pushizo.isInitialized, let config = PushizoBridgeConfig.load() {
37
- config.initializeSdk()
38
- }
39
- core.attachIfInitialized()
40
- }
41
-
42
- override func onReset() {
43
- // Sayfa yeniden yüklendi: eski JS kanalı geçersiz; yeni sayfa `setEventCallback` ile yeniden açar.
44
- eventCallbackId = nil
45
- core.foregroundHandlerEnabled = false
46
- }
47
-
48
- // MARK: Olay kanalı
49
-
50
- @objc(setEventCallback:) func setEventCallback(_ command: CDVInvokedUrlCommand) {
51
- eventCallbackId = command.callbackId
52
- let opened = CDVPluginResult(status: Self.statusNoResult)
53
- opened?.setKeepCallbackAs(true)
54
- commandDelegate.send(opened, callbackId: command.callbackId)
55
- let buffered = bufferedEvents
56
- bufferedEvents.removeAll()
57
- buffered.forEach { sendEvent($0) }
58
- }
59
-
60
- /// Ana iş parçacığında çağrılır.
61
- private func sendEvent(_ message: [String: Any]) {
62
- guard let callbackId = eventCallbackId else {
63
- bufferedEvents.append(message)
64
- if bufferedEvents.count > Self.maxBufferedEvents { bufferedEvents.removeFirst(bufferedEvents.count - Self.maxBufferedEvents) }
65
- return
66
- }
67
- let result = CDVPluginResult(status: Self.statusOk, messageAs: message)
68
- result?.setKeepCallbackAs(true)
69
- commandDelegate.send(result, callbackId: callbackId)
70
- }
71
-
72
- // MARK: Metotlar
73
-
74
- private func dispatch(_ command: CDVInvokedUrlCommand) {
75
- let args = command.argument(at: 0) as? [String: Any] ?? [:]
76
- let callbackId = command.callbackId
77
- let handled = core.handle(command.methodName ?? "", args) { [weak self] result in
78
- guard let self else { return }
79
- let pluginResult: CDVPluginResult?
80
- switch result {
81
- case .success(let data):
82
- pluginResult = data.map { CDVPluginResult(status: Self.statusOk, messageAs: $0) } ?? CDVPluginResult(status: Self.statusOk)
83
- case .failure(let code, let message):
84
- pluginResult = CDVPluginResult(status: Self.statusError, messageAs: ["code": code, "message": message])
85
- }
86
- self.commandDelegate.send(pluginResult, callbackId: callbackId)
87
- }
88
- if !handled {
89
- let error = CDVPluginResult(status: Self.statusError, messageAs: ["code": "NOT_IMPLEMENTED", "message": "Pushizo: \(command.methodName ?? "") desteklenmiyor"])
90
- commandDelegate.send(error, callbackId: callbackId)
91
- }
92
- }
93
-
94
- @objc(initialize:) func initializeSdk(_ command: CDVInvokedUrlCommand) { dispatch(command) }
95
- @objc(setConsentGiven:) func setConsentGiven(_ command: CDVInvokedUrlCommand) { dispatch(command) }
96
- @objc(login:) func login(_ command: CDVInvokedUrlCommand) { dispatch(command) }
97
- @objc(updateUserJwt:) func updateUserJwt(_ command: CDVInvokedUrlCommand) { dispatch(command) }
98
- @objc(logout:) func logout(_ command: CDVInvokedUrlCommand) { dispatch(command) }
99
- @objc(addTags:) func addTags(_ command: CDVInvokedUrlCommand) { dispatch(command) }
100
- @objc(removeTags:) func removeTags(_ command: CDVInvokedUrlCommand) { dispatch(command) }
101
- @objc(getTags:) func getTags(_ command: CDVInvokedUrlCommand) { dispatch(command) }
102
- @objc(addAliases:) func addAliases(_ command: CDVInvokedUrlCommand) { dispatch(command) }
103
- @objc(removeAlias:) func removeAlias(_ command: CDVInvokedUrlCommand) { dispatch(command) }
104
- @objc(setLanguage:) func setLanguage(_ command: CDVInvokedUrlCommand) { dispatch(command) }
105
- @objc(addEmail:) func addEmail(_ command: CDVInvokedUrlCommand) { dispatch(command) }
106
- @objc(removeEmail:) func removeEmail(_ command: CDVInvokedUrlCommand) { dispatch(command) }
107
- @objc(addSms:) func addSms(_ command: CDVInvokedUrlCommand) { dispatch(command) }
108
- @objc(removeSms:) func removeSms(_ command: CDVInvokedUrlCommand) { dispatch(command) }
109
- @objc(getUser:) func getUser(_ command: CDVInvokedUrlCommand) { dispatch(command) }
110
- @objc(getContacts:) func getContacts(_ command: CDVInvokedUrlCommand) { dispatch(command) }
111
- @objc(getPreferences:) func getPreferences(_ command: CDVInvokedUrlCommand) { dispatch(command) }
112
- @objc(setPreferences:) func setPreferences(_ command: CDVInvokedUrlCommand) { dispatch(command) }
113
- @objc(getPushSubscription:) func getPushSubscription(_ command: CDVInvokedUrlCommand) { dispatch(command) }
114
- @objc(optIn:) func optIn(_ command: CDVInvokedUrlCommand) { dispatch(command) }
115
- @objc(optOut:) func optOut(_ command: CDVInvokedUrlCommand) { dispatch(command) }
116
- @objc(getPermission:) func getPermission(_ command: CDVInvokedUrlCommand) { dispatch(command) }
117
- @objc(requestPermission:) func requestPermission(_ command: CDVInvokedUrlCommand) { dispatch(command) }
118
- @objc(clearAll:) func clearAll(_ command: CDVInvokedUrlCommand) { dispatch(command) }
119
- @objc(removeNotification:) func removeNotification(_ command: CDVInvokedUrlCommand) { dispatch(command) }
120
- @objc(removeGroupedNotifications:) func removeGroupedNotifications(_ command: CDVInvokedUrlCommand) { dispatch(command) }
121
- @objc(setForegroundHandlerEnabled:) func setForegroundHandlerEnabled(_ command: CDVInvokedUrlCommand) { dispatch(command) }
122
- @objc(displayNotification:) func displayNotification(_ command: CDVInvokedUrlCommand) { dispatch(command) }
123
- @objc(sendEvent:) func sendEvent(_ command: CDVInvokedUrlCommand) { dispatch(command) }
124
- @objc(setLogLevel:) func setLogLevel(_ command: CDVInvokedUrlCommand) { dispatch(command) }
125
- @objc(addTriggers:) func addTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
126
- @objc(removeTriggers:) func removeTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
127
- @objc(clearTriggers:) func clearTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
128
- @objc(getTriggers:) func getTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
129
- @objc(setScreen:) func setScreen(_ command: CDVInvokedUrlCommand) { dispatch(command) }
130
- @objc(setInAppPaused:) func setInAppPaused(_ command: CDVInvokedUrlCommand) { dispatch(command) }
131
- @objc(getInAppPaused:) func getInAppPaused(_ command: CDVInvokedUrlCommand) { dispatch(command) }
132
- @objc(inboxList:) func inboxList(_ command: CDVInvokedUrlCommand) { dispatch(command) }
133
- @objc(inboxMarkRead:) func inboxMarkRead(_ command: CDVInvokedUrlCommand) { dispatch(command) }
134
- @objc(inboxMarkAllRead:) func inboxMarkAllRead(_ command: CDVInvokedUrlCommand) { dispatch(command) }
135
- @objc(inboxArchive:) func inboxArchive(_ command: CDVInvokedUrlCommand) { dispatch(command) }
136
- @objc(inboxUnreadCount:) func inboxUnreadCount(_ command: CDVInvokedUrlCommand) { dispatch(command) }
137
- @objc(setupDefaultLiveActivity:) func setupDefaultLiveActivity(_ command: CDVInvokedUrlCommand) { dispatch(command) }
138
- @objc(startDefaultLiveActivity:) func startDefaultLiveActivity(_ command: CDVInvokedUrlCommand) { dispatch(command) }
139
- @objc(setLocationShared:) func setLocationShared(_ command: CDVInvokedUrlCommand) { dispatch(command) }
140
- @objc(isLocationShared:) func isLocationShared(_ command: CDVInvokedUrlCommand) { dispatch(command) }
141
- @objc(chatStart:) func chatStart(_ command: CDVInvokedUrlCommand) { dispatch(command) }
142
- @objc(chatGetConfig:) func chatGetConfig(_ command: CDVInvokedUrlCommand) { dispatch(command) }
143
- @objc(chatGetConversation:) func chatGetConversation(_ command: CDVInvokedUrlCommand) { dispatch(command) }
144
- @objc(chatGetMessages:) func chatGetMessages(_ command: CDVInvokedUrlCommand) { dispatch(command) }
145
- @objc(chatSendMessage:) func chatSendMessage(_ command: CDVInvokedUrlCommand) { dispatch(command) }
146
- @objc(chatSendAttachment:) func chatSendAttachment(_ command: CDVInvokedUrlCommand) { dispatch(command) }
147
- @objc(chatMarkRead:) func chatMarkRead(_ command: CDVInvokedUrlCommand) { dispatch(command) }
148
- @objc(chatRefreshUnreadCount:) func chatRefreshUnreadCount(_ command: CDVInvokedUrlCommand) { dispatch(command) }
149
- @objc(chatGetUnreadCount:) func chatGetUnreadCount(_ command: CDVInvokedUrlCommand) { dispatch(command) }
150
- @objc(chatLeaveOfflineMessage:) func chatLeaveOfflineMessage(_ command: CDVInvokedUrlCommand) { dispatch(command) }
151
- @objc(chatSetTyping:) func chatSetTyping(_ command: CDVInvokedUrlCommand) { dispatch(command) }
152
- @objc(chatStartListening:) func chatStartListening(_ command: CDVInvokedUrlCommand) { dispatch(command) }
153
- @objc(chatStopListening:) func chatStopListening(_ command: CDVInvokedUrlCommand) { dispatch(command) }
154
- @objc(chatAttachmentUrl:) func chatAttachmentUrl(_ command: CDVInvokedUrlCommand) { dispatch(command) }
155
- @objc(chatGetVisitorId:) func chatGetVisitorId(_ command: CDVInvokedUrlCommand) { dispatch(command) }
156
- @objc(requestLocationPermission:) func requestLocationPermission(_ command: CDVInvokedUrlCommand) { dispatch(command) }
157
- }
1
+ #if canImport(Cordova)
2
+ import Cordova
3
+ #endif
4
+ import Foundation
5
+ import Pushizo
6
+ #if canImport(PushizoCore)
7
+ import PushizoCore
8
+ #endif
9
+ import UIKit
10
+
11
+ /**
12
+ Cordova → Pushizo iOS SDK köprüsü (`cordova.exec` servisi "Pushizo", `onload` ile uygulama açılışında
13
+ yüklenir). Metotlar `PushizoBridgeCore` üzerinden SDK'ya iletilir. SDK olayları JS'in `setEventCallback`
14
+ ile açtığı tek `keepCallback` kanalından `{ type, payload }` olarak gönderilir; kanal açılmadan gelen olaylar
15
+ tamponlanır. APNs token geri çağrıları `PushizoAppDelegateHook` ile yakalanır.
16
+ */
17
+ @objc(PushizoCordovaPlugin)
18
+ class PushizoCordovaPlugin: CDVPlugin {
19
+ // CDVCommandStatus üye adları cordova-ios sürümleri arasında farklı (Swift adı); ham değerler sabittir.
20
+ private static let statusNoResult = CDVCommandStatus(rawValue: 0)!
21
+ private static let statusOk = CDVCommandStatus(rawValue: 1)!
22
+ private static let statusError = CDVCommandStatus(rawValue: 9)!
23
+ private static let maxBufferedEvents = 50
24
+
25
+ private var core: PushizoBridgeCore!
26
+ private var eventCallbackId: String?
27
+ private var bufferedEvents: [[String: Any]] = []
28
+
29
+ override func pluginInitialize() {
30
+ super.pluginInitialize()
31
+ core = PushizoBridgeCore { [weak self] type, payload in
32
+ DispatchQueue.main.async { self?.sendEvent(["type": type, "payload": payload]) }
33
+ }
34
+ PushizoAppDelegateHook.install()
35
+ // Daha önce JS ile başlatıldıysa SDK hemen kayıtlı ayarlarla başlatılır; bildirimden açılış tıklaması kaybolmaz.
36
+ if !Pushizo.isInitialized, let config = PushizoBridgeConfig.load() {
37
+ config.initializeSdk()
38
+ }
39
+ core.attachIfInitialized()
40
+ }
41
+
42
+ override func onReset() {
43
+ // Sayfa yeniden yüklendi: eski JS kanalı geçersiz; yeni sayfa `setEventCallback` ile yeniden açar.
44
+ eventCallbackId = nil
45
+ core.foregroundHandlerEnabled = false
46
+ }
47
+
48
+ // MARK: Olay kanalı
49
+
50
+ @objc(setEventCallback:) func setEventCallback(_ command: CDVInvokedUrlCommand) {
51
+ eventCallbackId = command.callbackId
52
+ let opened = CDVPluginResult(status: Self.statusNoResult)
53
+ opened?.setKeepCallbackAs(true)
54
+ commandDelegate.send(opened, callbackId: command.callbackId)
55
+ let buffered = bufferedEvents
56
+ bufferedEvents.removeAll()
57
+ buffered.forEach { sendEvent($0) }
58
+ }
59
+
60
+ /// Ana iş parçacığında çağrılır.
61
+ private func sendEvent(_ message: [String: Any]) {
62
+ guard let callbackId = eventCallbackId else {
63
+ bufferedEvents.append(message)
64
+ if bufferedEvents.count > Self.maxBufferedEvents { bufferedEvents.removeFirst(bufferedEvents.count - Self.maxBufferedEvents) }
65
+ return
66
+ }
67
+ let result = CDVPluginResult(status: Self.statusOk, messageAs: message)
68
+ result?.setKeepCallbackAs(true)
69
+ commandDelegate.send(result, callbackId: callbackId)
70
+ }
71
+
72
+ // MARK: Metotlar
73
+
74
+ private func dispatch(_ command: CDVInvokedUrlCommand) {
75
+ let args = command.argument(at: 0) as? [String: Any] ?? [:]
76
+ let callbackId = command.callbackId
77
+ let handled = core.handle(command.methodName ?? "", args) { [weak self] result in
78
+ guard let self else { return }
79
+ let pluginResult: CDVPluginResult?
80
+ switch result {
81
+ case .success(let data):
82
+ pluginResult = data.map { CDVPluginResult(status: Self.statusOk, messageAs: $0) } ?? CDVPluginResult(status: Self.statusOk)
83
+ case .failure(let code, let message):
84
+ pluginResult = CDVPluginResult(status: Self.statusError, messageAs: ["code": code, "message": message])
85
+ }
86
+ self.commandDelegate.send(pluginResult, callbackId: callbackId)
87
+ }
88
+ if !handled {
89
+ let error = CDVPluginResult(status: Self.statusError, messageAs: ["code": "NOT_IMPLEMENTED", "message": "Pushizo: \(command.methodName ?? "") desteklenmiyor"])
90
+ commandDelegate.send(error, callbackId: callbackId)
91
+ }
92
+ }
93
+
94
+ @objc(initialize:) func initializeSdk(_ command: CDVInvokedUrlCommand) { dispatch(command) }
95
+ @objc(setConsentGiven:) func setConsentGiven(_ command: CDVInvokedUrlCommand) { dispatch(command) }
96
+ @objc(login:) func login(_ command: CDVInvokedUrlCommand) { dispatch(command) }
97
+ @objc(updateUserJwt:) func updateUserJwt(_ command: CDVInvokedUrlCommand) { dispatch(command) }
98
+ @objc(logout:) func logout(_ command: CDVInvokedUrlCommand) { dispatch(command) }
99
+ @objc(addTags:) func addTags(_ command: CDVInvokedUrlCommand) { dispatch(command) }
100
+ @objc(removeTags:) func removeTags(_ command: CDVInvokedUrlCommand) { dispatch(command) }
101
+ @objc(getTags:) func getTags(_ command: CDVInvokedUrlCommand) { dispatch(command) }
102
+ @objc(addAliases:) func addAliases(_ command: CDVInvokedUrlCommand) { dispatch(command) }
103
+ @objc(removeAlias:) func removeAlias(_ command: CDVInvokedUrlCommand) { dispatch(command) }
104
+ @objc(setLanguage:) func setLanguage(_ command: CDVInvokedUrlCommand) { dispatch(command) }
105
+ @objc(addEmail:) func addEmail(_ command: CDVInvokedUrlCommand) { dispatch(command) }
106
+ @objc(removeEmail:) func removeEmail(_ command: CDVInvokedUrlCommand) { dispatch(command) }
107
+ @objc(addSms:) func addSms(_ command: CDVInvokedUrlCommand) { dispatch(command) }
108
+ @objc(removeSms:) func removeSms(_ command: CDVInvokedUrlCommand) { dispatch(command) }
109
+ @objc(getUser:) func getUser(_ command: CDVInvokedUrlCommand) { dispatch(command) }
110
+ @objc(getContacts:) func getContacts(_ command: CDVInvokedUrlCommand) { dispatch(command) }
111
+ @objc(getPreferences:) func getPreferences(_ command: CDVInvokedUrlCommand) { dispatch(command) }
112
+ @objc(setPreferences:) func setPreferences(_ command: CDVInvokedUrlCommand) { dispatch(command) }
113
+ @objc(getPushSubscription:) func getPushSubscription(_ command: CDVInvokedUrlCommand) { dispatch(command) }
114
+ @objc(optIn:) func optIn(_ command: CDVInvokedUrlCommand) { dispatch(command) }
115
+ @objc(optOut:) func optOut(_ command: CDVInvokedUrlCommand) { dispatch(command) }
116
+ @objc(getPermission:) func getPermission(_ command: CDVInvokedUrlCommand) { dispatch(command) }
117
+ @objc(requestPermission:) func requestPermission(_ command: CDVInvokedUrlCommand) { dispatch(command) }
118
+ @objc(clearAll:) func clearAll(_ command: CDVInvokedUrlCommand) { dispatch(command) }
119
+ @objc(removeNotification:) func removeNotification(_ command: CDVInvokedUrlCommand) { dispatch(command) }
120
+ @objc(removeGroupedNotifications:) func removeGroupedNotifications(_ command: CDVInvokedUrlCommand) { dispatch(command) }
121
+ @objc(setForegroundHandlerEnabled:) func setForegroundHandlerEnabled(_ command: CDVInvokedUrlCommand) { dispatch(command) }
122
+ @objc(displayNotification:) func displayNotification(_ command: CDVInvokedUrlCommand) { dispatch(command) }
123
+ @objc(sendEvent:) func sendEvent(_ command: CDVInvokedUrlCommand) { dispatch(command) }
124
+ @objc(setLogLevel:) func setLogLevel(_ command: CDVInvokedUrlCommand) { dispatch(command) }
125
+ @objc(addTriggers:) func addTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
126
+ @objc(removeTriggers:) func removeTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
127
+ @objc(clearTriggers:) func clearTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
128
+ @objc(getTriggers:) func getTriggers(_ command: CDVInvokedUrlCommand) { dispatch(command) }
129
+ @objc(setScreen:) func setScreen(_ command: CDVInvokedUrlCommand) { dispatch(command) }
130
+ @objc(setInAppPaused:) func setInAppPaused(_ command: CDVInvokedUrlCommand) { dispatch(command) }
131
+ @objc(getInAppPaused:) func getInAppPaused(_ command: CDVInvokedUrlCommand) { dispatch(command) }
132
+ @objc(inboxList:) func inboxList(_ command: CDVInvokedUrlCommand) { dispatch(command) }
133
+ @objc(inboxMarkRead:) func inboxMarkRead(_ command: CDVInvokedUrlCommand) { dispatch(command) }
134
+ @objc(inboxMarkAllRead:) func inboxMarkAllRead(_ command: CDVInvokedUrlCommand) { dispatch(command) }
135
+ @objc(inboxArchive:) func inboxArchive(_ command: CDVInvokedUrlCommand) { dispatch(command) }
136
+ @objc(inboxUnreadCount:) func inboxUnreadCount(_ command: CDVInvokedUrlCommand) { dispatch(command) }
137
+ @objc(setupDefaultLiveActivity:) func setupDefaultLiveActivity(_ command: CDVInvokedUrlCommand) { dispatch(command) }
138
+ @objc(startDefaultLiveActivity:) func startDefaultLiveActivity(_ command: CDVInvokedUrlCommand) { dispatch(command) }
139
+ @objc(setLocationShared:) func setLocationShared(_ command: CDVInvokedUrlCommand) { dispatch(command) }
140
+ @objc(isLocationShared:) func isLocationShared(_ command: CDVInvokedUrlCommand) { dispatch(command) }
141
+ @objc(setGeofencingEnabled:) func setGeofencingEnabled(_ command: CDVInvokedUrlCommand) { dispatch(command) }
142
+ @objc(isGeofencingEnabled:) func isGeofencingEnabled(_ command: CDVInvokedUrlCommand) { dispatch(command) }
143
+ @objc(featureFlagsRefresh:) func featureFlagsRefresh(_ command: CDVInvokedUrlCommand) { dispatch(command) }
144
+ @objc(featureFlagsIsEnabled:) func featureFlagsIsEnabled(_ command: CDVInvokedUrlCommand) { dispatch(command) }
145
+ @objc(featureFlagsGetValue:) func featureFlagsGetValue(_ command: CDVInvokedUrlCommand) { dispatch(command) }
146
+ @objc(placementsList:) func placementsList(_ command: CDVInvokedUrlCommand) { dispatch(command) }
147
+ @objc(placementsReportImpression:) func placementsReportImpression(_ command: CDVInvokedUrlCommand) { dispatch(command) }
148
+ @objc(placementsReportClick:) func placementsReportClick(_ command: CDVInvokedUrlCommand) { dispatch(command) }
149
+ @objc(placementsReportDismiss:) func placementsReportDismiss(_ command: CDVInvokedUrlCommand) { dispatch(command) }
150
+ @objc(chatStart:) func chatStart(_ command: CDVInvokedUrlCommand) { dispatch(command) }
151
+ @objc(chatGetConfig:) func chatGetConfig(_ command: CDVInvokedUrlCommand) { dispatch(command) }
152
+ @objc(chatGetConversation:) func chatGetConversation(_ command: CDVInvokedUrlCommand) { dispatch(command) }
153
+ @objc(chatGetMessages:) func chatGetMessages(_ command: CDVInvokedUrlCommand) { dispatch(command) }
154
+ @objc(chatSendMessage:) func chatSendMessage(_ command: CDVInvokedUrlCommand) { dispatch(command) }
155
+ @objc(chatSendAttachment:) func chatSendAttachment(_ command: CDVInvokedUrlCommand) { dispatch(command) }
156
+ @objc(chatMarkRead:) func chatMarkRead(_ command: CDVInvokedUrlCommand) { dispatch(command) }
157
+ @objc(chatRefreshUnreadCount:) func chatRefreshUnreadCount(_ command: CDVInvokedUrlCommand) { dispatch(command) }
158
+ @objc(chatGetUnreadCount:) func chatGetUnreadCount(_ command: CDVInvokedUrlCommand) { dispatch(command) }
159
+ @objc(chatLeaveOfflineMessage:) func chatLeaveOfflineMessage(_ command: CDVInvokedUrlCommand) { dispatch(command) }
160
+ @objc(chatSetTyping:) func chatSetTyping(_ command: CDVInvokedUrlCommand) { dispatch(command) }
161
+ @objc(chatStartListening:) func chatStartListening(_ command: CDVInvokedUrlCommand) { dispatch(command) }
162
+ @objc(chatStopListening:) func chatStopListening(_ command: CDVInvokedUrlCommand) { dispatch(command) }
163
+ @objc(chatAttachmentUrl:) func chatAttachmentUrl(_ command: CDVInvokedUrlCommand) { dispatch(command) }
164
+ @objc(chatGetVisitorId:) func chatGetVisitorId(_ command: CDVInvokedUrlCommand) { dispatch(command) }
165
+ @objc(requestLocationPermission:) func requestLocationPermission(_ command: CDVInvokedUrlCommand) { dispatch(command) }
166
+ }
package/types/index.d.ts CHANGED
@@ -1,54 +1,64 @@
1
- /*
2
- * cordova-plugin-pushizo tip tanımları. Eklenti `window.Pushizo` ve `window.plugins.Pushizo`
3
- * olarak yüklenir; TypeScript projelerinde `import Pushizo = require('cordova-plugin-pushizo')`
4
- * yerine çoğunlukla genel `Pushizo` değişkeni kullanılır.
5
- */
6
- import type { PushizoCore } from '../www/core';
7
- import type * as Definitions from '../www/definitions';
8
-
9
- declare const Pushizo: PushizoCore;
10
-
11
- declare namespace Pushizo {
12
- type LogLevel = Definitions.LogLevel;
13
- type InitializeOptions = Definitions.InitializeOptions;
14
- type LoginOptions = Definitions.LoginOptions;
15
- type PushizoNotification = Definitions.PushizoNotification;
16
- type NotificationClickEvent = Definitions.NotificationClickEvent;
17
- type ForegroundWillDisplayEvent = Definitions.ForegroundWillDisplayEvent;
18
- type PushSubscriptionState = Definitions.PushSubscriptionState;
19
- type PermissionChangeEvent = Definitions.PermissionChangeEvent;
20
- type InAppClickEvent = Definitions.InAppClickEvent;
21
- type InAppLifecycleEvent = Definitions.InAppLifecycleEvent;
22
- type InAppLifecycleListener = Definitions.InAppLifecycleListener;
23
- type InAppTriggerValue = Definitions.InAppTriggerValue;
24
- type LiveActivityValue = Definitions.LiveActivityValue;
25
- type InboxItem = Definitions.InboxItem;
26
- type InboxPage = Definitions.InboxPage;
27
- type InboxListOptions = Definitions.InboxListOptions;
28
- type PreferenceChannel = Definitions.PreferenceChannel;
29
- type UserPreference = Definitions.UserPreference;
30
- type PreferenceCategory = Definitions.PreferenceCategory;
31
- type UserPreferences = Definitions.UserPreferences;
32
- type PreferenceInput = Definitions.PreferenceInput;
33
- type ChatMessage = Definitions.ChatMessage;
34
- type ChatAttachment = Definitions.ChatAttachment;
35
- type ChatQuickReply = Definitions.ChatQuickReply;
36
- type ChatConversation = Definitions.ChatConversation;
37
- type ChatConversationState = Definitions.ChatConversationState;
38
- type ChatMessagePage = Definitions.ChatMessagePage;
39
- type ChatIdentifyResult = Definitions.ChatIdentifyResult;
40
- type ChatConfig = Definitions.ChatConfig;
41
- type ChatStartOptions = Definitions.ChatStartOptions;
42
- type ChatMessagesOptions = Definitions.ChatMessagesOptions;
43
- type ChatAttachmentSource = Definitions.ChatAttachmentSource;
44
- type ChatAttachmentOptions = Definitions.ChatAttachmentOptions;
45
- type ChatEventMap = Definitions.ChatEventMap;
46
- }
47
-
48
- export = Pushizo;
49
-
50
- declare global {
51
- interface Window {
52
- Pushizo: PushizoCore;
53
- }
54
- }
1
+ /*
2
+ * cordova-plugin-pushizo tip tanımları. Eklenti `window.Pushizo` ve `window.plugins.Pushizo`
3
+ * olarak yüklenir; TypeScript projelerinde `import Pushizo = require('cordova-plugin-pushizo')`
4
+ * yerine çoğunlukla genel `Pushizo` değişkeni kullanılır.
5
+ */
6
+ import type { PushizoCore } from '../www/core';
7
+ import type * as Definitions from '../www/definitions';
8
+
9
+ declare const Pushizo: PushizoCore;
10
+
11
+ declare namespace Pushizo {
12
+ type LogLevel = Definitions.LogLevel;
13
+ type InitializeOptions = Definitions.InitializeOptions;
14
+ type LoginOptions = Definitions.LoginOptions;
15
+ type PushizoNotification = Definitions.PushizoNotification;
16
+ type NotificationClickEvent = Definitions.NotificationClickEvent;
17
+ type ForegroundWillDisplayEvent = Definitions.ForegroundWillDisplayEvent;
18
+ type PushSubscriptionState = Definitions.PushSubscriptionState;
19
+ type PermissionChangeEvent = Definitions.PermissionChangeEvent;
20
+ type InAppClickEvent = Definitions.InAppClickEvent;
21
+ type InAppLifecycleEvent = Definitions.InAppLifecycleEvent;
22
+ type InAppLifecycleListener = Definitions.InAppLifecycleListener;
23
+ type InAppTriggerValue = Definitions.InAppTriggerValue;
24
+ type FeatureFlagValue = Definitions.FeatureFlagValue;
25
+ type InAppMessage = Definitions.InAppMessage;
26
+ type InAppDisplay = Definitions.InAppDisplay;
27
+ type InAppLayout = Definitions.InAppLayout;
28
+ type InAppBlock = Definitions.InAppBlock;
29
+ type InAppButton = Definitions.InAppButton;
30
+ type InAppCarouselCard = Definitions.InAppCarouselCard;
31
+ type InAppAction = Definitions.InAppAction;
32
+ type InAppTrigger = Definitions.InAppTrigger;
33
+ type PlacementListOptions = Definitions.PlacementListOptions;
34
+ type LiveActivityValue = Definitions.LiveActivityValue;
35
+ type InboxItem = Definitions.InboxItem;
36
+ type InboxPage = Definitions.InboxPage;
37
+ type InboxListOptions = Definitions.InboxListOptions;
38
+ type PreferenceChannel = Definitions.PreferenceChannel;
39
+ type UserPreference = Definitions.UserPreference;
40
+ type PreferenceCategory = Definitions.PreferenceCategory;
41
+ type UserPreferences = Definitions.UserPreferences;
42
+ type PreferenceInput = Definitions.PreferenceInput;
43
+ type ChatMessage = Definitions.ChatMessage;
44
+ type ChatAttachment = Definitions.ChatAttachment;
45
+ type ChatQuickReply = Definitions.ChatQuickReply;
46
+ type ChatConversation = Definitions.ChatConversation;
47
+ type ChatConversationState = Definitions.ChatConversationState;
48
+ type ChatMessagePage = Definitions.ChatMessagePage;
49
+ type ChatIdentifyResult = Definitions.ChatIdentifyResult;
50
+ type ChatConfig = Definitions.ChatConfig;
51
+ type ChatStartOptions = Definitions.ChatStartOptions;
52
+ type ChatMessagesOptions = Definitions.ChatMessagesOptions;
53
+ type ChatAttachmentSource = Definitions.ChatAttachmentSource;
54
+ type ChatAttachmentOptions = Definitions.ChatAttachmentOptions;
55
+ type ChatEventMap = Definitions.ChatEventMap;
56
+ }
57
+
58
+ export = Pushizo;
59
+
60
+ declare global {
61
+ interface Window {
62
+ Pushizo: PushizoCore;
63
+ }
64
+ }
package/www/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ChatAttachmentOptions, ChatAttachmentSource, ChatConfig, ChatConversationState, ChatEventMap, ChatIdentifyResult, ChatMessage, ChatMessagePage, ChatMessagesOptions, ChatStartOptions, ForegroundWillDisplayEvent, PushizoNotification, InAppClickEvent, InAppLifecycleListener, InAppTriggerValue, InboxItem, InboxListOptions, InboxPage, InitializeOptions, LiveActivityValue, LogLevel, LoginOptions, NotificationClickEvent, PermissionChangeEvent, PreferenceInput, PushSubscriptionState, UserPreferences } from './definitions';
1
+ import type { ChatAttachmentOptions, ChatAttachmentSource, ChatConfig, ChatConversationState, ChatEventMap, ChatIdentifyResult, ChatMessage, ChatMessagePage, ChatMessagesOptions, ChatStartOptions, FeatureFlagValue, ForegroundWillDisplayEvent, PushizoNotification, InAppClickEvent, InAppLifecycleListener, InAppMessage, InAppTriggerValue, InboxItem, InboxListOptions, InboxPage, InitializeOptions, LiveActivityValue, LogLevel, LoginOptions, NotificationClickEvent, PermissionChangeEvent, PlacementListOptions, PreferenceInput, PushSubscriptionState, UserPreferences } from './definitions';
2
2
  /** Native katmandan gelen olay adları. */
3
3
  export type BridgeEventType = 'click' | 'foregroundWillDisplay' | 'pushSubscriptionChange' | 'permissionChange' | 'inAppClick' | 'inAppLifecycle' | 'chatEvent' | 'chatOpen';
4
4
  /** Taşıma katmanı: native metot çağrısı ve olay aboneliği. */
@@ -196,11 +196,35 @@ export declare class PushizoCore {
196
196
  private onChatEvent;
197
197
  private onChatOpen;
198
198
  /**
199
- * Konum paylaşımı (yalnızca ön plan; arka plan konumu yok). Paylaşım açıkken native SDK konumu oturum başında ve
200
- * uygulama ön plana döndüğünde en sık 5 dakikada bir push aboneliğine yazar; izin yoksa veya gizlilik onayı
201
- * verilmemişse hiçbir şey gönderilmez. İlk konum sunucuda KVKK açık rıza kaydı sayılır; `setShared(false)` konumu ve
202
- * rıza kaydını sildirir. Tercih kalıcıdır. `initialize` öncesinde `setShared`/`requestPermission` `NOT_READY` ile
203
- * reddedilir (web: Web SDK hatası).
199
+ * Özellik bayrakları: değerler native SDK'da oturum başında yenilenir ve cihazda saklanır; ağ yoksa son değer, hiç
200
+ * alınmadıysa verilen varsayılan döner. Gizlilik onayı beklenirken istek gönderilmez.
201
+ */
202
+ readonly FeatureFlags: {
203
+ /** Değerleri sunucudan hemen yeniler; yeni değerler alındıysa true (hata son değerleri korur). */
204
+ refresh: () => Promise<boolean>;
205
+ /** Bayrak bu kullanıcı için açık mı; değer henüz yoksa `defaultValue`. */
206
+ isEnabled: (key: string, defaultValue?: boolean) => Promise<boolean>;
207
+ /** Bayrağın değeri (metin, sayı, mantıksal, nesne veya dizi); değer yoksa `defaultValue`. */
208
+ getValue: <T extends FeatureFlagValue = FeatureFlagValue>(key: string, defaultValue?: T | null) => Promise<T | null>;
209
+ };
210
+ /**
211
+ * Gömülü yerleşimler: uygulamanın ayırdığı alana içerik. Model döner, çizim uygulamanındır; içerik ekrana gelince
212
+ * `reportImpression`, düğme tıklanınca `reportClick`, kapatılınca `reportDismiss` çağrılır.
213
+ */
214
+ readonly Placements: {
215
+ /** Alanın içeriği (`limit` 1-10, varsayılan 1). Abonelik yoksa veya gizlilik onayı bekleniyorsa boş döner. */
216
+ list: (key: string, options?: PlacementListOptions) => Promise<InAppMessage[]>;
217
+ /** Raporlar `list` ile alınmış mesaj içindir; native katmanın tanımadığı mesaj yok sayılır. */
218
+ reportImpression: (message: Pick<InAppMessage, "id">) => Promise<void>;
219
+ reportClick: (message: Pick<InAppMessage, "id">, buttonId: string) => Promise<void>;
220
+ reportDismiss: (message: Pick<InAppMessage, "id">) => Promise<void>;
221
+ };
222
+ /**
223
+ * Konum paylaşımı (yalnızca ön plan; arka planda koordinat toplanmaz, bölge izleme için `setGeofencingEnabled`).
224
+ * Paylaşım açıkken native SDK konumu oturum başında ve uygulama ön plana döndüğünde en sık 5 dakikada bir push
225
+ * aboneliğine yazar; izin yoksa veya gizlilik onayı verilmemişse hiçbir şey gönderilmez. İlk konum sunucuda KVKK açık
226
+ * rıza kaydı sayılır; `setShared(false)` konumu ve rıza kaydını sildirir. Tercih kalıcıdır. `initialize` öncesinde
227
+ * `setShared`/`requestPermission`/`setGeofencingEnabled` `NOT_READY` ile reddedilir (web: Web SDK hatası).
204
228
  */
205
229
  readonly Location: {
206
230
  /** Paylaşımı açar/kapatır (kalıcı). Açılırken izin varsa konum hemen gönderilir; izin için `requestPermission`. */
@@ -216,6 +240,14 @@ export declare class PushizoCore {
216
240
  * açılmaz. Sonuç: izin varsa veya verildiyse true; reddedildiyse, uygulama izni tanımlamadıysa veya vazgeçildiyse false.
217
241
  */
218
242
  requestPermission: (rationale?: string) => Promise<boolean>;
243
+ /**
244
+ * Arka plan bölge izlemeyi açar/kapatır (ADR-0065; kalıcı, varsayılan kapalı). İzlemeyi işletim sistemi yapar,
245
+ * sunucuya koordinat gitmez. `setShared(true)` ve arka plan konum izni gerekir; köprü izin istemez ve
246
+ * manifest/Info.plist'e izin eklemez.
247
+ */
248
+ setGeofencingEnabled: (enabled: boolean) => Promise<void>;
249
+ /** Bölge izleme açık mı (kalıcı tercih; izin durumundan bağımsız). */
250
+ isGeofencingEnabled: () => Promise<boolean>;
219
251
  };
220
252
  /**
221
253
  * iOS Live Activities (ADR-0024; iOS 16.1+). Köprü genel `PushizoDefaultLiveActivityAttributes` türünü kullanır;
package/www/core.js CHANGED
@@ -79,6 +79,14 @@ function liveActivityValues(input, name, reservedKey) {
79
79
  }
80
80
  return out;
81
81
  }
82
+ /** Yerleşim anahtarı: native SDK ve sunucu kuralı. */
83
+ const PLACEMENT_KEY = /^[a-z][a-z0-9_.-]{0,63}$/;
84
+ /** Rapor çağrılarında yalnızca mesaj kimliği köprüye gider; native katman mesajı son `list` yanıtlarından bulur. */
85
+ function placementMessageId(message) {
86
+ if (message === null || typeof message !== 'object')
87
+ throw new TypeError('Pushizo: message bir nesne olmalı.');
88
+ return requireString(message.id, 'message.id');
89
+ }
82
90
  const PREFERENCE_CHANNELS = ['ios_push', 'android_push', 'web_push', 'email', 'sms'];
83
91
  /** `setPreferences` girdisini yerel SDK kurallarıyla doğrular: 1-100 kayıt, kategori 1-64 karakter, bilinen kanal. */
84
92
  function preferenceArgs(input) {
@@ -437,13 +445,58 @@ class PushizoCore {
437
445
  (_a = this.chatListeners[event]) === null || _a === void 0 ? void 0 : _a.delete(listener);
438
446
  },
439
447
  };
448
+ // --- Özellik bayrakları (ADR-0066) ---
449
+ /**
450
+ * Özellik bayrakları: değerler native SDK'da oturum başında yenilenir ve cihazda saklanır; ağ yoksa son değer, hiç
451
+ * alınmadıysa verilen varsayılan döner. Gizlilik onayı beklenirken istek gönderilmez.
452
+ */
453
+ this.FeatureFlags = {
454
+ /** Değerleri sunucudan hemen yeniler; yeni değerler alındıysa true (hata son değerleri korur). */
455
+ refresh: async () => { var _a; return Boolean((_a = (await this.bridge.call('featureFlagsRefresh'))) === null || _a === void 0 ? void 0 : _a.success); },
456
+ /** Bayrak bu kullanıcı için açık mı; değer henüz yoksa `defaultValue`. */
457
+ isEnabled: async (key, defaultValue = false) => {
458
+ var _a;
459
+ const args = { key: requireString(key, 'key'), defaultValue: Boolean(defaultValue) };
460
+ return Boolean((_a = (await this.bridge.call('featureFlagsIsEnabled', args))) === null || _a === void 0 ? void 0 : _a.enabled);
461
+ },
462
+ /** Bayrağın değeri (metin, sayı, mantıksal, nesne veya dizi); değer yoksa `defaultValue`. */
463
+ getValue: async (key, defaultValue = null) => {
464
+ const result = await this.bridge.call('featureFlagsGetValue', {
465
+ key: requireString(key, 'key'),
466
+ });
467
+ const value = result === null || result === void 0 ? void 0 : result.value;
468
+ return value === undefined || value === null ? defaultValue : value;
469
+ },
470
+ };
471
+ // --- Gömülü yerleşimler (ADR-0068) ---
472
+ /**
473
+ * Gömülü yerleşimler: uygulamanın ayırdığı alana içerik. Model döner, çizim uygulamanındır; içerik ekrana gelince
474
+ * `reportImpression`, düğme tıklanınca `reportClick`, kapatılınca `reportDismiss` çağrılır.
475
+ */
476
+ this.Placements = {
477
+ /** Alanın içeriği (`limit` 1-10, varsayılan 1). Abonelik yoksa veya gizlilik onayı bekleniyorsa boş döner. */
478
+ list: async (key, options = {}) => {
479
+ var _a;
480
+ if (typeof key !== 'string' || !PLACEMENT_KEY.test(key))
481
+ throw new TypeError('Pushizo: geçersiz yerleşim anahtarı.');
482
+ const limit = (_a = options.limit) !== null && _a !== void 0 ? _a : 1;
483
+ if (!Number.isInteger(limit) || limit < 1 || limit > 10)
484
+ throw new RangeError('Pushizo: limit 1-10 olmalı.');
485
+ const result = await this.bridge.call('placementsList', { key, limit });
486
+ return Array.isArray(result === null || result === void 0 ? void 0 : result.messages) ? result.messages : [];
487
+ },
488
+ /** Raporlar `list` ile alınmış mesaj içindir; native katmanın tanımadığı mesaj yok sayılır. */
489
+ reportImpression: async (message) => this.bridge.call('placementsReportImpression', { id: placementMessageId(message) }),
490
+ reportClick: async (message, buttonId) => this.bridge.call('placementsReportClick', { id: placementMessageId(message), buttonId: requireString(buttonId, 'buttonId') }),
491
+ reportDismiss: async (message) => this.bridge.call('placementsReportDismiss', { id: placementMessageId(message) }),
492
+ };
440
493
  // --- Konum (v2 Faz 17b) ---
441
494
  /**
442
- * Konum paylaşımı (yalnızca ön plan; arka plan konumu yok). Paylaşım açıkken native SDK konumu oturum başında ve
443
- * uygulama ön plana döndüğünde en sık 5 dakikada bir push aboneliğine yazar; izin yoksa veya gizlilik onayı
444
- * verilmemişse hiçbir şey gönderilmez. İlk konum sunucuda KVKK açık rıza kaydı sayılır; `setShared(false)` konumu ve
445
- * rıza kaydını sildirir. Tercih kalıcıdır. `initialize` öncesinde `setShared`/`requestPermission` `NOT_READY` ile
446
- * reddedilir (web: Web SDK hatası).
495
+ * Konum paylaşımı (yalnızca ön plan; arka planda koordinat toplanmaz, bölge izleme için `setGeofencingEnabled`).
496
+ * Paylaşım açıkken native SDK konumu oturum başında ve uygulama ön plana döndüğünde en sık 5 dakikada bir push
497
+ * aboneliğine yazar; izin yoksa veya gizlilik onayı verilmemişse hiçbir şey gönderilmez. İlk konum sunucuda KVKK açık
498
+ * rıza kaydı sayılır; `setShared(false)` konumu ve rıza kaydını sildirir. Tercih kalıcıdır. `initialize` öncesinde
499
+ * `setShared`/`requestPermission`/`setGeofencingEnabled` `NOT_READY` ile reddedilir (web: Web SDK hatası).
447
500
  */
448
501
  this.Location = {
449
502
  /** Paylaşımı açar/kapatır (kalıcı). Açılırken izin varsa konum hemen gönderilir; izin için `requestPermission`. */
@@ -467,6 +520,14 @@ class PushizoCore {
467
520
  args.rationale = rationale;
468
521
  return Boolean((await this.bridge.call('requestLocationPermission', args)).permission);
469
522
  },
523
+ /**
524
+ * 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.
527
+ */
528
+ setGeofencingEnabled: (enabled) => this.bridge.call('setGeofencingEnabled', { enabled: Boolean(enabled) }),
529
+ /** Bölge izleme açık mı (kalıcı tercih; izin durumundan bağımsız). */
530
+ isGeofencingEnabled: async () => { var _a; return Boolean((_a = (await this.bridge.call('isGeofencingEnabled'))) === null || _a === void 0 ? void 0 : _a.enabled); },
470
531
  };
471
532
  // --- Live Activities (iOS) ---
472
533
  /**