@entrig/capacitor 0.0.4 → 1.0.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/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.1")
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 pod install issues (click to expand)</summary>
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>Notification Service Extension (Optional - for Delivery Tracking)</summary>
135
+ <summary>Troubleshooting SPM / Xcode build issues (click to expand)</summary>
136
136
 
137
- The Notification Service Extension enables delivery status tracking even when your app is killed or in the background.
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
- #### 1. Create Notification Service Extension in Xcode
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
- 1. Open `ios/App/App.xcworkspace`
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
- import UserNotifications
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
- #### 3. Link EntrigSDK framework to the extension target
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
- func application(_ application: UIApplication,
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
@@ -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.10-dev'
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: ${notification.toMap()}")
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: ${notification.toMap()}")
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>",
@@ -14,6 +14,7 @@ export interface EntrigPlugin {
14
14
  init(config: EntrigConfig): Promise<void>;
15
15
  register(options: {
16
16
  userId: string;
17
+ isDebug?: boolean;
17
18
  }): Promise<void>;
18
19
  requestPermission(): Promise<{
19
20
  granted: boolean;
@@ -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"]}
@@ -1,11 +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
4
7
  import class Entrig.Entrig
5
8
  import struct Entrig.EntrigConfig
6
9
  import struct Entrig.NotificationEvent
7
10
  import protocol Entrig.OnNotificationReceivedListener
8
11
  import protocol Entrig.OnNotificationClickListener
12
+ #else
13
+ // CocoaPods - module is EntrigSDK, no name collision
14
+ import EntrigSDK
15
+ #endif
9
16
 
10
17
  @objc(EntrigPlugin)
11
18
  public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedListener, OnNotificationClickListener {
@@ -86,12 +93,14 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
86
93
  return
87
94
  }
88
95
 
89
- // Detect debug mode based on compilation flags
96
+ // Use caller-provided isDebug if present, otherwise fall back to compile-time flag
97
+ let isDebug: Bool
90
98
  #if DEBUG
91
- let isDebug = true
99
+ let defaultDebug = true
92
100
  #else
93
- let isDebug = false
101
+ let defaultDebug = false
94
102
  #endif
103
+ isDebug = call.getBool("isDebug", defaultDebug)
95
104
 
96
105
  Entrig.register(userId: userId, sdk: "capacitor", isDebug: isDebug) { success, error in
97
106
  if success {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entrig/capacitor",
3
- "version": "0.0.4",
3
+ "version": "1.0.0",
4
4
  "description": "Push Notifications for Supabase",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -32,6 +32,10 @@
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",