Skip to content

Commit ec1bc33

Browse files
committed
update example
1 parent d59a458 commit ec1bc33

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

example/app/routes/Chat/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class Chat extends Component {
4040

4141
this.updateLayout = this.updateLayout.bind(this);
4242
this.conversation = this.props.navigation.state.params.conversation
43-
43+
Alert.alert("the conversation ",JSON.stringify(this.conversation))
4444
JMessage.getMyInfo((myInfo) => {
4545
this.myInfo = myInfo
4646
})
@@ -197,6 +197,7 @@ export default class Chat extends Component {
197197
onSendText = (text) => {
198198

199199
var message = this.getNormalMessage()
200+
message.username='fasddsaf'
200201
message.text = text
201202
JMessage.sendTextMessage(message, (message) => {
202203
var auroraMsg = this.convertJMessageToAuroraMsg(message)

example/app/routes/ConversationList/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ var count = 0
5353
var item
5454
if (conversaion.conversationType === 'single') {
5555
item = {key: conversaion.target.username}
56+
item.conversationType = 'single'
5657
} else {
5758
item = {key: conversaion.target.id}
59+
item.conversationType = 'group'
5860
Alert.alert('conversaion', JSON.stringify(conversaion))
5961
}
6062

63+
if (conversaion.latestMessage === undefined) {
64+
item.latestMessageString = ""
65+
return item
66+
}
67+
6168
item.conversationType = conversaion.conversationType
6269
if (conversaion.latestMessage.type === 'text') {
6370
item.latestMessageString = conversaion.latestMessage.text
@@ -84,6 +91,21 @@ var count = 0
8491
}
8592

8693
_onPress() {
94+
Alert.alert("click","fasdf")
95+
JMessage.createConversation({type: 'single', username: '0002'}, (conv) => {
96+
var item
97+
if (conv.conversationType === 'single') {
98+
item = {key: conv.target.username}
99+
item.conversationType = 'single'
100+
} else {
101+
item = {key: conv.target.id}
102+
item.conversationType = 'group'
103+
Alert.alert('conversaion', JSON.stringify(conv))
104+
}
105+
this.props.navigation.navigate('Chat', {conversation: item})
106+
}, (error) => {
107+
Alert.alert('error', JSON.stringify(error))
108+
})
87109
}
88110

89111
render() {

example/app/routes/Login/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ const {
2727
}
2828

2929
onPress() {
30+
const { navigate } = this.props.navigation
31+
3032
JMessage.login({username: this.state.username, password: this.state.password}, () => {
3133
Alert.alert('login success')
34+
navigate('ConversationList')
3235
}, (error) => {
3336
Alert.alert('login success', JSON.stringify(error))
3437
})
@@ -46,7 +49,7 @@ const {
4649
onChangeText = { (e) => { this.setState({password: e}) } }>
4750
</TextInput>
4851
<FormButton
49-
title="lala"
52+
title="登录"
5053
onPress={this.onPress}
5154
>
5255
</FormButton>

example/ios/JMessageDemo/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
1919
NSURL *jsCodeLocation;
2020

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

ios/RCTJMessageModule/RCTJMessageModule.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ - (void)onSyncRoamingMessage: (NSNotification *) notification {
148148
-(void)didSendMessage:(NSNotification *)notification {
149149
NSDictionary *response = notification.object;
150150

151-
// CDVPluginResult *result = nil;
151+
if (!response[@"message"]) {
152+
return;
153+
}
154+
152155
NSDictionary *msgDic = response[@"message"];
153156
NSArray *callBacks = self.SendMsgCallbackDic[msgDic[@"id"]];
154157
if (response[@"error"] == nil) {

0 commit comments

Comments
 (0)