Skip to content

Commit 8f9ada2

Browse files
guangyaoguangyao
authored andcommitted
增加iPhone X的判断
1 parent 809ff83 commit 8f9ada2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ios/RNNeteaseIm/RNNeteaseIm/RNNeteaseIm.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#import "RCTUtils.h"
1111
#import "RNNotificationCenter.h"
1212

13+
#define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
14+
15+
1316
@implementation RNNeteaseIm
1417

1518
- (void)dealloc{
@@ -776,15 +779,19 @@ -(void)setSendState{
776779
};
777780
}
778781

779-
//开启录音权限
782+
//获取网络状态权限
780783
RCT_EXPORT_METHOD(getNetWorkStatus:(RCTPromiseResolveBlock)resolve
781784
reject:(RCTPromiseRejectBlock)reject){
782-
UIApplication *app = [UIApplication sharedApplication];
783-
NSArray *children = [[[app valueForKeyPath:@"statusBar"] valueForKeyPath:@"foregroundView"] subviews];
784785
int type = 0;//0:无网络, 1:2G, 2:3G, 3:4G, 4:LTE准4G,5:wifi
785-
for (id child in children) {
786-
if ([child isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
787-
type = [[child valueForKeyPath:@"dataNetworkType"] intValue];
786+
if (kDevice_Is_iPhoneX){//iPhone X 目前未找到获取状态栏网络状态,先设置为1
787+
type = 1;
788+
}else{
789+
UIApplication *app = [UIApplication sharedApplication];
790+
NSArray *children = [[[app valueForKeyPath:@"statusBar"] valueForKeyPath:@"foregroundView"] subviews];
791+
for (id child in children) {
792+
if ([child isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
793+
type = [[child valueForKeyPath:@"dataNetworkType"] intValue];
794+
}
788795
}
789796
}
790797
if (type) {

0 commit comments

Comments
 (0)