diff --git a/Parse.xcodeproj/project.pbxproj b/Parse.xcodeproj/project.pbxproj index f8c5459a5..5fd2bc0e0 100644 --- a/Parse.xcodeproj/project.pbxproj +++ b/Parse.xcodeproj/project.pbxproj @@ -229,7 +229,6 @@ 810155F41BB3832700D7C7BD /* PFMutableObjectState.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CB7F731B166FF500DC601D /* PFMutableObjectState.h */; }; 810155F51BB3832700D7C7BD /* PFWeakValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C1EE471AE1EF960031C438 /* PFWeakValue.h */; }; 810155F61BB3832700D7C7BD /* PFOfflineStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 8166FCA41B503886003841A2 /* PFOfflineStore.h */; }; - 810155F71BB3832700D7C7BD /* PFReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 81329E8C1AE1E8840071EE3E /* PFReachability.h */; }; 810155F81BB3832700D7C7BD /* PFMutableQueryState.h in Headers */ = {isa = PBXBuildFile; fileRef = 81C7F4A71AF42BD9007B5418 /* PFMutableQueryState.h */; }; 810155F91BB3832700D7C7BD /* PFPaymentTransactionObserver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = F5B0B3121B44A05100F3EBC4 /* PFPaymentTransactionObserver_Private.h */; }; 810155FA1BB3832700D7C7BD /* PFPushState_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 81CB7F981B17970400DC601D /* PFPushState_Private.h */; }; @@ -3528,7 +3527,6 @@ 810155F41BB3832700D7C7BD /* PFMutableObjectState.h in Headers */, 810155F51BB3832700D7C7BD /* PFWeakValue.h in Headers */, 810155F61BB3832700D7C7BD /* PFOfflineStore.h in Headers */, - 810155F71BB3832700D7C7BD /* PFReachability.h in Headers */, 810155F81BB3832700D7C7BD /* PFMutableQueryState.h in Headers */, 810155F91BB3832700D7C7BD /* PFPaymentTransactionObserver_Private.h in Headers */, 810155FA1BB3832700D7C7BD /* PFPushState_Private.h in Headers */, diff --git a/Parse/Internal/PFEventuallyQueue.h b/Parse/Internal/PFEventuallyQueue.h index 3a4411ba9..0ac4ea14f 100644 --- a/Parse/Internal/PFEventuallyQueue.h +++ b/Parse/Internal/PFEventuallyQueue.h @@ -36,7 +36,7 @@ extern NSTimeInterval const PFEventuallyQueueDefaultTimeoutRetryInterval; Controls whether the queue should monitor network reachability and pause itself when there is no connection. Default: `YES`. */ -@property (atomic, assign, readonly) BOOL monitorsReachability; +@property (atomic, assign, readonly) BOOL monitorsReachability PF_WATCH_UNAVAILABLE; @property (nonatomic, assign, readonly, getter=isConnected) BOOL connected; // Gets notifications of various events happening in the command cache, so that tests can be synchronized. diff --git a/Parse/Internal/PFEventuallyQueue.m b/Parse/Internal/PFEventuallyQueue.m index f5e536c6f..80e025d7c 100644 --- a/Parse/Internal/PFEventuallyQueue.m +++ b/Parse/Internal/PFEventuallyQueue.m @@ -27,7 +27,10 @@ NSUInteger const PFEventuallyQueueDefaultMaxAttemptsCount = 5; NSTimeInterval const PFEventuallyQueueDefaultTimeoutRetryInterval = 600.0f; -@interface PFEventuallyQueue () +@interface PFEventuallyQueue () +#if !TARGET_OS_WATCH + +#endif @property (atomic, assign, readwrite) BOOL monitorsReachability; @property (atomic, assign, getter=isRunning) BOOL running; @@ -360,6 +363,9 @@ - (BFTask *)_waitForOperationSet:(PFOperationSet *)operationSet ///-------------------------------------- - (void)_startMonitoringNetworkReachability { +#if TARGET_OS_WATCH + self.connected = YES; +#else if (self.monitorsReachability) { return; } @@ -369,24 +375,20 @@ - (void)_startMonitoringNetworkReachability { // Set the initial connected status self.connected = ([PFReachability sharedParseReachability].currentState != PFReachabilityStateNotReachable); +#endif } - (void)_stopMonitoringNetworkReachability { +#if !TARGET_OS_WATCH if (!self.monitorsReachability) { return; } [[PFReachability sharedParseReachability] removeListener:self]; - if (_reachability != NULL) { - SCNetworkReachabilitySetCallback(_reachability, NULL, NULL); - SCNetworkReachabilitySetDispatchQueue(_reachability, NULL); - CFRelease(_reachability); - _reachability = NULL; - } - self.monitorsReachability = NO; self.connected = YES; +#endif } ///-------------------------------------- @@ -454,6 +456,8 @@ - (void)_setRetryInterval:(NSTimeInterval)retryInterval { _retryInterval = retryInterval; } +#if !TARGET_OS_WATCH + ///-------------------------------------- #pragma mark - Reachability ///-------------------------------------- @@ -464,6 +468,8 @@ - (void)reachability:(PFReachability *)reachability didChangeReachabilityState:( } } +#endif + @end // PFEventuallyQueueTestHelper gets notifications of various events happening in the command cache, diff --git a/Parse/Internal/PFEventuallyQueue_Private.h b/Parse/Internal/PFEventuallyQueue_Private.h index b7ec91853..3e576f330 100644 --- a/Parse/Internal/PFEventuallyQueue_Private.h +++ b/Parse/Internal/PFEventuallyQueue_Private.h @@ -7,8 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import - #import "PFEventuallyQueue.h" @class BFExecutor; @@ -28,10 +26,6 @@ extern NSTimeInterval const PFEventuallyQueueDefaultTimeoutRetryInterval; BFExecutor *_synchronizationExecutor; dispatch_queue_t _synchronizationQueue; - // Object for getting network status. - SCNetworkReachabilityRef _reachability; - dispatch_queue_t _reachabilityQueue; - @private dispatch_queue_t _processingQueue; dispatch_source_t _processingQueueSource; diff --git a/Parse/Internal/PFReachability.h b/Parse/Internal/PFReachability.h index 85c622ebb..8e6242a98 100644 --- a/Parse/Internal/PFReachability.h +++ b/Parse/Internal/PFReachability.h @@ -8,7 +8,8 @@ */ #import -#import + +#import @class PFReachability; @@ -26,7 +27,7 @@ typedef NS_ENUM(uint8_t, PFReachabilityState) { @end -@interface PFReachability : NSObject +PF_WATCH_UNAVAILABLE @interface PFReachability : NSObject @property (nonatomic, assign, readonly) PFReachabilityState currentState; diff --git a/Parse/Internal/PFReachability.m b/Parse/Internal/PFReachability.m index a9a0f8669..b14c7e09b 100644 --- a/Parse/Internal/PFReachability.m +++ b/Parse/Internal/PFReachability.m @@ -9,6 +9,8 @@ #import "PFReachability.h" +#import + #import "PFAssert.h" #import "PFConstants.h" #import "PFLogging.h" diff --git a/Parse/PFConstants.h b/Parse/PFConstants.h index ce1a703be..0c29ec297 100644 --- a/Parse/PFConstants.h +++ b/Parse/PFConstants.h @@ -483,15 +483,27 @@ extern NSString *const PF_NONNULL_S PFNetworkNotificationURLResponseBodyUserInfo ///-------------------------------------- #ifndef TARGET_OS_IOS -#define TARGET_OS_IOS TARGET_OS_IPHONE +# define TARGET_OS_IOS TARGET_OS_IPHONE #endif #ifndef TARGET_OS_WATCH -#define TARGET_OS_WATCH 0 +# define TARGET_OS_WATCH 0 #endif #ifndef TARGET_OS_TV -#define TARGET_OS_TV 0 +# define TARGET_OS_TV 0 #endif #ifndef PF_TARGET_OS_OSX # define PF_TARGET_OS_OSX TARGET_OS_MAC && !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV #endif + +///-------------------------------------- +/// @name Avaiability Macros +///-------------------------------------- + +#ifndef PF_WATCH_UNAVAILABLE +# ifdef __WATCHOS_UNAVAILABLE +# define PF_WATCH_UNAVAILABLE __WATCHOS_UNAVAILABLE +# else +# define PF_WATCH_UNAVAILABLE +# endif +#endif