How to implement 1:1 Chat-to-Custom Object History with Quickblox in Javascript - quickblox

I have been to this link which explains how to automatically save chat history for android and ios in the Custom Objects module.
However my app is cordova and therefore written in javascript. I tried sending a message with the class_name and quickblox session token in the extension of the message, but this did not automatically create the chat history as the link suggests...Is this not implemented for javascript yet?
var message = {
body: 'hi',
type: 'chat',
extension: {
class_name: 'chat_messages',
token: token
}
}
chatService.sendMessage(1234,message);
Also, I have created a class in custom objects called chat_messages with 3 fields, receiver_id message and dateSent. They are int, string and int respectively.

Related

How to set property of 'X-IW-SESSION' in Flutter

I am converting my employer's current android app to flutter. One of the difficulties I have been facing recently is how I post data to the server with json.
For some data transactions, the server requires the 'X-IW-SESSION', which is set as follows in the original app:
httpURLConnection.setRequestProperty("X-IW-SESSION", session);
I've tried using the following properties, but I am unable to get the result I need.
Map<String, String> headers = {
HttpHeaders.contentTypeHeader: "application/json",
HttpHeaders.authorizationHeader: session,
};
I checked this over flutter's official documentation. I couldn't find the name 'x-iw-session' but saw something similar = HttpHeaders.authorizationHeader.
In the old android app, the 'x-iw-session' helps the user to login using a session (String) which is stored in the shared preferences.
In the flutter app, I have access to the same session (String), but I am lost as to how should I use the same to login into the server.
Currently, this is what my server sends as response for failure:
{success: false, message: Please Login..You dont have permission}
Please do tell, If I need to show some specific code.
Maybe this would work.
Map<String, String> headers = {
HttpHeaders.contentTypeHeader: "application/json",
”X-IW-SESSION”: session,
};
If so, check for a declaration in HttpHeaders.

Twilio programmable chat message user friendlyName

I am using Twilio Programmable Chat to add a chat feature to my mobile app built in React Native. I'm using the JS client SDK for this.
When the app receives a new message, the data that comes through uses the user identity for the author field. Is there away to include the friendlyName in the payload so I can display this to the user.
I could make a separate request for all users and find the correct user within the app but it would be great if this data could just be on the same request.
Thanks for any help
Yes, only author field present in new message event, I used an alternate approach
channelMembersDict = {}
// Assuming you have set selected an Channel
this.activeChannel.getMembers().then(members => {
members.forEach(mem => {
//member contains friendlyName attribute
this.channelMembersDict[mem.state.identity] = mem;
//If you really want user then
mem.getUser().then(user => {
this.channelMembersDict[mem.state.identity] = user;
});
});

How to use FaceID using Xamarin.forms?

What I need to implement that Face ID authentication will work on Xamarin.forms project?
You have to do this natively on your iOS project, and then expose it to your Forms project using a DependencyService or some kind of ioc.
You must add to your info.plist the NSFaceIDUsageDescription key, otherwise the app will crash when asking for authentication.
Here is a snippet that authenticates a user locally:
var context = new LAContext();
LAContextReplyHandler replyHandler;
NSError AuthError;
if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError))
{
replyHandler = new LAContextReplyHandler((success, error) =>
{
// Handle authentication success or error
});
// Authenticate and ask for permission if needed.
context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Authenticate", replyHandler);
}

Sending a link using push notifications in Azure for Android

I have created a backed in asp.net web-forms successful send a notification for all registered devices but I tired to send a link for example I need to send one push notification include a link When user touch on the notification redirect to mobile browser and open the link.
private static async void SendNotificationAsync()
{
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString("<Here is my endpoint >", "<hub name>");
await hub.SendGcmNativeNotificationAsync("{ \"data\" : {\"message\":\"Hello Users \"}}");
}
Based on my experience, we could use custom json format and at receiver end convert that string into url. For example,Here’s a sample of the complete JSON payload with a custom "web_link" key containing the URL:
{"data": "{\"message\":\"xxxx\",\"web_link\":\"https://www.example.com\"}"}
Then we could override the OnMessage function to create Notification, we also could get more detail info from the Azure document.

How do I deregister device in MFP

I am sending push notification via an external script and capturing the response that is return from MobileFirst. The response is always 200 and a messageId is in the response JSON object
How can I simulate a error condition?
I used the MFP API to remove the subscription, removing the device from the device tab in the MFP console. However, I can still send and receive push notification for that deviceID .
Unsubscribing from the tag subscription (which you have subscribed in the code) does not clear all subscriptions. A default Push.ALL tag subscription stays in the DB. This is why you are able to still send notifications.
You can remove the device registration either using the SDK ( as mentioned by Gaurab) or use the REST API call to do this.
Details here: Push Device Registration Delete
I assume that you are using IBM MobileFirst v8.0.
You need to implement these API in client side to unregister the device or unsubscribe from tags.
Unregister the device from push notification service instance.
MFPPush.unregisterDevice(
function(successResponse) {
alert("Unregistered successfully");
},
function() {
alert("Failed to unregister");
}
);
Unsubscribe from tags.
var tags = ['sample-tag1','sample-tag2'];
MFPPush.unsubscribe(
tags,
function(tags) {
alert("Unsubscribed successfully");
},
function() {
alert("Failed to unsubscribe");
}
);