@pulseboard/react-native 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PulseBoardSDK.podspec +1 -1
- package/ios/PulseBoardNetwork.mm +12 -8
- package/package.json +1 -1
package/PulseBoardSDK.podspec
CHANGED
package/ios/PulseBoardNetwork.mm
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
#import <CoreTelephony/CTCarrier.h>
|
|
5
5
|
#include <arpa/inet.h>
|
|
6
6
|
#include <ifaddrs.h>
|
|
7
|
+
#include <netdb.h> // ← fixes NI_MAXHOST and NI_NUMERICHOST
|
|
8
|
+
#include <sys/socket.h>
|
|
7
9
|
|
|
8
10
|
@implementation PulseBoardNetwork
|
|
9
11
|
|
|
@@ -26,12 +28,13 @@
|
|
|
26
28
|
dispatch_queue_t queue = dispatch_queue_create(
|
|
27
29
|
"com.pulseboard.network", DISPATCH_QUEUE_SERIAL);
|
|
28
30
|
|
|
31
|
+
// ← correct API: set handler first, then start with queue
|
|
29
32
|
nw_path_monitor_set_update_handler(monitor, ^(nw_path_t path) {
|
|
30
33
|
nw_path_monitor_cancel(monitor);
|
|
31
34
|
|
|
32
|
-
BOOL isConnected
|
|
33
|
-
BOOL isWifi
|
|
34
|
-
BOOL isCellular
|
|
35
|
+
BOOL isConnected = nw_path_get_status(path) == nw_path_status_satisfied;
|
|
36
|
+
BOOL isWifi = nw_path_uses_interface_type(path, nw_interface_type_wifi);
|
|
37
|
+
BOOL isCellular = nw_path_uses_interface_type(path, nw_interface_type_cellular);
|
|
35
38
|
|
|
36
39
|
NSString *carrier = @"unknown";
|
|
37
40
|
if (@available(iOS 12.0, *)) {
|
|
@@ -44,10 +47,10 @@
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
NSString *type;
|
|
47
|
-
if (isWifi)
|
|
48
|
-
else if (isCellular)
|
|
49
|
-
else if (isConnected)
|
|
50
|
-
else
|
|
50
|
+
if (isWifi) type = @"wifi";
|
|
51
|
+
else if (isCellular) type = @"cellular";
|
|
52
|
+
else if (isConnected) type = @"unknown";
|
|
53
|
+
else type = @"offline";
|
|
51
54
|
|
|
52
55
|
resolve(@{
|
|
53
56
|
@"type": type,
|
|
@@ -58,7 +61,8 @@
|
|
|
58
61
|
});
|
|
59
62
|
});
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
nw_path_monitor_set_queue(monitor, queue); // ← set queue separately
|
|
65
|
+
nw_path_monitor_start(monitor); // ← then start with no queue arg
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
- (nullable NSString *)getIPAddress {
|