Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2017 Google
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
#import <Foundation/Foundation.h>
18
#if !TARGET_OS_WATCH
19
#import <SystemConfiguration/SystemConfiguration.h>
20
#endif
21
 
22
/// Reachability Status
23
typedef enum {
24
  kGULReachabilityUnknown,  ///< Have not yet checked or been notified whether host is reachable.
25
  kGULReachabilityNotReachable,  ///< Host is not reachable.
26
  kGULReachabilityViaWifi,       ///< Host is reachable via Wifi.
27
  kGULReachabilityViaCellular,   ///< Host is reachable via cellular.
28
} GULReachabilityStatus;
29
 
30
const NSString *GULReachabilityStatusString(GULReachabilityStatus status);
31
 
32
@class GULReachabilityChecker;
33
 
34
/// Google Analytics iOS Reachability Checker.
35
@protocol GULReachabilityDelegate
36
@required
37
/// Called when network status has changed.
38
- (void)reachability:(GULReachabilityChecker *)reachability
39
       statusChanged:(GULReachabilityStatus)status;
40
@end
41
 
42
/// Google Analytics iOS Network Status Checker.
43
@interface GULReachabilityChecker : NSObject
44
 
45
/// The last known reachability status, or GULReachabilityStatusUnknown if the
46
/// checker is not active.
47
@property(nonatomic, readonly) GULReachabilityStatus reachabilityStatus;
48
/// The host to which reachability status is to be checked.
49
@property(nonatomic, copy, readonly) NSString *host;
50
/// The delegate to be notified of reachability status changes.
51
@property(nonatomic, weak) id<GULReachabilityDelegate> reachabilityDelegate;
52
/// `YES` if the reachability checker is active, `NO` otherwise.
53
@property(nonatomic, readonly) BOOL isActive;
54
 
55
/// Initialize the reachability checker. Note that you must call start to begin checking for and
56
/// receiving notifications about network status changes.
57
///
58
/// @param reachabilityDelegate The delegate to be notified when reachability status to host
59
/// changes.
60
///
61
/// @param host The name of the host.
62
///
63
- (instancetype)initWithReachabilityDelegate:(id<GULReachabilityDelegate>)reachabilityDelegate
64
                                    withHost:(NSString *)host;
65
 
66
- (instancetype)init NS_UNAVAILABLE;
67
 
68
/// Start checking for reachability to the specified host. This has no effect if the status
69
/// checker is already checking for connectivity.
70
///
71
/// @return `YES` if initiating status checking was successful or the status checking has already
72
/// been initiated, `NO` otherwise.
73
- (BOOL)start;
74
 
75
/// Stop checking for reachability to the specified host. This has no effect if the status
76
/// checker is not checking for connectivity.
77
- (void)stop;
78
 
79
@end