1 /* 2 * 3 * Copyright 2016 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #import <Foundation/Foundation.h> 20 #import <SystemConfiguration/SystemConfiguration.h> 21 22 typedef NS_ENUM(NSInteger, GRPCConnectivityStatus) { 23 GRPCConnectivityUnknown = 0, 24 GRPCConnectivityNoNetwork = 1, 25 GRPCConnectivityCellular = 2, 26 GRPCConnectivityWiFi = 3, 27 }; 28 29 extern NSString* _Nonnull kGRPCConnectivityNotification; 30 31 // This interface monitors OS reachability interface for any network status 32 // change. Parties interested in these events should register themselves as 33 // observer. 34 @interface GRPCConnectivityMonitor : NSObject 35 36 - (nonnull instancetype)init NS_UNAVAILABLE; 37 38 // Register an object as observer of network status change. \a observer 39 // must have a notification method with one parameter of type 40 // (NSNotification *) and should pass it to parameter \a selector. The 41 // parameter of this notification method is not used for now. 42 + (void)registerObserver:(_Nonnull id)observer selector:(_Nonnull SEL)selector; 43 44 // Ungegister an object from observers of network status change. 45 + (void)unregisterObserver:(_Nonnull id)observer; 46 47 @end 48