Commit fceba30a authored by Tobias's avatar Tobias
Browse files

add check if WCSession is supported

parent 303ba32f
...@@ -167,11 +167,12 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize ...@@ -167,11 +167,12 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
setupBlock(); setupBlock();
} }
_watchCommunication = [VLCWatchCommunication sharedInstance]; if ([VLCWatchCommunication isSupported]) {
_watchCommunication = [VLCWatchCommunication sharedInstance];
// TODO: push DB changes instead // TODO: push DB changes instead
// [_watchCommunication startRelayingNotificationName:NSManagedObjectContextDidSaveNotification object:nil]; // [_watchCommunication startRelayingNotificationName:NSManagedObjectContextDidSaveNotification object:nil];
[_watchCommunication startRelayingNotificationName:VLCPlaybackControllerPlaybackMetadataDidChange object:nil]; [_watchCommunication startRelayingNotificationName:VLCPlaybackControllerPlaybackMetadataDidChange object:nil];
}
return YES; return YES;
} }
...@@ -437,7 +438,9 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType ...@@ -437,7 +438,9 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
handleWatchKitExtensionRequest:(NSDictionary *)userInfo handleWatchKitExtensionRequest:(NSDictionary *)userInfo
reply:(void (^)(NSDictionary *))reply reply:(void (^)(NSDictionary *))reply
{ {
[self.watchCommunication session:[WCSession defaultSession] didReceiveMessage:userInfo replyHandler:reply]; if ([VLCWatchCommunication isSupported]) {
[self.watchCommunication session:[WCSession defaultSession] didReceiveMessage:userInfo replyHandler:reply];
}
} }
......
...@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCWatchCommunication : NSObject <WCSessionDelegate> @interface VLCWatchCommunication : NSObject <WCSessionDelegate>
+ (BOOL)isSupported;
+ (instancetype)sharedInstance; + (instancetype)sharedInstance;
- (void)startRelayingNotificationName:(nullable NSString *)name object:(nullable id)object; - (void)startRelayingNotificationName:(nullable NSString *)name object:(nullable id)object;
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
@implementation VLCWatchCommunication @implementation VLCWatchCommunication
+ (BOOL)isSupported {
return [WCSession class] != nil && [WCSession isSupported];
}
- (instancetype)init - (instancetype)init
{ {
self = [super init]; self = [super init];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment