@neoskola/auto-play 0.2.12 → 0.2.14

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.
@@ -73,21 +73,20 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
73
73
  /// Pushes CPNowPlayingTemplate using ObjC @try/@catch to prevent crash from NSException.
74
74
  private func pushNowPlayingTemplateSafely(animated: Bool) async -> Bool {
75
75
  return await withCheckedContinuation { continuation in
76
- var pushError: NSError?
77
- let success = ObjCExceptionCatcher.tryBlock({
78
- self.interfaceController.pushTemplate(
79
- CPNowPlayingTemplate.shared,
80
- animated: animated
81
- ) { success, error in
82
- if let error = error {
83
- print("[AutoPlay] CPNowPlayingTemplate push completion error: \(error)")
76
+ do {
77
+ try ObjCExceptionCatcher.execute {
78
+ self.interfaceController.pushTemplate(
79
+ CPNowPlayingTemplate.shared,
80
+ animated: animated
81
+ ) { success, error in
82
+ if let error = error {
83
+ print("[AutoPlay] CPNowPlayingTemplate push completion error: \(error)")
84
+ }
85
+ continuation.resume(returning: success)
84
86
  }
85
- continuation.resume(returning: success)
86
87
  }
87
- }, error: &pushError)
88
-
89
- if !success {
90
- print("[AutoPlay] CPNowPlayingTemplate push threw ObjC exception: \(pushError?.localizedDescription ?? "unknown")")
88
+ } catch {
89
+ print("[AutoPlay] CPNowPlayingTemplate push threw ObjC exception: \(error.localizedDescription)")
91
90
  continuation.resume(returning: false)
92
91
  }
93
92
  }
@@ -6,7 +6,7 @@
6
6
  /// with CPNowPlayingTemplate). This wrapper makes those exceptions catchable.
7
7
  @interface ObjCExceptionCatcher : NSObject
8
8
 
9
- + (BOOL)tryBlock:(void(NS_NOESCAPE ^_Nonnull)(void))tryBlock
10
- error:(NSError * _Nullable * _Nullable)error;
9
+ + (BOOL)executeBlock:(void(NS_NOESCAPE ^_Nonnull)(void))block
10
+ error:(NSError * _Nullable * _Nullable)error;
11
11
 
12
12
  @end
@@ -2,9 +2,9 @@
2
2
 
3
3
  @implementation ObjCExceptionCatcher
4
4
 
5
- + (BOOL)tryBlock:(void(NS_NOESCAPE ^)(void))tryBlock error:(NSError **)error {
5
+ + (BOOL)executeBlock:(void(NS_NOESCAPE ^)(void))block error:(NSError **)error {
6
6
  @try {
7
- tryBlock();
7
+ block();
8
8
  return YES;
9
9
  } @catch (NSException *exception) {
10
10
  NSLog(@"[ObjCExceptionCatcher] Caught exception: %@ — %@", exception.name, exception.reason);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neoskola/auto-play",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",