@entrig/capacitor 0.0.5 → 1.0.1
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/Package.swift +1 -1
- package/README.md +12 -66
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/entrig/plugin/capacitor/EntrigPlugin.kt +4 -2
- package/dist/docs.json +2 -2
- package/dist/esm/definitions.d.ts +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/EntrigPlugin/EntrigPlugin.swift +5 -3
- package/package.json +7 -3
package/Package.swift
CHANGED
|
@@ -11,7 +11,7 @@ let package = Package(
|
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
13
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
|
|
14
|
-
.package(url: "https://github.com/entrig/entrig-ios.git", from: "0.0
|
|
14
|
+
.package(url: "https://github.com/entrig/entrig-ios.git", from: "1.0.0")
|
|
15
15
|
],
|
|
16
16
|
targets: [
|
|
17
17
|
.target(
|
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ This automatically configures:
|
|
|
116
116
|
> **Note:** The command creates `.backup` files for safety. You can delete them after verifying everything works.
|
|
117
117
|
|
|
118
118
|
<details>
|
|
119
|
-
<summary>Troubleshooting
|
|
119
|
+
<summary>Troubleshooting CocoaPods issues (click to expand)</summary>
|
|
120
120
|
|
|
121
121
|
If you encounter CocoaPods dependency errors, try cleaning and updating:
|
|
122
122
|
|
|
@@ -132,84 +132,30 @@ pod install
|
|
|
132
132
|
</details>
|
|
133
133
|
|
|
134
134
|
<details>
|
|
135
|
-
<summary>
|
|
135
|
+
<summary>Troubleshooting SPM / Xcode build issues (click to expand)</summary>
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
If you encounter build errors after adding the plugin (e.g., `Cannot convert value of type 'NSUserActivity'`, missing methods on `CAPPluginCall`, or unresolved module errors), try resetting the SPM package cache:
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
1. Open your Xcode project (`ios/App/App.xcworkspace`)
|
|
140
|
+
2. **File → Packages → Reset Package Caches**
|
|
141
|
+
3. **File → Packages → Resolve Package Versions**
|
|
142
|
+
4. **Product → Clean Build Folder** (Cmd+Shift+K)
|
|
143
|
+
5. Build again (Cmd+B)
|
|
140
144
|
|
|
141
|
-
|
|
142
|
-
2. File → New → Target → Notification Service Extension
|
|
143
|
-
3. Product Name: `NotificationService`, Language: Swift
|
|
144
|
-
4. Click "Cancel" when asked to activate scheme
|
|
145
|
-
|
|
146
|
-
#### 2. Update NotificationService.swift
|
|
145
|
+
If you see `Cannot convert value of type 'NSUserActivity' to expected argument type 'URL'` in `AppDelegate.swift`, this is a known Capacitor 8 SPM issue. Replace:
|
|
147
146
|
|
|
148
147
|
```swift
|
|
149
|
-
|
|
150
|
-
import EntrigSDK
|
|
151
|
-
|
|
152
|
-
class NotificationService: UNNotificationServiceExtension {
|
|
153
|
-
|
|
154
|
-
var contentHandler: ((UNNotificationContent) -> Void)?
|
|
155
|
-
var bestAttemptContent: UNMutableNotificationContent?
|
|
156
|
-
|
|
157
|
-
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
158
|
-
self.contentHandler = contentHandler
|
|
159
|
-
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
|
160
|
-
|
|
161
|
-
// Report delivered status to Entrig
|
|
162
|
-
let apiKey = "YOUR_ENTRIG_API_KEY"
|
|
163
|
-
Entrig.reportDelivered(request: request, apiKey: apiKey)
|
|
164
|
-
|
|
165
|
-
if let bestAttemptContent = bestAttemptContent {
|
|
166
|
-
contentHandler(bestAttemptContent)
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
override func serviceExtensionTimeWillExpire() {
|
|
171
|
-
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
|
|
172
|
-
contentHandler(bestAttemptContent)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
148
|
+
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
|
|
176
149
|
```
|
|
177
150
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
In Build Settings for the NotificationService target, ensure the EntrigSDK pod/framework is linked.
|
|
181
|
-
|
|
182
|
-
</details>
|
|
183
|
-
|
|
184
|
-
<details>
|
|
185
|
-
<summary>Manual AppDelegate setup (click to expand)</summary>
|
|
186
|
-
|
|
187
|
-
#### 1. Enable Push Notifications in Xcode
|
|
188
|
-
|
|
189
|
-
- Open `ios/App/App.xcworkspace`
|
|
190
|
-
- Select App target → Signing & Capabilities
|
|
191
|
-
- Click `+ Capability` → Push Notifications
|
|
192
|
-
- Click `+ Capability` → Background Modes → Enable `Remote notifications`
|
|
193
|
-
|
|
194
|
-
#### 2. Update AppDelegate.swift
|
|
195
|
-
|
|
196
|
-
Add the following methods to your `AppDelegate` class:
|
|
151
|
+
with:
|
|
197
152
|
|
|
198
153
|
```swift
|
|
199
|
-
|
|
200
|
-
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
201
|
-
NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
func application(_ application: UIApplication,
|
|
205
|
-
didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
206
|
-
NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
|
|
207
|
-
}
|
|
154
|
+
return true
|
|
208
155
|
```
|
|
209
156
|
|
|
210
157
|
</details>
|
|
211
158
|
|
|
212
|
-
|
|
213
159
|
---
|
|
214
160
|
|
|
215
161
|
## Usage
|
package/android/build.gradle
CHANGED
|
@@ -54,7 +54,7 @@ dependencies {
|
|
|
54
54
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
55
55
|
implementation project(':capacitor-android')
|
|
56
56
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
57
|
-
api 'com.entrig:entrig:0.0
|
|
57
|
+
api 'com.entrig:entrig:1.0.0'
|
|
58
58
|
testImplementation "junit:junit:$junitVersion"
|
|
59
59
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
60
60
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -42,12 +42,12 @@ class EntrigPlugin : Plugin() {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
Entrig.setOnForegroundNotificationListener { notification ->
|
|
45
|
-
Log.d(TAG, "Foreground notification
|
|
45
|
+
Log.d(TAG, "Foreground notification received")
|
|
46
46
|
notifyListeners("onForegroundNotification", notification.toJSObject(isForeground = true))
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
Entrig.setOnNotificationOpenedListener { notification ->
|
|
50
|
-
Log.d(TAG, "Notification opened
|
|
50
|
+
Log.d(TAG, "Notification opened")
|
|
51
51
|
notifyListeners("onNotificationOpened", notification.toJSObject(isForeground = false))
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -83,6 +83,8 @@ class EntrigPlugin : Plugin() {
|
|
|
83
83
|
call.reject("userId is required")
|
|
84
84
|
return
|
|
85
85
|
}
|
|
86
|
+
// isDebug is accepted for API consistency but auto-detected by the Android SDK internally
|
|
87
|
+
// val isDebug = call.getBoolean("isDebug")
|
|
86
88
|
|
|
87
89
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
|
|
88
90
|
getPermissionState("notifications") != PermissionState.GRANTED
|
package/dist/docs.json
CHANGED
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"name": "register",
|
|
28
|
-
"signature": "(options: { userId: string; }) => Promise<void>",
|
|
28
|
+
"signature": "(options: { userId: string; isDebug?: boolean; }) => Promise<void>",
|
|
29
29
|
"parameters": [
|
|
30
30
|
{
|
|
31
31
|
"name": "options",
|
|
32
32
|
"docs": "",
|
|
33
|
-
"type": "{ userId: string; }"
|
|
33
|
+
"type": "{ userId: string; isDebug?: boolean | undefined; }"
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
36
|
"returns": "Promise<void>",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface EntrigConfig {\n apiKey: string;\n handlePermission?: boolean;\n showForegroundNotification?: boolean;\n}\n\nexport interface NotificationEvent {\n title: string;\n body: string;\n data: Record<string, any>;\n isForeground: boolean;\n}\n\nexport interface EntrigPlugin {\n init(config: EntrigConfig): Promise<void>;\n register(options: { userId: string }): Promise<void>;\n requestPermission(): Promise<{ granted: boolean }>;\n unregister(): Promise<void>;\n getInitialNotification(): Promise<NotificationEvent | null>;\n\n addListener(\n eventName: 'onForegroundNotification',\n listenerFunc: (event: NotificationEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: 'onNotificationOpened',\n listenerFunc: (event: NotificationEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n removeAllListeners(): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface EntrigConfig {\n apiKey: string;\n handlePermission?: boolean;\n showForegroundNotification?: boolean;\n}\n\nexport interface NotificationEvent {\n title: string;\n body: string;\n data: Record<string, any>;\n isForeground: boolean;\n}\n\nexport interface EntrigPlugin {\n init(config: EntrigConfig): Promise<void>;\n register(options: { userId: string; isDebug?: boolean }): Promise<void>;\n requestPermission(): Promise<{ granted: boolean }>;\n unregister(): Promise<void>;\n getInitialNotification(): Promise<NotificationEvent | null>;\n\n addListener(\n eventName: 'onForegroundNotification',\n listenerFunc: (event: NotificationEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: 'onNotificationOpened',\n listenerFunc: (event: NotificationEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n removeAllListeners(): Promise<void>;\n}\n"]}
|
|
@@ -93,12 +93,14 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
|
|
|
93
93
|
return
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
//
|
|
96
|
+
// Use caller-provided isDebug if present, otherwise fall back to compile-time flag
|
|
97
|
+
let isDebug: Bool
|
|
97
98
|
#if DEBUG
|
|
98
|
-
let
|
|
99
|
+
let defaultDebug = true
|
|
99
100
|
#else
|
|
100
|
-
let
|
|
101
|
+
let defaultDebug = false
|
|
101
102
|
#endif
|
|
103
|
+
isDebug = call.getBool("isDebug", defaultDebug)
|
|
102
104
|
|
|
103
105
|
Entrig.register(userId: userId, sdk: "capacitor", isDebug: isDebug) { success, error in
|
|
104
106
|
if success {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entrig/capacitor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Push Notifications for Supabase",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -22,16 +22,20 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/entrig/capacitor.git"
|
|
25
|
+
"url": "git+https://github.com/entrig/entrig-capacitor.git"
|
|
26
26
|
},
|
|
27
27
|
"bugs": {
|
|
28
|
-
"url": "https://github.com/entrig/capacitor/issues"
|
|
28
|
+
"url": "https://github.com/entrig/entrig-capacitor/issues"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
|
31
31
|
"capacitor",
|
|
32
32
|
"plugin",
|
|
33
33
|
"native"
|
|
34
34
|
],
|
|
35
|
+
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
35
39
|
"scripts": {
|
|
36
40
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
37
41
|
"verify:ios": "xcodebuild -scheme EntrigCapacitor -destination generic/platform=iOS",
|