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?
Related
I'm trying to create a custom sms/email sending view (I don't think i can use the regular SMS/Email API's since i'm planning on calling a server to send these emails and sms messages - meaning no instant sending so apple's api won't do).
The issue i'm facing:
Using the contacts bar the way apple uses it - writing a list of all the contacts needed in a way which makes the bar a "dynamic" contacts bar, which allows the user to add with completion or a "+" button which opens a people image picker view, and change the size of the bar in a very unique and nice way for each contact added.
I saw this stackoverflow question, but the project is archived and not relevant any more i guess.
IS there any source which has already implemented this? or should i face the fact i will have to implement it from scratch?
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.
I am creating a social networking app in iOS for a university group and it's supposed to have display user feeds just like Facebook.
I am saving status updates in MySql database on a server. to update status I am using NSURLRequest and NSURLSession to send status data in post variables to the status update web service which uses php to update the database.
Now, I am confused about displaying the feeds. Here is what i want to do.
I want to fetch 30 feeds first and display them in tableview.
After 30 feeds if the user clicks on more, I want to be able to add another 30 and so on. just like Facebook, when you scroll to the bottom it shows more feeds.
I know how to make the first request and display 30 feeds, but I dont know how to do it the second time. Do I need to make another request? Can someone please explain how Facebook and Twitter do it?
Your request needs to ask for a specific page or offset of the feed, and your server should handle this.
For the first feed, you'd ask for page 0. The server gives you items 1 - 30. At the app end, you keep track of the page you last requested. On the next request, you ask for page 1, and the server gives you items 31-60.
Alternatively, you can send the ID of the last item you have. So for the first request, you send nothing - the server gives you items 1-30. On the second request, you say "the last item in my current list is ID 14152" and the server gives you the next 30 items older than that.
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".
I'm trying to figure out the best way I can inform analytics trackers that the page view is coming from my app, rather than a 'direct visit' (for example).
I have an app that displays a list view of tons of different news stories, and I want to make it so that, when a user taps on one of the stories, and it is displayed in my UIWebView, the website being loaded is somehow informed that the referral came from 'example-iphone-app', or maybe my iPhone app's website?
Is there any way to manipulate the http request to make the iPhone app act as if the link is being opened by a referral link on my website?
I was originally thinking of just adding a query string with a parameter like ?source=myappname, but realized this is not a reliable (or even useful) way of alerting site owners with Google Analytics, SiteMeter, Urchin, etc. from where the request has come.
If you're using Google Analytics then you can set the utm_source and utm_medium query parameters and they will be displayed as the referral source. utm_source is where you would put your myappname parameter and utm_medium should probably be set to referral unless you are charging per click then it is usually set to cpc.