iOS Networking data cache issue - ios

I am developing app. It includes login page. After login I receive the response json. I tried the login multiple times with two different accounts.
Lets say account A & B. If I build and run fresh build on device and login with account A. I get the correct response. If I logout and re-login with the account B. In this case, I get the old response of the account A.
The problem remains if I do vice-versa. There is no issue with the web services.
I need to know whether there is issue with response caching in ios. I tried to implement this with the NSURLConnection, NSURLSession, and AFNetworking. The problem stays.
I have implemented the same for the android device. no response issue on android.
Can anybody suggest anything on this situation. Any suggestions are highly appreciated.

NSURLCache has no notion of accounts. You'll have to either tell it to remove all cached items or disable caching. Realistically, caching JSON responses is almost never the right thing to do, so you should probably disable caching for those requests.

Related

branch test app link weird behaviour for facebook/twitter deep linking - iOS

I am using branch for deep linking on facebook as well as twitter. Deep linking opens up my app successfully and I am also able to retrieve all the parameters correctly. But at one instance, it stopped working and said developers are working on it and after 2 days started working again after I submitted a ticket to Branch and without me changing anything. But this weird stopping and starting of link is not good for app users. Can someone from Branch help me know the possible cause for the same, as for the live app, this would create a problem?
The reason why you are experiencing this issue is that apps like Facebook, Twitter, Instagram and Snapchat prevent users from opening a third-party app via Universal Links. One way to mitigate this issue is to use forced redirections via URI Schemes on the in-app browser. You can enable forced redirections on Branch links by appending $uri_redirect_mode=2 as a query parameter.
eg:
https://example.app.link/j93str?$uri_redirect_mode=2
If you are still experiencing issues, please write to integrations#branch.io with a video recording of the link redirection behavior and one of our engineers would be able to help you with this.
Branch documentation includes two types of method calls - synchronous and asynchronous calls to method that generates url. If we are using asynchronous call, it would take time to give us the url so need to check for url first before posting it on social sharing and if we are using synchronous call, we get a short url which can be easily shared to social sites. This is what made a difference for me!!

Is there any way to be connected with the Dropbox SDK without having the captcha access screen each time?

I would like to be connected with the Dropbox SDK on iOS without allowing it every time. Is it possible?
I would just like the person log it with is Dropbox and password account, and that's all.
My main problem is that Dropbox is asking each time a captcha which is bugging me...
How can I avoid that captcha question?
Thanks in advance.
If you RTFM, you will have everything for your code.
https://www.dropbox.com/developers/documentation/objective-c
Check the example provided by Dropbox:
https://github.com/dropbox/dropbox-sdk-obj-c/tree/master/Examples/DBRoulette
It is probably because you ask several times the token...
The Dropbox iOS SDK will automatically store the access token that results from the app authorization flow, so you only need to send the user through the flow once.
That is, check if you already have an authorized user, and don't call authorizeFromController if so.
For reference, the captcha itself won't always be shown during login. Dropbox has an anti-abuse system that will decide if/when to show it on various factors, but that's not something you can turn on/off yourself.

SFSafariViewController OAuth implementation

In the apple WWDC 2015-504, the SFSafariViewController has been announced.
Ricky Mondello claimed that the new secure, stable, and fast embedded Safari browser is capable of creating authentication flows, with two easy steps, passing though AppDelegate.
I wanted to give it a try, so i searched a bit on the implementation for OAuth2 using SFSafariViewController... I found almost nothing. There are plenty of articles explaining why the SF(...) is better than a UIWebView and so on, but i couldn't find a working implementation, not even in GitHub.
I tried to open a simple url such as "http://www.google.com" and everything works just fine.
I wanted to go one step further: i've tried implemented login with OAuth in order to receive the auth token (first step of flow).
So sent my SF(...) to "https://website.com/auth?ID=...&access=..." and set as redirect URI testApp:// (The name of my app).
I was expecting to see the request in - application:openURL:sourceApplication:annotation:
but nothing at all happened.
I've also added "testApp" in 'LSApplicationQueriesSchemes' but i have had no luck.
It's been one day struggling on this problem, and i would really like to know what am i doing wrong.
Thanks.
After another day, i can assume that the iOS 9.0.2 Jailbreak was causing the url scheme issue.

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

Facebook iOS SDK Pass parameter with app requests

I would like to have my native iOS app send a request with a parameter to a Facebook user on iOS. If they accept, it will launch my native iOS app and pass it the parameter. Is this possible?
I am having marginal success using [facebook dialog:#"apprequests" andParams:dict andDelegate:self]. I am getting the bookmark counter to increment on Facebook iOS app, but I do not see the individual requests. If I tap the bookmark it launches my app but I do not see how I can get the "data" parameter I passed with the request, or even the request_id.
On desktop I see the individual messages under "Requests" section of "Apps and Games". If I accept a request, I can see it pass the request_id to my (simple echo) canvas URL. I read this can be used to fetch the associated data. But, this does not help me on iOS. My app only runs on iOS, so this canvas app will eventually just be a "this app only works on iOS," but it seemed to be necessary to get the requests to flow.
Neither of these are showing me Notifications, so maybe I am doing something basic wrong. Or, is there some other way to pass a message to a Facebook user, with a URL they could click (to launch and feed my app its parameter).
One other odd thing, I do not see how to get rid of the Requests. If I "X" them on the desktop client, it asks me if I want to stop receiving all requests from my app, and if I say no, it only hides them temporarily.
Leif, Hi - I'm the engineer at Facebook who wrote the tutorial you've referenced.
I've taken a look at the issue you've mentioned - this is in fact not a bug in the documentation and is by design.
The incoming url from a request on iOS looks something like this:
fb480369938658210://authorize?expires_in=3600&access_token=BAAG05NeN86IBAC31YWMWRHVrNCAYMy0Rv1OtqZCwdH8QDBUAt5KgZCsIbU0EOZAvMms2tZCANV9sZBWSkEzStDtt4i7YnYZA4bPgGx2XaI5s22iBMxIZAneZAv7ADi3Wi20ZD&target_url=http%3A%2F%2Fm.facebook.com%2Fapps%2Ffriendsmashsample%3Ffb_source%3Dnotification%26request_ids%3D364209433669109%252C379616028785376%252C494409170593789%252C489782271042929%252C328564930575784%26ref%3Dnotif%26app_request_type%3Duser_to_user
This is bundling together several requests, with multiple request ids into a single url.
To get the extra data coupled with this request, it is not required to have the user_id. Hitting graph.facebook.com/*request_id* is enough.
You can actually see this outlined in the documentation here: https://developers.facebook.com/docs/requests/#deleting under the 'Request ID Format' heading.
The code contained in the Friendsmash sample and on the tutorial works correctly - I verified it just now. So it should serve as a good guide to the OP's question.
Thanks!
I have been struggling with this too.
First, the FB iOS SDK requests tutorial is a good start.
However, there are also a few bugs that makes things not work as expected:
It seems that currently, a mobile web url has to be set up for the FB app in order for requestIds to be forwarded from the native FB app to your native app. See this bug report.
The tutorial mentioned above uses an erroneous graph path for the request object. I uses "request-id" where it should be "request-id"_"user-id". I have filed a documentation bug report on that issue.

Resources