Skip to content

Commit 8494483

Browse files
committed
Merge pull request hyperfiction#19 from hyperfiction/fix/ios-networkinfos
Fix/ios networkinfos
2 parents 0ddde36 + 7d270f9 commit 8494483

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

haxelib.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"license": "MIT",
55
"tags": ["hyperfiction","android","ios","connectivity","uuid","density"],
66
"description": "OpenFl native (Android / iOS) toolkit",
7-
"version": "0.1.9",
8-
"releasenote": "Fix missing joda-time initialization",
7+
"version": "0.2.1",
8+
"releasenote": "Fix iOS reachability change listener",
99
"contributors": ["shoebox"] ,
1010
"dependencies": {
1111
"inthebox-macros":""
1212
}
13-
}
13+
}

hypsystem/system/Device.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ class Device
9292
return "x.0";
9393
}
9494

95-
}
95+
}
1.3 KB
Binary file not shown.

ndll/iPhone/libhypsystem.iphoneos.a

2.34 KB
Binary file not shown.

ndll/iPhone/libhypsystem.iphonesim.a

1.53 KB
Binary file not shown.

project/iPhone/NetworkInfos.mm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
@interface NetworkInfos:NSObject
1111

12+
@property (retain, nonatomic) Reachability* reach;
13+
1214
+(NetworkInfos *) getInstance;
1315

1416
-(bool)isConnected;
@@ -19,6 +21,8 @@ -(int)getActiveConnectionType;
1921

2022
@implementation NetworkInfos
2123

24+
@synthesize reach;
25+
2226
+(NetworkInfos *)getInstance
2327
{
2428
static NetworkInfos *instance;
@@ -36,15 +40,14 @@ -(id)init
3640
{
3741
if( self == [super init])
3842
{
39-
43+
self.reach = [Reachability reachabilityForInternetConnection]; //retain reach
4044
}
4145
return self;
4246
}
4347

4448
-(NetworkStatus)getStatus
4549
{
46-
Reachability *reachability = [Reachability reachabilityForInternetConnection];
47-
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
50+
NetworkStatus networkStatus = [self.reach currentReachabilityStatus];
4851
return networkStatus;
4952
}
5053

@@ -56,22 +59,20 @@ -(bool)isConnected
5659

5760
-(bool)isWifi
5861
{
59-
NSLog(@"isWifi");
6062
NetworkStatus networkStatus = [self getStatus];
6163
return networkStatus == ReachableViaWiFi;
6264
}
6365

6466
-(void)listen
6567
{
66-
NSLog(@"listen");
6768
[[NSNotificationCenter defaultCenter] addObserver:self
6869
selector:@selector(statusUpdated:) name:kReachabilityChangedNotification
6970
object:nil];
71+
[self.reach startNotifier];
7072
}
7173

7274
-(void)statusUpdated:(NSNotification*)notification
7375
{
74-
NSLog(@"statusUpdated");
7576
hypsystem_networkinterface_onUpdate();
7677
}
7778

@@ -124,4 +125,4 @@ bool isWifi()
124125
return result;
125126
}
126127

127-
}
128+
}

project/iPhone/Reachability.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
6060

6161
#pragma mark - Supporting functions
6262

63-
#define kShouldPrintReachabilityFlags 1
63+
#define kShouldPrintReachabilityFlags 0
6464

6565
static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
6666
{

0 commit comments

Comments
 (0)