Skip to content

Commit 756ea2a

Browse files
committed
fix myavatar is blank bug
1 parent 31f540e commit 756ea2a

File tree

7 files changed

+156
-16
lines changed

7 files changed

+156
-16
lines changed

example/app/routes/Home/MyInfo/index.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import React from 'react';
44
import ReactNative from 'react-native';
5+
56
import JMessage from 'jmessage-react-plugin';
67
import {
78
TabNavigator
89
} from 'react-navigation';
910

11+
var RNFS = require('react-native-fs');
12+
1013
import ListItem from '../../../views/ListItem'
1114

1215
const {
@@ -60,12 +63,27 @@ export default class MyNotificationsScreen extends React.Component {
6063
constructor(props) {
6164
super(props)
6265
this.state = {
63-
myInfo: {}
66+
myInfo: {},
67+
headerImage: "",
6468
}
6569
}
6670
componentWillMount() {
6771
JMessage.getMyInfo((user) => {
68-
this.setState({myInfo: user})
72+
Alert.alert("RNFS.MainBundlePath",RNFS.MainBundlePath)
73+
Alert.alert("user.avatarThumbPath",user.avatarThumbPath)
74+
this.setState({myInfo: user,})
75+
RNFS.readFile(user.avatarThumbPath,'base64')
76+
.then((data)=>{
77+
//字符串转json
78+
this.setState({myInfo: 'data:image/png;base64,' + data,})
79+
this.setState({headerImage: 'data:image/png;base64,' + data,})
80+
81+
})
82+
.catch((data)=>{
83+
console.log('读取失败');
84+
});
85+
86+
6987
})
7088

7189
}
@@ -77,9 +95,9 @@ export default class MyNotificationsScreen extends React.Component {
7795
</Image>
7896
} else {
7997
this.avatar = <Image
80-
source={{isStatic:true,uri:this.state.myInfo.avatarThumbPath, scale:1}}
98+
source={{isStatic:true,uri: this.state.headerImage}}
8199
style={styles.avatar}>
82-
</Image>
100+
</Image>
83101
}
84102
return (
85103
<View>

example/app/routes/UpdateMyInfo/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export default class UpdataMyInfoScreen extends Component {
9999

100100
updateMyInfo() {
101101
JMessage.getMyInfo((user) => {
102+
102103
this.setState({myInfo: user})
103104
})
104105
}
@@ -112,6 +113,7 @@ export default class UpdataMyInfoScreen extends Component {
112113

113114

114115
render() {
116+
115117
if (this.state.myInfo.avatarThumbPath === "") {
116118
this.avatar = <Image
117119
source={require('../../resource/group-icon.png')}

example/app/views/FormButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

33
import React from 'react'
4+
import PropTypes from 'prop-types';
45
import
56
{
67
StyleSheet,
@@ -9,7 +10,6 @@ import
910
} from 'react-native'
1011

1112
var {
12-
PropTypes,
1313
Component,
1414
} = React;
1515

example/app/views/ListItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23

34
var {
4-
PropTypes,
55
Component,
66
} = React;
77
import ReactNative from 'react-native';

example/ios/JMessageDemo.xcodeproj/project.pbxproj

Lines changed: 126 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
};
66
objectVersion = 46;
77
objects = {
8+
89
/* Begin PBXBuildFile section */
910
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1011
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -31,6 +32,7 @@
3132
2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */; };
3233
2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */; };
3334
2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };
35+
44014AEAFABF4C69BAAD9E8B /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A113E0A77554EA9A1728090 /* libRNFS.a */; };
3436
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
3537
621730131F4DAA24001ADED4 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 621730121F4DAA24001ADED4 /* CoreTelephony.framework */; };
3638
621730151F4DAA2A001ADED4 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 621730141F4DAA2A001ADED4 /* CoreAudio.framework */; };
@@ -288,6 +290,55 @@
288290
remoteGlobalIDString = 6212EB151F3C34BB00BDF51A;
289291
remoteInfo = RCTJMessageModule;
290292
};
293+
62E7C7CE1FADC6EA009BD7C8 /* PBXContainerItemProxy */ = {
294+
isa = PBXContainerItemProxy;
295+
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
296+
proxyType = 2;
297+
remoteGlobalIDString = 3DBE0D001F3B181A0099AA32;
298+
remoteInfo = fishhook;
299+
};
300+
62E7C7D01FADC6EA009BD7C8 /* PBXContainerItemProxy */ = {
301+
isa = PBXContainerItemProxy;
302+
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
303+
proxyType = 2;
304+
remoteGlobalIDString = 3DBE0D0D1F3B181C0099AA32;
305+
remoteInfo = "fishhook-tvOS";
306+
};
307+
62E7C7E01FADC6EA009BD7C8 /* PBXContainerItemProxy */ = {
308+
isa = PBXContainerItemProxy;
309+
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
310+
proxyType = 2;
311+
remoteGlobalIDString = 9936F3131F5F2E4B0010BF04;
312+
remoteInfo = privatedata;
313+
};
314+
62E7C7E21FADC6EA009BD7C8 /* PBXContainerItemProxy */ = {
315+
isa = PBXContainerItemProxy;
316+
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
317+
proxyType = 2;
318+
remoteGlobalIDString = 9936F32F1F5F2E5B0010BF04;
319+
remoteInfo = "privatedata-tvOS";
320+
};
321+
62E7C7E81FADC6EC009BD7C8 /* PBXContainerItemProxy */ = {
322+
isa = PBXContainerItemProxy;
323+
containerPortal = 8450B64F75C44CB8B3422A07 /* RNFS.xcodeproj */;
324+
proxyType = 2;
325+
remoteGlobalIDString = F12AFB9B1ADAF8F800E0535D;
326+
remoteInfo = RNFS;
327+
};
328+
62E7C7EA1FADC6EC009BD7C8 /* PBXContainerItemProxy */ = {
329+
isa = PBXContainerItemProxy;
330+
containerPortal = 8450B64F75C44CB8B3422A07 /* RNFS.xcodeproj */;
331+
proxyType = 2;
332+
remoteGlobalIDString = 6456441F1EB8DA9100672408;
333+
remoteInfo = "RNFS-tvOS";
334+
};
335+
62E7C7EC1FADC937009BD7C8 /* PBXContainerItemProxy */ = {
336+
isa = PBXContainerItemProxy;
337+
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
338+
proxyType = 1;
339+
remoteGlobalIDString = 3C86DF451ADF2C930047B81A;
340+
remoteInfo = RCTWebSocket;
341+
};
291342
78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
292343
isa = PBXContainerItemProxy;
293344
containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
@@ -361,6 +412,8 @@
361412
6258B07E1F4E763A00990134 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
362413
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
363414
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
415+
8450B64F75C44CB8B3422A07 /* RNFS.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFS.xcodeproj; path = "../node_modules/react-native-fs/RNFS.xcodeproj"; sourceTree = "<group>"; };
416+
8A113E0A77554EA9A1728090 /* libRNFS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFS.a; sourceTree = "<group>"; };
364417
9468FF705FDF464DB351AC60 /* UIKit.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
365418
B3D3338066F545108CE6489C /* libAuroraIMUI.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libAuroraIMUI.a; sourceTree = "<group>"; };
366419
B68903A680EE48DAA80CB4A8 /* libRCTJMessageModule.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTJMessageModule.a; sourceTree = "<group>"; };
@@ -400,6 +453,7 @@
400453
EBD4EB335B5A4E73981DA11B /* Foundation.framework in Frameworks */,
401454
D6E3BB68828140DFAB77E5BC /* UIKit.framework in Frameworks */,
402455
6683A32737904214BD076312 /* libRCTJCoreModule.a in Frameworks */,
456+
44014AEAFABF4C69BAAD9E8B /* libRNFS.a in Frameworks */,
403457
);
404458
runOnlyForDeploymentPostprocessing = 0;
405459
};
@@ -494,6 +548,8 @@
494548
children = (
495549
139FDEF41B06529B00C62182 /* libRCTWebSocket.a */,
496550
3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */,
551+
62E7C7CF1FADC6EA009BD7C8 /* libfishhook.a */,
552+
62E7C7D11FADC6EA009BD7C8 /* libfishhook-tvOS.a */,
497553
);
498554
name = Products;
499555
sourceTree = "<group>";
@@ -530,6 +586,8 @@
530586
62D683931F43E8890083CDF6 /* libthird-party.a */,
531587
62D683951F43E8890083CDF6 /* libdouble-conversion.a */,
532588
62D683971F43E8890083CDF6 /* libdouble-conversion.a */,
589+
62E7C7E11FADC6EA009BD7C8 /* libprivatedata.a */,
590+
62E7C7E31FADC6EA009BD7C8 /* libprivatedata-tvOS.a */,
533591
);
534592
name = Products;
535593
sourceTree = "<group>";
@@ -585,10 +643,10 @@
585643
6291C0931F99C22600C85F64 /* Recovered References */ = {
586644
isa = PBXGroup;
587645
children = (
588-
E53DEE966F3C4EF59620DD03 /* libRNSVG.a */,
589646
B68903A680EE48DAA80CB4A8 /* libRCTJMessageModule.a */,
590647
B3D3338066F545108CE6489C /* libAuroraIMUI.a */,
591648
2C597C5BCCDA4718A237069C /* libRCTJCoreModule.a */,
649+
8A113E0A77554EA9A1728090 /* libRNFS.a */,
592650
);
593651
name = "Recovered References";
594652
sourceTree = "<group>";
@@ -601,6 +659,15 @@
601659
name = Products;
602660
sourceTree = "<group>";
603661
};
662+
62E7C7E41FADC6EC009BD7C8 /* Products */ = {
663+
isa = PBXGroup;
664+
children = (
665+
62E7C7E91FADC6EC009BD7C8 /* libRNFS.a */,
666+
62E7C7EB1FADC6EC009BD7C8 /* libRNFS.a */,
667+
);
668+
name = Products;
669+
sourceTree = "<group>";
670+
};
604671
78C398B11ACF4ADC00677621 /* Products */ = {
605672
isa = PBXGroup;
606673
children = (
@@ -627,6 +694,7 @@
627694
53E405AEFA73434487A5D4CD /* RCTJMessageModule.xcodeproj */,
628695
278EF46CCB2D4E47B8ECCF30 /* RCTAuroraIMUI.xcodeproj */,
629696
4C54343FC0D74C6180E8B4CC /* RCTJCoreModule.xcodeproj */,
697+
8450B64F75C44CB8B3422A07 /* RNFS.xcodeproj */,
630698
);
631699
name = Libraries;
632700
sourceTree = "<group>";
@@ -679,6 +747,7 @@
679747
buildRules = (
680748
);
681749
dependencies = (
750+
62E7C7ED1FADC937009BD7C8 /* PBXTargetDependency */,
682751
6258B07A1F4E756000990134 /* PBXTargetDependency */,
683752
);
684753
name = JMessageDemo;
@@ -790,6 +859,10 @@
790859
ProductGroup = 146834001AC3E56700842450 /* Products */;
791860
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
792861
},
862+
{
863+
ProductGroup = 62E7C7E41FADC6EC009BD7C8 /* Products */;
864+
ProjectRef = 8450B64F75C44CB8B3422A07 /* RNFS.xcodeproj */;
865+
},
793866
);
794867
projectRoot = "";
795868
targets = (
@@ -1017,18 +1090,53 @@
10171090
remoteRef = 62D683961F43E8890083CDF6 /* PBXContainerItemProxy */;
10181091
sourceTree = BUILT_PRODUCTS_DIR;
10191092
};
1020-
62D6839D1F43E8890083CDF6 /* libRNSVG-tvOS.a */ = {
1093+
62D683B51F43F1A40083CDF6 /* libRCTJMessageModule.a */ = {
10211094
isa = PBXReferenceProxy;
10221095
fileType = archive.ar;
1023-
path = "libRNSVG-tvOS.a";
1024-
remoteRef = 62D6839C1F43E8890083CDF6 /* PBXContainerItemProxy */;
1096+
path = libRCTJMessageModule.a;
1097+
remoteRef = 62D683B41F43F1A40083CDF6 /* PBXContainerItemProxy */;
10251098
sourceTree = BUILT_PRODUCTS_DIR;
10261099
};
1027-
62D683B51F43F1A40083CDF6 /* libRCTJMessageModule.a */ = {
1100+
62E7C7CF1FADC6EA009BD7C8 /* libfishhook.a */ = {
10281101
isa = PBXReferenceProxy;
10291102
fileType = archive.ar;
1030-
path = libRCTJMessageModule.a;
1031-
remoteRef = 62D683B41F43F1A40083CDF6 /* PBXContainerItemProxy */;
1103+
path = libfishhook.a;
1104+
remoteRef = 62E7C7CE1FADC6EA009BD7C8 /* PBXContainerItemProxy */;
1105+
sourceTree = BUILT_PRODUCTS_DIR;
1106+
};
1107+
62E7C7D11FADC6EA009BD7C8 /* libfishhook-tvOS.a */ = {
1108+
isa = PBXReferenceProxy;
1109+
fileType = archive.ar;
1110+
path = "libfishhook-tvOS.a";
1111+
remoteRef = 62E7C7D01FADC6EA009BD7C8 /* PBXContainerItemProxy */;
1112+
sourceTree = BUILT_PRODUCTS_DIR;
1113+
};
1114+
62E7C7E11FADC6EA009BD7C8 /* libprivatedata.a */ = {
1115+
isa = PBXReferenceProxy;
1116+
fileType = archive.ar;
1117+
path = libprivatedata.a;
1118+
remoteRef = 62E7C7E01FADC6EA009BD7C8 /* PBXContainerItemProxy */;
1119+
sourceTree = BUILT_PRODUCTS_DIR;
1120+
};
1121+
62E7C7E31FADC6EA009BD7C8 /* libprivatedata-tvOS.a */ = {
1122+
isa = PBXReferenceProxy;
1123+
fileType = archive.ar;
1124+
path = "libprivatedata-tvOS.a";
1125+
remoteRef = 62E7C7E21FADC6EA009BD7C8 /* PBXContainerItemProxy */;
1126+
sourceTree = BUILT_PRODUCTS_DIR;
1127+
};
1128+
62E7C7E91FADC6EC009BD7C8 /* libRNFS.a */ = {
1129+
isa = PBXReferenceProxy;
1130+
fileType = archive.ar;
1131+
path = libRNFS.a;
1132+
remoteRef = 62E7C7E81FADC6EC009BD7C8 /* PBXContainerItemProxy */;
1133+
sourceTree = BUILT_PRODUCTS_DIR;
1134+
};
1135+
62E7C7EB1FADC6EC009BD7C8 /* libRNFS.a */ = {
1136+
isa = PBXReferenceProxy;
1137+
fileType = archive.ar;
1138+
path = libRNFS.a;
1139+
remoteRef = 62E7C7EA1FADC6EC009BD7C8 /* PBXContainerItemProxy */;
10321140
sourceTree = BUILT_PRODUCTS_DIR;
10331141
};
10341142
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
@@ -1128,6 +1236,11 @@
11281236
name = RCTAuroraIMUI;
11291237
targetProxy = 6258B0791F4E756000990134 /* PBXContainerItemProxy */;
11301238
};
1239+
62E7C7ED1FADC937009BD7C8 /* PBXTargetDependency */ = {
1240+
isa = PBXTargetDependency;
1241+
name = RCTWebSocket;
1242+
targetProxy = 62E7C7EC1FADC937009BD7C8 /* PBXContainerItemProxy */;
1243+
};
11311244
/* End PBXTargetDependency section */
11321245

11331246
/* Begin PBXVariantGroup section */
@@ -1157,11 +1270,13 @@
11571270
"$(SRCROOT)/../node_modules/jmessage-react-plugin/ios/RCTJMessageModule/**",
11581271
"$(SRCROOT)/../node_modules/aurora-imui-react-native/iOS/IMUIMessageCollectionView/**",
11591272
"$(SRCROOT)/../node_modules/jcore-react-native/ios/RCTJCoreModule",
1273+
"$(SRCROOT)/../node_modules/react-native-fs/**",
11601274
);
11611275
INFOPLIST_FILE = JMessageDemo/Info.plist;
11621276
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
11631277
LIBRARY_SEARCH_PATHS = (
11641278
"$(inherited)",
1279+
"\"$(SRCROOT)/JMessageDemo\"",
11651280
);
11661281
OTHER_LDFLAGS = (
11671282
"$(inherited)",
@@ -1188,11 +1303,13 @@
11881303
"$(SRCROOT)/../node_modules/jmessage-react-plugin/ios/RCTJMessageModule/**",
11891304
"$(SRCROOT)/../node_modules/aurora-imui-react-native/iOS/IMUIMessageCollectionView/**",
11901305
"$(SRCROOT)/../node_modules/jcore-react-native/ios/RCTJCoreModule",
1306+
"$(SRCROOT)/../node_modules/react-native-fs/**",
11911307
);
11921308
INFOPLIST_FILE = JMessageDemo/Info.plist;
11931309
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
11941310
LIBRARY_SEARCH_PATHS = (
11951311
"$(inherited)",
1312+
"\"$(SRCROOT)/JMessageDemo\"",
11961313
);
11971314
OTHER_LDFLAGS = (
11981315
"$(inherited)",
@@ -1223,6 +1340,7 @@
12231340
"$(SRCROOT)/../node_modules/jmessage-react-plugin/ios/RCTJMessageModule/**",
12241341
"$(SRCROOT)/../node_modules/aurora-imui-react-native/iOS/IMUIMessageCollectionView/**",
12251342
"$(SRCROOT)/../node_modules/jcore-react-native/ios/RCTJCoreModule",
1343+
"$(SRCROOT)/../node_modules/react-native-fs/**",
12261344
);
12271345
INFOPLIST_FILE = "JMessageDemo-tvOS/Info.plist";
12281346
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -1255,6 +1373,7 @@
12551373
"$(SRCROOT)/../node_modules/jmessage-react-plugin/ios/RCTJMessageModule/**",
12561374
"$(SRCROOT)/../node_modules/aurora-imui-react-native/iOS/IMUIMessageCollectionView/**",
12571375
"$(SRCROOT)/../node_modules/jcore-react-native/ios/RCTJCoreModule",
1376+
"$(SRCROOT)/../node_modules/react-native-fs/**",
12581377
);
12591378
INFOPLIST_FILE = "JMessageDemo-tvOS/Info.plist";
12601379
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

example/ios/JMessageDemo/AppDelegate.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
1818
{
1919
NSURL *jsCodeLocation;
2020

21-
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
22-
// jsCodeLocation = [NSURL URLWithString:@"http://192.168.10.73:8081/index.ios.bundle?platform=ios&dev=true"];
21+
// jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
22+
jsCodeLocation = [NSURL URLWithString:@"http://192.168.9.113:8081/index.ios.bundle?platform=ios&dev=true"];
2323
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
2424
moduleName:@"ReactJChat"
2525
initialProperties:nil

0 commit comments

Comments
 (0)