@virex-tech/paywallo-sdk 1.1.1 → 1.1.3

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.
@@ -9,6 +9,7 @@
9
9
  @property (nonatomic, copy) NSString *injectedJavaScript;
10
10
  @property (nonatomic, copy) RCTDirectEventBlock onMessage;
11
11
  @property (nonatomic, copy) RCTDirectEventBlock onLoadEnd;
12
+ @property (nonatomic, copy) RCTDirectEventBlock onError;
12
13
 
13
14
  - (void)injectJavaScript:(NSString *)script;
14
15
 
@@ -147,10 +147,30 @@
147
147
 
148
148
  - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
149
149
  {
150
+ NSString *urlString = webView.URL ? webView.URL.absoluteString : @"";
151
+ NSDictionary *errorInfo = @{
152
+ @"code": @(error.code),
153
+ @"description": error.localizedDescription ?: @"",
154
+ @"url": urlString
155
+ };
156
+ if (self.onError) {
157
+ self.onError(@{@"type": @"error", @"payload": errorInfo});
158
+ }
159
+ [PaywalloWebViewModule emitWebViewError:errorInfo];
150
160
  }
151
161
 
152
162
  - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
153
163
  {
164
+ NSString *urlString = webView.URL ? webView.URL.absoluteString : @"";
165
+ NSDictionary *errorInfo = @{
166
+ @"code": @(error.code),
167
+ @"description": error.localizedDescription ?: @"",
168
+ @"url": urlString
169
+ };
170
+ if (self.onError) {
171
+ self.onError(@{@"type": @"error", @"payload": errorInfo});
172
+ }
173
+ [PaywalloWebViewModule emitWebViewError:errorInfo];
154
174
  }
155
175
 
156
176
  - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
@@ -20,6 +20,7 @@ RCT_EXPORT_VIEW_PROPERTY(sourceHtml, NSString)
20
20
  RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
21
21
  RCT_EXPORT_VIEW_PROPERTY(onMessage, RCTDirectEventBlock)
22
22
  RCT_EXPORT_VIEW_PROPERTY(onLoadEnd, RCTDirectEventBlock)
23
+ RCT_EXPORT_VIEW_PROPERTY(onError, RCTDirectEventBlock)
23
24
 
24
25
  RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
25
26
  {
@@ -4,5 +4,6 @@
4
4
 
5
5
  + (void)emitWebViewMessage:(NSDictionary *)message;
6
6
  + (void)emitWebViewLoadEnd;
7
+ + (void)emitWebViewError:(NSDictionary *)errorPayload;
7
8
 
8
9
  @end
@@ -17,7 +17,7 @@ RCT_EXPORT_MODULE(PaywalloWebViewModule);
17
17
 
18
18
  - (NSArray<NSString *> *)supportedEvents
19
19
  {
20
- return @[@"PaywalloWebViewMessage", @"PaywalloWebViewLoadEnd"];
20
+ return @[@"PaywalloWebViewMessage", @"PaywalloWebViewLoadEnd", @"PaywalloWebViewError"];
21
21
  }
22
22
 
23
23
  + (void)emitWebViewMessage:(NSDictionary *)message
@@ -34,6 +34,13 @@ RCT_EXPORT_MODULE(PaywalloWebViewModule);
34
34
  }
35
35
  }
36
36
 
37
+ + (void)emitWebViewError:(NSDictionary *)errorPayload
38
+ {
39
+ if (sharedInstance) {
40
+ [sharedInstance sendEventWithName:@"PaywalloWebViewError" body:errorPayload];
41
+ }
42
+ }
43
+
37
44
  + (BOOL)requiresMainQueueSetup
38
45
  {
39
46
  return YES;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virex-tech/paywallo-sdk",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "SDK React Native para integração com Paywallo - Paywalls, Subscriptions e Analytics",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",