Skip to content

Commit 3fd2d77

Browse files
guangyaoguangyao
authored andcommitted
2 parents f91b35a + 111c958 commit 3fd2d77

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

AppCacheUtil.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
import { NativeModules,Platform } from 'react-native';
2+
import { NativeModules,Platform, NetInfo } from 'react-native';
33

44
const { RNNeteaseIm } = NativeModules;
55

@@ -21,8 +21,16 @@ export default class AppCacheUtil{
2121
/**
2222
* 获取网络状态
2323
*/
24-
static getNetWorkStatus(){//0:无网络,1:有网络
25-
return RNNeteaseIm.getNetWorkStatus();
24+
static networkIsConnected(){//0:无网络,1:有网络
25+
if(Platform.OS === 'ios'){
26+
if(RNNeteaseIm.getNetWorkStatus() === '1'){
27+
return true;
28+
}
29+
return false;
30+
}else{
31+
return NetInfo.isConnected.fetch().done();
32+
}
2633
}
34+
2735
}
2836

0 commit comments

Comments
 (0)