@entrig/capacitor 0.0.3 → 0.0.5
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,7 +1,18 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
3
|
import UserNotifications
|
|
4
|
+
|
|
5
|
+
#if canImport(Entrig)
|
|
6
|
+
// SPM - specific imports to avoid module/class name collision
|
|
7
|
+
import class Entrig.Entrig
|
|
8
|
+
import struct Entrig.EntrigConfig
|
|
9
|
+
import struct Entrig.NotificationEvent
|
|
10
|
+
import protocol Entrig.OnNotificationReceivedListener
|
|
11
|
+
import protocol Entrig.OnNotificationClickListener
|
|
12
|
+
#else
|
|
13
|
+
// CocoaPods - module is EntrigSDK, no name collision
|
|
4
14
|
import EntrigSDK
|
|
15
|
+
#endif
|
|
5
16
|
|
|
6
17
|
@objc(EntrigPlugin)
|
|
7
18
|
public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedListener, OnNotificationClickListener {
|
|
@@ -56,27 +67,29 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
|
|
|
56
67
|
// MARK: - Plugin Methods
|
|
57
68
|
|
|
58
69
|
@objc func `init`(_ call: CAPPluginCall) {
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
let apiKey = call.getString("apiKey", "")
|
|
71
|
+
guard !apiKey.isEmpty else {
|
|
72
|
+
call.unavailable("API key is required and cannot be empty")
|
|
61
73
|
return
|
|
62
74
|
}
|
|
63
75
|
|
|
64
|
-
let handlePermission = call.getBool("handlePermission"
|
|
65
|
-
let showForegroundNotification = call.getBool("showForegroundNotification"
|
|
76
|
+
let handlePermission = call.getBool("handlePermission", true)
|
|
77
|
+
let showForegroundNotification = call.getBool("showForegroundNotification", true)
|
|
66
78
|
let config = EntrigConfig(apiKey: apiKey, handlePermission: handlePermission, showForegroundNotification: showForegroundNotification)
|
|
67
79
|
|
|
68
80
|
Entrig.configure(config: config) { success, error in
|
|
69
81
|
if success {
|
|
70
82
|
call.resolve()
|
|
71
83
|
} else {
|
|
72
|
-
call.
|
|
84
|
+
call.unavailable(error ?? "Failed to initialize SDK")
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
@objc func register(_ call: CAPPluginCall) {
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
let userId = call.getString("userId", "")
|
|
91
|
+
guard !userId.isEmpty else {
|
|
92
|
+
call.unavailable("userId is required")
|
|
80
93
|
return
|
|
81
94
|
}
|
|
82
95
|
|
|
@@ -91,7 +104,7 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
|
|
|
91
104
|
if success {
|
|
92
105
|
call.resolve()
|
|
93
106
|
} else {
|
|
94
|
-
call.
|
|
107
|
+
call.unavailable(error ?? "Registration failed")
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
110
|
}
|
|
@@ -99,7 +112,7 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
|
|
|
99
112
|
@objc func requestPermission(_ call: CAPPluginCall) {
|
|
100
113
|
Entrig.requestPermission { granted, error in
|
|
101
114
|
if let error = error {
|
|
102
|
-
call.
|
|
115
|
+
call.unavailable(error.localizedDescription)
|
|
103
116
|
} else {
|
|
104
117
|
call.resolve(["granted": granted])
|
|
105
118
|
}
|
|
@@ -111,7 +124,7 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
|
|
|
111
124
|
if success {
|
|
112
125
|
call.resolve()
|
|
113
126
|
} else {
|
|
114
|
-
call.
|
|
127
|
+
call.unavailable(error ?? "Unregistration failed")
|
|
115
128
|
}
|
|
116
129
|
}
|
|
117
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entrig/capacitor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Push Notifications for Supabase",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"dist/",
|
|
17
17
|
"ios/Sources",
|
|
18
18
|
"ios/Tests",
|
|
19
|
-
"Package.swift"
|
|
20
|
-
"EntrigCapacitor.podspec"
|
|
19
|
+
"Package.swift"
|
|
21
20
|
],
|
|
22
21
|
"author": "entrig",
|
|
23
22
|
"license": "MIT",
|
package/EntrigCapacitor.podspec
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'json'
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = 'EntrigCapacitor'
|
|
7
|
-
s.version = package['version']
|
|
8
|
-
s.summary = package['description']
|
|
9
|
-
s.license = package['license']
|
|
10
|
-
s.homepage = package['repository']['url']
|
|
11
|
-
s.author = package['author']
|
|
12
|
-
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
-
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '15.0'
|
|
15
|
-
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'EntrigSDK', '0.0.1'
|
|
17
|
-
s.swift_version = '5.9'
|
|
18
|
-
end
|