How to manage Presence Subscription requests with smack on Android - android

I want to know the best practice to send presence requests during registration.
I am developing a chat app on android. The user account id is based on phone numbers.
The approach is like this.
Read all contacts from Phone.
Create a list of all phone numbers you need to send presence requests to.
When the list reaches 50 numbers. Send a Multicast message using
XEP-0033. This is to reduce network
calls.
The issue with this approach is that a user normally has 500-600 contacts on his phone or maybe more. On an average the registration process might take 10-12 http calls for presence subscriptions.
Can somebody suggest a better approach to it.

I assume that your framework is something like that of Whatsapp.
Now, for that I can refer you to opensource alternative of Whatsapp that is Kontalk.
You can find the Github code here.
You can go through the code, hope it helps.

Related

MQTT Unique Topic Format generation for Mobile Devices

Currently I'm working on the MQTT based Chat application where I need to assign
Unique Topics to Users dynamically.
So, I thought of using their IMEI/MobileNumber. But in iOS, we cannot get the IMEI Number so we thought of generating a random IMEI from the backend and assign it to the Users.
Now, My problem is whenever user changes his mobile, the IMEI Number changes and it will be fresh profile again to that user.
If I use based on his Mobile Number, there is a chance when the user doesn't use the sim for 3 months. The connection automatically terminates from the network provider and the same number will be assigned to another new customer(atleast here in india).
Can anyone suggest me a good approach for the Topic Generation?
BTW, I need a Web Chat also and that need to be fetched from database. that is the only reason, I'm focusing on the Topic Generation. So, I will fetch messages based on his topic and show them in the Web Chat.
Do anyone know, how whatsapp maintained their topics?
I thought of using their IMEI/MobileNumber.
Bad design. Have the user create an account (i.e. email) with a password for your service that way no matter what phone or phone number they have, they can still log in and use your app. And make sure you ENCRYPT the user credentials in your database. Start FIRST by building an app with proper security or else you will be hacked 5 minutes after you launch it.
Do anyone know, how whatsapp maintained their topics?
Just because Zuckerberg copies everyone else, doesn't mean you need to copy them. Also, I believe whatsapp created there own version of a MQTT Broker. Hence, it will have an entirely different set of functionality from a regular MQTT Broker.

AMQP Strategy to manage mobile offline data

I m actually working on a little application with Android and NodeJS as backend.
I want to manage realtime data & offline data so I decided to use AMQP through RabbitMQ.
My problem
In my domain, a device is related to a place, and this place to a city. I want to be able to broadcast information to devices in a specific place, in a specific city.
I want to be able to have the message in a queue, and when all the devices in this queue have consumed the data, it's auto deleted by rabbitMQ, knowing that every devices dont consume the information at the same time (offline problems).
Question
What is the best strategy to manage this kind of problems ?
Thanks for advance
Take a look at this guide: http://www.rabbitmq.com/tutorials/amqp-concepts.html specifically about the topic exchange, which is what your probably want to use. In your case I think each device needs it's own queue bound to a topic exchange.

How to start a multi-user conversation in Lync UCWA

To start off, here's a bit of info on what I'm trying to accomplish, so if there's a better way of doing it, I'd love to hear your thoughts.
I'm creating and Android Kiosk application that leverages Lync UCWA to sit at the entrance of my work and when visitors enter the office, they'll use the Kiosk to notify somebody in the office that there is a guest.
I've had a new Lync user created for this purpose, which will be the account authenticated on the kiosk and will be the user sending outgoing messaging invitations.
What I want to accomplish is to create a group conversation by adding multiple people to a conversation so that everybody gets the message and somebody can then respond to the group chat letting everybody else know that they will go to the front and greet the guest. I'm able to send a message to a single person, but haven't figured out how to get multiple people on a conversation.
I've tried to start a conversation with a single person and then call the addParticipant endpoint to add others to the conversation, but that hasn't worked for me yet. From what I'm seeing, I can't add somebody until the 1st person accepts the invitation, which poses the problem as I can't be guaranteed that person will accept it.
Am I taking a wrong approach here or am I missing something? I tried to think what code would be helpful here, but didn't think it would help, so if I see that it's needed by follow-ups, I'll post anything relevant to the topic.
The situation you are describing might be best served with a slightly altered solution. This kiosk is the entry point for a guest to contact a set of users and as you have discovered if those users don't respond your guests is left without much recourse.
If you were to change the approach to expose an anonymous meeting for the guest to join, it would be possible to have a UCMA application join and attempt to facilitate the communication between the guest and the users. The UCMA application could facilitate adding the expected users or contacting them and executing a script to notify them of the guests arrival.
You would want to wrap/expose a way (most likely a Web API) to communicate the meeting created by UCMA to the web application as UCWA needs specific information (conferenceUri) in order to join anonymously.
I am working something very similar where I need to be able to send to a number of users at once and avoid the send and accept scenario you mentioned.
So far from my testing and reading this doesn't seem to be possible with just UCWA. What I have been looking into is using the SDKs available for Lync, which are UCMA and the Persistent Chat SDK.
Using these you would need to create your own application which could act as a REST API for preforming the group sending.

Send text to app (not specific phone number)

I don't know if this is even possible, couldn't find anything usefull on the internet.
I wanted to make an app, that me and some of my friends could send a message trough "my app" and that everyone who has that app, receive the message, without using a phone number.
So basically, same as WhatsApp GroupConversation, but then without using a phone number.
Is this even possible?
If it is possible, could you put me on the right track to start with.
Hope I am clear enough, if not, tell me :)
Edit:
This just pops up in my head (didn't look on internet yet), but what I want, is a kind of a shoutbox.
This is possible, in fact WhatsApp does not use your phone number for this at all.
You simply provide your phone number to asure a unique ID and proof that you are indeed in possession of this phone with the validation SMS.
From there on, your phone number isn't even used anymore.
You can go 2 ways with this;
Create a simple webservice with a database on which you just save and request messages. Maybe make a little difference between get all or get latest message. Anyone, hooking into the group, can just fetch the same data. With the use of GCM push notifications, you can make this pretty instant.
Use XMPP, which is a chat protocol kinda all the chats use. Whatsapp, Google talk, FB messenger... This will provide you with instant messaging just like any other chat app or program you know.
Option 2 is by far the best in final functionality, but be warned that XMPP is quite complex and error prone.
You can look into the asmack and asmackx libraries for Android, which will give you the basic functionality with ease. Going a bit deeper, you'll have to dig into the protocol and really get to know it though.
ps. For both you'll need your own server, however with asmack(x) you are also allowed to use Google's Talk servers for free. Communication will go through your Gmail account. Basically with this you just make your own version of Google Talk.
It is possible by implementing server-client architecture. Your app will use a common database for all the users. whenever an user install your app, he will achieve an unique user ID. if anyone uninstall it, his id will be destroyed. You can track the users from those ID in database. You don't need phone numbers.

Sharing data between android users

I'm having trouble understanding the top level of abstraction of this problem.
The Problem:
Users A and B download application X. A wants to send application-specific data to B. How does user A link with B?
My incredibly messy solution:
- User A clicks a button on the application that opens up a list of contacts. user A selects user B from the list. User B's email address was stored in A's address book. Application creates a sort of "share ID" and sends it to user B via that email address. User B's application gets that ID from the mail, then User A and B use the share ID to connect to a server and share between each other via the sserver.
There must be a better way? The two problems are:
1. It shouldn't need a server (should it? could it be free?)
2. There must be better ways of the users connecting to each other than sending ID's or links etc by gmail.
This solution should be so so simple, but I can't get my head round it. If this question is not sufficient to get a good answer, please please tell me what I need to do to get into the way of thinking about how mobile users can interract with each other as simply as possible, with as few clicks as possible, (Mobile 2.0 or whatever the modern day thing is!)
For example: A mother and a child have an android smart phone. They each download the "ChildLeash" app. Child wishes to configure the app to send updates to Mother, so that Mother can keep track of Child's location and so on. The problem is some how Child needs to tell the app what location Mother is at for the data to be sent to. What is a user-friendly way for Child to Identify Mother's phone? (Mother's IP address? Phone number? Email address? OpenIDs? NFC/Bluetooth?) So that it can then communicate?
You could use push notifications, as provided by the Android Cloud to Device Messaging Framework. There's an Android blog post about this. Problem is, this seems beta and not yet available to all developers (you need a specific signup).
Regarding "IP Adresss", P2P and such, this generally won't work. See: Is peer-to-peer communication over 3G/4G possible for smart phones?
If messages are not urgent, then you could use AlarmManager to have your app wake up every hour or so, and check for new messages by connecting to a server. Not sure that would work for your "ChildLeash" example. Another similar solution would be to use a Service to poll the server.
Usually this sort of interaction would require a server. Which you've kind of faked using email as your medium.
It might be worth looking into peer to peer libraries such as JXTA. There's an android port here: http://code.google.com/p/peerdroid/
EDIT: I just came across this: http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging.html Which looks like exactly what you're after.

Categories

Resources