how to update previously loaded data after user update his profile - ios

I have one logical question.
I have one iOS app. which uses php mysql as backend. I am getting other user's feeds/Posts on the app home page. I am first getting latest post and saves it locally then display User Post and his details from local.
Now if some user has created one feed, that I will get and display at app side. after sometime if user changes his profile details(like changes his picture). So until that Post/feed updated I could not get know that the user has changed his picture. and every time user's old picture and details will be shown.
So can anyone suggest me which was the better way to update user's information? same like facebook does
Thanks.

Logical Answer:
Make an api in the backend which will return only the updated post.
From app side add a timer for around 3sec/5sec and call the api again and again, and refresh the feed with the current changes. If there is no changes you don't have to refresh the feed.
Make sure from the api you will return only changes not the whole feed again and again it will consume more data if you do so.

Related

How to check if there is new data in API response?

Im creating two types of functionalities in my app, live status update for my order and social media integration too. I would like to know how to update data for these 2 situations as I want my UI to change automatically when there is change in API response. I have made them work but I'm not sure my approach is correct.
These are few situations I'm confused with:
I have to track my order using some status codes from 0 to 9 coming in API response and update UI based on status code, like for 0, say order received, for 1, order confirmed and so on.
Right now I'm using timer to keep calling api again and again to check if there is any change in status in API response and reload tableview if there is.
I have opened all user posts page and first post on the screen is a post posted by me, and if someone likes my post on other device, is there any way to change likes count on my device without refreshing the page again?
Again im using timer to call API and if there is new data, I reload my UITableView.
This is I got covered but just want clarity. In my social media post, if I click a post it opens CommentViewController showing comments, and if I click any comment then it opens RepliesViewController for all the replies and from any UIViewController you can tap userImage and open their profile. So if I like any post/comment/reply, im using delegates to make changes in other view controllers, so if I like a post in their profile, using delegates I'm adding like to post in HomePage for same postId but this approach increases number of delegates by a lot. It works fine but is there any way to tackle this situation with live updating API too like above two situations?
recently I worked with a Socket based chat app and it was easy to handle any live updates but is there any other way to get same functionality with my API's especially for that tracking feature?

Maintaining user data in an iOS app

I'm in the final stretch of building my first iOS app and I wanted to know the best practices for passing around the user or not. Do I pass the user to every controller or is there a store-like infrastructure I can set up to store all runtime data in, or do I fetch from local storage every time I need the user?
Also when I close my simulator, the user is logged out of my backend. Does that mean that I should store the user password in local storage to sign them back if they have logged in before or is that bad practice?
If these questions have been answered else where please send me a link to a discussion along these lines.

Get URL for embedded image on rails

I have created a certification platform and whenever a user gets a certification he/she gets a badge image link to add to his/her website.
When they do that I generate the image on my server-side. So, if they add the image url http://mycertification.com/badges/asdfasdfasdfasdf.jpg, it will check on my side if the image has been created and return it or, if not, create a new one.
I have now over 10000 certified users and I would like to check if they are embedding the badges and also where the badges are embedded. So, if the user from the website www.user1.com embeds the badge image on this website, I would like to track that.
I have created a model BadgeTracker with the user_id, the url and a counter. Simple as that. The counter works already, now I want to know the URL where the image is embedded!
Any ideas on how to achieve that?
As far as I know there is no way to track if the user put the embed code on their website. You could only track how many times the badge has been viewed (meaning loaded) in a browser. If this is the case then you may create a route that handles badge displaying, so once the browser tries to access this URL you collect the badge information from the params, save it in the DB and then simply return the badge image. Sorry if I got your question wrong...
If you're interested I could try to create a code snippet with the solution.

How to update an ios App with current information daily

I'm trying to design an app for my club at school. What I want to happen is when there is new information about meetings or events I want to be able to add this new content to the app and then have it visible by other app users.
So my question is how would I approach this idea?
Conceptually, you're going to need to have a centralized server which contains the data, an API to connect an application to this data, and finally the end user application.
On the server end, you could have a simple database which will house the event and meeting information.
On the API end, you could have a simple script which fetches the latest entries in the database and displays the data in a standard format such as JSON or XML.
On the app end, every time the user opens the application, fetch the latest data from your API and parse it into an array. Then, just populate a table or collection with the data in that array. You could also add a pull to refresh control to fetch the latest information at any time so the user doesn't have to launch the app again.

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".

Resources