@entrig/capacitor 0.0.3 → 0.0.4

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,11 @@
1
1
  import Foundation
2
2
  import Capacitor
3
3
  import UserNotifications
4
- import EntrigSDK
4
+ import class Entrig.Entrig
5
+ import struct Entrig.EntrigConfig
6
+ import struct Entrig.NotificationEvent
7
+ import protocol Entrig.OnNotificationReceivedListener
8
+ import protocol Entrig.OnNotificationClickListener
5
9
 
6
10
  @objc(EntrigPlugin)
7
11
  public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedListener, OnNotificationClickListener {
@@ -56,27 +60,29 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
56
60
  // MARK: - Plugin Methods
57
61
 
58
62
  @objc func `init`(_ call: CAPPluginCall) {
59
- guard let apiKey = call.getString("apiKey"), !apiKey.isEmpty else {
60
- call.reject("API key is required and cannot be empty")
63
+ let apiKey = call.getString("apiKey", "")
64
+ guard !apiKey.isEmpty else {
65
+ call.unavailable("API key is required and cannot be empty")
61
66
  return
62
67
  }
63
68
 
64
- let handlePermission = call.getBool("handlePermission") ?? true
65
- let showForegroundNotification = call.getBool("showForegroundNotification") ?? true
69
+ let handlePermission = call.getBool("handlePermission", true)
70
+ let showForegroundNotification = call.getBool("showForegroundNotification", true)
66
71
  let config = EntrigConfig(apiKey: apiKey, handlePermission: handlePermission, showForegroundNotification: showForegroundNotification)
67
72
 
68
73
  Entrig.configure(config: config) { success, error in
69
74
  if success {
70
75
  call.resolve()
71
76
  } else {
72
- call.reject(error ?? "Failed to initialize SDK")
77
+ call.unavailable(error ?? "Failed to initialize SDK")
73
78
  }
74
79
  }
75
80
  }
76
81
 
77
82
  @objc func register(_ call: CAPPluginCall) {
78
- guard let userId = call.getString("userId"), !userId.isEmpty else {
79
- call.reject("userId is required")
83
+ let userId = call.getString("userId", "")
84
+ guard !userId.isEmpty else {
85
+ call.unavailable("userId is required")
80
86
  return
81
87
  }
82
88
 
@@ -91,7 +97,7 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
91
97
  if success {
92
98
  call.resolve()
93
99
  } else {
94
- call.reject(error ?? "Registration failed")
100
+ call.unavailable(error ?? "Registration failed")
95
101
  }
96
102
  }
97
103
  }
@@ -99,7 +105,7 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
99
105
  @objc func requestPermission(_ call: CAPPluginCall) {
100
106
  Entrig.requestPermission { granted, error in
101
107
  if let error = error {
102
- call.reject(error.localizedDescription)
108
+ call.unavailable(error.localizedDescription)
103
109
  } else {
104
110
  call.resolve(["granted": granted])
105
111
  }
@@ -111,7 +117,7 @@ public class EntrigPlugin: CAPPlugin, CAPBridgedPlugin, OnNotificationReceivedLi
111
117
  if success {
112
118
  call.resolve()
113
119
  } else {
114
- call.reject(error ?? "Unregistration failed")
120
+ call.unavailable(error ?? "Unregistration failed")
115
121
  }
116
122
  }
117
123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entrig/capacitor",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
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",
@@ -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