Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendMessageToPeer not working #47

Open
vinaysgl opened this issue Aug 27, 2021 · 9 comments
Open

sendMessageToPeer not working #47

vinaysgl opened this issue Aug 27, 2021 · 9 comments

Comments

@vinaysgl
Copy link

Sending Message one to one
is not working

@LichKing-2234
Copy link
Contributor

Is our demo working?

@Pravat45
Copy link

Pravat45 commented Sep 9, 2021

Is our demo working?

no its not working

@orafoxinc
Copy link

Any update on one-to-one chat messaging issue?

@Pravat45
Copy link

successfully implemented

@orafoxinc
Copy link

@Pravat45 any changes required to make it work?

@Pravat45
Copy link

Pravat45 commented Sep 19, 2021

you need a valid token and unique user to make it work

@Pravat45
Copy link

Pravat45 commented Sep 19, 2021

const initRTM = async (rtmToken, id) => {
engine = new RtmClient();
localUid = id; // this is your USER ID
engine.on('error', evt => {
console.log(evt);
});
engine.on('messageReceived', evt => {
let {text} = evt;
const msg = [
{
_id: uuid.v4(),
createdAt: new Date(),
text: text,
user: {
_id: 2,
},
},
];
setMessagesArr(previousMessages =>
GiftedChat.append(previousMessages, msg),
);
});
await engine.createClient(appId).catch(e => console.log(e));
await engine
.login({uid: localUid, token: rtmToken})
.catch(e => console.log(e));
setLogin(true);
};

@Pravat45
Copy link

const onSend = useCallback(async (messages = []) => {
await engine
.sendMessageToPeer({
peerId: '8850817c-d42a-4113-97fc-ed9cc47ad7c1', //ID of Receiver,
offline: false,
text: messages[0].text,
})
.catch(e => console.log(e));
setMessagesArr(previousMessages =>
GiftedChat.append(previousMessages, messages),
);
setMessage('');
}, []);

@orafoxinc
Copy link

I have used this code login and getting an issue.

const createEngine = async(rtmToken)=> {
try {
engine = new RtmEngine();
engine.on('error', evt => {
console.log('agora Error: ', evt);
});
engine.on('messageReceived', evt => {
let {text} = evt;
const msg = [
{
_id: uuid.v4(),
createdAt: new Date(),
text: text,
user: {
_id: user._id,
name: user.user_name,
avatar: user.profile_image,
}
}
];
console.log("Message recievied =>", msg);
setMessages(previousMessages =>
GiftedChat.append(previousMessages, msg),
);
});
await engine.createClient(AGORA_APP_ID).catch(e => console.log('Create Client: ', JSON.stringify(e)));
let loginData = {
token: rtmToken,
uid: user._id,
}
await engine?.login(loginData)
.catch((e) => console.log('Login Error: ', JSON.stringify(e)));
} catch (e) {
console.log('Create Engin Error: ', e);
}
};

Error Message :

{
"code": "5",
"message": "",
"domain": "RCTErrorDomain",
"userInfo": null,
"nativeStackIOS": [
"0 COUM 0x0000000100b152f7 RCTJSErrorFromCodeMessageAndNSError + 135",
"1 COUM 0x0000000100a9d053 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.129 + 179",
"2 COUM 0x00000001011ba4a8 __33-[AgoraRTM login:resolve:reject:]_block_invoke + 200",
"3 libdispatch.dylib 0x000000010613c7ec _dispatch_call_block_and_release + 12",
"4 libdispatch.dylib 0x000000010613d9c8 _dispatch_client_callout + 8",
"5 libdispatch.dylib 0x000000010614be75 _dispatch_main_queue_callback_4CF + 1152",
"6 CoreFoundation 0x00007fff2038fdbb CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9",
"7 CoreFoundation 0x00007fff2038a63e __CFRunLoopRun + 2685",
"8 CoreFoundation 0x00007fff203896d6 CFRunLoopRunSpecific + 567",
"9 GraphicsServices 0x00007fff2c257db3 GSEventRunModal + 139",
"10 UIKitCore 0x00007fff24696cf7 -[UIApplication _run] + 912",
"11 UIKitCore 0x00007fff2469bba8 UIApplicationMain + 101",
"12 COUM 0x000000010012bee0 main + 112",
"13 libdyld.dylib 0x00007fff2025a3e9 start + 1",
"14 ??? 0x0000000000000001 0x0 + 1"
]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants