Avatar for anonymous users in multi-user chat in XMPP - ios

I am writing an iOS app that features anonymous multi-user chat. All the users logged in using
[self xmppStream] authenticateAnonymously:&error]
So they all have random bare JID. What I am trying to achieve here is implement anonymous multi-user chat with avatar, I've done some research in the documentation but is still unclear on how I could do this.
Some of the questions that I am still not understanding yet:
Can anonymous user have a vcard? If this is possible, will the server automatically delete the vcard for the anonymous user once he disconnected? (I am running OpenFire)
What is the most efficient way to implement this avatar enabled anonymous MUC? What I am thinking right now is to get a list of occupants (not sure how to do this) when a user enters the room, and when a user speaks, download the user avatar if it is not stored or it has been changed (don't know how to do this as well)
If you could provide some sample codes to get me started, I would really appreciate it.
Thank you for your time!

XMPPvCardTempModule with XMPPvCardTempCoreDataStorage and XMPPvCardAvatarCoreDataStorage will do the job for you, check iPhoneXMPP project from XMPPFramework for example usage. The only difference in anonymous usage is that you need to publish your own vCard on every login.

Related

Swift : Upload pdf as "admin user" and send notification to other "normal users" that pdf is uploaded

I'm a swift beginner.
I'm trying to create an app that essentially does the following :
Users can sign up and login to the app to receive a new recipe weekly in a pdf (or word doc) format. Once the new recipe of the week is ready to be viewed the users will receive a notification that "recipe of the week is ready for viewing" and they can then login and access the new recipe (as well as recipes from previous weeks).
One admin user will be able to login and upload these pdfs/word doc that contain the recipe and once the upload is complete, the other normal users are notified of this new recipe.
My question :
1) Is it possible to have different users in one app? (ie normal users and admin users). I just want to make the app easy to use for the admin (a friend who is not a tech and who just want to upload recipes) without having to touch the codes or needing me to upload them manually. If its not possible, what could be an alternative way of doing this, so that an ordinary admin user can just upload into the app for other users viewing pleasure?
2) I just thought pdf/word doc might be an easier way for the friend to upload the recipes into app (the recipe might contain pics, tables, graphs etc), if there is a different way of doing this, open to suggestions :) At first I thought maybe putting the recipes on a shared directory and getting Apple's DirectoryMonitor.swift to monitor the directory so that everytime the friend uploads something to the directory, the app will detect this and send notifications to other users....but I thought maybe this isnt the best way to do it, not to mention it might send false notifications (ie when files are removed insteaf of added..)
I do know the basics of Swift, or think I do.So hopefully if you can provide me enough hints (ie framework or SDK or classes to use etc etc) I can use your suggestions to do further research on the subject.
If you need more details or clarifications, please let me know. Thanks!
You must use web services (server) to achieve this stuff.
Design api for login like if admin user login then you return something like this is admin and shows admin screens in your app like upload dishes etc.
If normal user will login then your api (web service) will return you that this is a normal user then show stuff regarding it in your app.
You required web services for uploading and retrieving recipes.
You can easily manage notification if admin upload new recipe to server.
So, it's basically depends on your server and mobile both side of proper management. Your database will take place server side. that's it.

How to share links via FB App when I am offline

I am developing an mobile app for iPhone. The app will primary used by people who are on holiday in a different country and will be offline most of the time, due to high costs for internet traffic.
However, the company for which I am developing the app wants to users to be able to use the "Facebook Share" functionality also when people are not connected to the internet.
It should work on a way that they click the SHARE link button in the app, but then get a message that they are offline and the link will get shared as soon as they are online again.
I am trying to figure out how to do this. Can I pass the link I want to share to the official FB App via fb:// protocol (or whatever) and the FB App handles the post/share as soon as it is online again?
Or do I have to do it on my own, put the links I want to share in a internal database and then post them to the wall when I am online again?
Or any other ways??
Any suggestions would be welcome, I would prefer a very quick solution and hope someone maybe has an idea how to do this. I was hoping I can pass the share-link to the official FB App and this one handles everything when it goes online again !?
Thanks for your ideas!
Your approach should be to make your link-sharing code automatically cache requests until they are sent. The app then doesn't need to concern itself with the details - it can just post the link and get a 'failed', 'success', or 'postponed' response from your API and notify the user accordingly.
Your link-sharing code can then internally check if it can currently post to FB and if not (either because the user is currently offline or perhaps the Facebook token is expired) it will store it for later. This class will then re-check periodically (for example when the app comes to the foreground or when the class is initialised the next time the app starts) for connectivity and then it will check if the token is still valid and perform FB login if required. Once it has a valid token it can then iterate through the pending requests and act upon them.
If you really want to make it nice and clean, you can separate out the code that accepts incoming requests to do something, checks if it can be performed now, does it or stores it for later, and periodically checks any requests in the pending queue. This class will not have any idea what the requests do or how they are performed, it will work with another class that implements a protocol to do the actual work and knows about facebook, etc. There may even be an existing design pattern for such a setup, but I don't know what it's called if there is.
Update: I did some research and found this is very similar to the "Fire-and-Forget Pattern".

Inviting users to an IOS app

After registration, our app prompts users to invite her friends (aka phone contacts) to use the app too. This allows us to send an email/sms to the useer's contacts with some sort of invitation key. Works fine for a web version app, just embed the key in the url you provide in the invitation.
I'm having trouble figuring out how to make this work smoothly with IOS only. It would be brilliant if I could send the invitee a link to appstore.apple.com/myapp?registrationKey=abcXYZ and have the key magically available to my app once it's installed, but I guess this is a lot to hope for?
The obvious way around this is to make the user manually enter their registration key on first launch, but this seems less reliable and (to my mind) adds friction to the UX.
Has anybody come up with something clever to get around this?
Here is what is flowing through my brain on how to solve this solution, please note, I have not vetted, psudeo-coded, coded, or applied this theory.
Since you will know who is being sent an invitation, save that data to your database with a relationship to the user sending and a unique id to the user being invited (email address if its in the contact's card). When new users sign up scan the database for invitations, if one is found present it to the user asking We're you referred by <existing user>? Once the new user selects their response continue through the registration process, updating the relationship table accordingly and applying any extra settings you need to for the referral.
This combines automatic referral tracking with referral codes for a basic, straight-forward, almost (but not quite) fool proof method to make sure referrals are linked to the right users.
As far as I can tell, the App Store provides an information firewall between an invitation and the installed app.
The closest workaround I've seen is the following:
email link sends you to your website
the website logs reference information in the URL and the IP address
the website instantly redirects you to the App Store (if iOS detected)
user installs the app
user loads the app
app contacts your website, IP addresses matched ... BINGO
Obviously not a secure method though.
There are many failure cases:
business networks commonly share IPs
home and mobile networks release and reuse IPs
The more is frequently used to resolve cases where its good enough to know that the user 'almost-certainly' was referred to download app by the email.
For example, it can be a good mechanism to prompt the user with a "who do you know" question in an app and limit the options based on the (IP+reference) data. If they pick the original poster, then maybe that's good enough, and then you can attach any other data that the inviter provided.
(Full disclosure, currently work at Branch)
The best solution to this is to fingerprint a user. This requires you to do the following steps:
For each user, using your own domain, generate a link for said user. So, right when they complete registration, generate their unique URL, that contains the invitation key.
For anyone clicking this link, they will redirect to Safari first. When they do, capture their IP address and iOS operating system version from the headers and user-agent.
Save this data on your server, and set window.location to your iTunes url.
If the user downloads and consequently opens, inside AppDelegate.m, send a message to your server with the IP address + major/minor/min version you collect upon app launch. If it matches with what you have on the server, you can now pass that invitation key back to the new user.
It's not perfect, and has the ability to misattribute. You could also use branch.io, where all of this is taken care of (link-generation, fingerprinting a user, attribution). Branch also drops a first party cookie and ties it with the device level ID, so attributions are much more accurate.

is there support to mark events as read-only either in CalDAV or ical (icalendar)

I've searched the iCalendar spec https://www.rfc-editor.org/rfc/rfc5545 and the CalDAV spec https://www.rfc-editor.org/rfc/rfc4791 looking for insight on how to mark an event that is sent from our calendar server to an iPhone as "read-only" (non-editable) when the iPhone connects to our server using the CalDAV protocol. But the answer is not jumping out at me.
In other words, the iPhone user is receiving, via a CalDAV account a bunch of events. Normally, they can edit any of these events. However, we want to be able to mark a few as read-only. I know that we can use the iPhone ability to add an .ics subscription account, but we don't really want to do this, because it requires the iPhone user to add BOTH a CalDAV and an .ics subscription account.
We are using SabreDAV as our CalDAV server.
My technical co-worker has asked me to look into this, so I am asking for help from the Stackoverflow community.
Any help or hints will be greatly appreciated.
Once you've sent the file to the user it's theirs to deal with so...
I would say there isn't a way to protect the appointment/event from modification.
What you can however do is host the whole calendar yourself and if the user has Outlook or similiar, to subscribe to that RSS feed.
It's one idea... but for protecting what you send them? Highly doubtful. Just take heart they are only modifying their copy of your data, not the source data itself.
1/ You can use shared calendars and invite the user as a read-only. However, the user will have 2 calendars: its own and the shared calendar. Still, it's the same CalDAV account so the user has just one checkbox to click to opt in.
2/ I've not tried ACL but maybe you can play with it.
3/ As a dirtly last resort, you can edit Sabre\CalDAV\Backend\PDO::updateCalendarObject and deleteCalendarObject and add your conditions. But that's very low-level at this point (this class doesn't even know who's doing the change). I don't recommend it.

How to Add Phone With twitter using Third Party tool

I need a script that will add my phone with Twitter for All latest notification.
I found this page Twitter but i need to create script for my own application.
I goggled but i didn't get any solution For this.Please Help me to find this answer.
Thanks a lot in advance.
First Edit
This is a twitter's new feature Send notification to Phone. Actually I want to create an app that will allow users to register there phone with twitter via my application. Ie I need a script to implement send notification to phone.
The question that others are asking you Pankaj is what platform is your application being written for. You keep saying you want a "script" to do this, but what kind of script?
Giving us more insight to what your application is (a console application written in C#, or an ASP.NET web application) would lend more detail and raise the chances of someone being able to help you. :)
Regardless of your app's platform though, you're probably going to need to look into the Twitter API for setting this up. This is the normal method to interact with Twitter from 3rd party applications. So all the suggestions above, specifically the list of API's available, is probably what you're looking for.
Hey, can you give some more information? What kind of Phone are you developing for?
Maybe that helps solving your Problem.
If you are just searching for a way connecting your Phone to Twitter, here is the Twitter FAQ for Phone connecting:
http://support.twitter.com/articles/14014-twitter-phone-faqs
Maybe it helps, or give you more keywords for your search.
I don't believe there's a way to get or set the notification phone number using the API, however if a phone is already setup on the profile you want to configure, you can do the following to get notification from all user friends.
The user will need to authorize your application to access her account. This flow uses OAuth, and begins here:
http://api.twitter.com/oauth/request_token
Once the user has granted your app access, and your application has all the required OAuth credentials, turn on notifications using account/update_delivery_device:
http://api.twitter.com/1/account/update_delivery_device.json?device=sms
Next, fetch all the IDs for your user's friends using the friends/ids API call. Be sure to study the documentation; this call uses cursors, so you will have to manage those if the user has over 5,000 friends. Store these IDs for use in the next step. Here's an example call:
http://api.twitter.com/1/friends/ids.json?cursor=-1
Once you have all of the friend IDs, you can call notifications/follow repeatedly to enable notifications on your mobile device whenever your friend makes an update:
http://api.twitter.com/1/notifications/follow.xml?user_id=12345
This approach will burn one API call for each user that you enable notifications for; there's no way currently to manage notifications en masse.

Resources