I'm creating an iOS native app version of a web app that uses jQuery to fetch information from its database. Is there a way to make an ajax call in iOS that returns a JSON object?
You're going to want to take a look at NSURLSessionDataTask. This will return JSON as an NSData object . Here is a link to the docs.
If you want to make the request asyncronously, NSURLConnection class here.
Related
I am using the URL
http://itunes.apple.com/lookup?bundleId=com.myCompany.myApp
to get a JSON file with the information about my app. This works if the app is already published on the App Store but I am still developing it and the result coming from that URL contains just this:
{
"resultCount":0,
"results": []
}
I have tried to use
http://sandbox.itunes.apple.com/lookup?bundleId=com.myCompany.myApp
and
https://sandbox.itunes.apple.com/lookup?bundleId=com.myCompany.myApp
and I receive
Http/1.1 Service Unavailable
Any ideas?
It's not possible to do that. I'd suggest using another way to get the data you need or mocking the response you expect while the app isn't available and forward the request to Apple as soon as data is available.
I'm creating an iOS app by swift that is as same as the AliExpress iOS app.
This App has ability that connect to our site and download all of data from JSON api online.
Now, I wanna download the images of the icons and banner slider from our site by JSON api in main page. But I don't know how i can do it. Do I use queues or background functions like in android? Also, I'm an android developer and i know how i can do this in android. You can guide me by this way ,too. please guide me by sample codes or description of its logic.
Please refer following link for tutorial
http://www.raywenderlich.com/51127/nsurlsession-tutorial
Apple documentation can be found on following link
https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSURLSession_class/
Swift example can be found here
http://jamesonquave.com/blog/making-a-post-request-in-swift/
I have also created a demo for the same
https://github.com/Gagan5278/SessionDownload
Let me know if you want more on this.
You have the seed of your answer in the title of your question. You want to create an NSURLSession and add NSURLDownloadTasks to it. That class does all the work for you.
A quick search on Github reveals this repository that claims to offer an async download queue in Swift:
https://github.com/Gurpartap/Cheapjack
(I haven't used that one. You can either build it into your project or look at the code and use it to implement your own download sessions.)
There is also AlamoFire, another swift library that has built-in JSON support.
I'm trying to write an iOS Objective-C app to login to an old website. Note I don't have control of the website so I have no way of changing the login.
The procedure is:
Open browser at specific URL.
User enters their username and password.
Website returns a file called something like bad_link.smith.
App reads file to get key to use for API.
Is it possible to do this in iOS - open a URL from an app and have the file returned?
You could use UIWebView Delegates for this
Implement this https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIWebViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIWebViewDelegate/webView:shouldStartLoadWithRequest:navigationType: delegate method and get the URL the user is going to and if the URL matches the URL you want to download then you can get the URL by the NSURLRequest and download it seperately. :) Hope I helped you.
What other thing you could do is make the code native and without the browser and simulating as a browser in the code. Can be used if no CAPTCHA is there. Do tell if you need more info on this.
I am running into a situation which I am not sure is possible from technical/design point of view. Please advise.
Here is what I need:
I have an open URL registered for my native iOS app. I expect a request ID to be passed along with it and once hit I open that request.
From within my native iOS app, I need to open a web page in the webview. This page has few buttons in it.
A tap on the button in the webview should open the request inside my app. So, I want to trigger the registered open URL in step #1.
Web page data is dynamic and will change on the fly.
Is this a feasible design. Shall I consider something else.
Any advise/pointers will be appreciated.
This should be possible. Here's a though:
1: Implement the UIWebview delegate method shouldStartLoadWithRequest.
2: when you intercept that your webview is attempting to access the url yourapp://blah-blah-blah you can return NO instead dip into your appdelegate can manually call the function handleOpenURL.
I've seen something similar in the past with supporting oAuth (I believe it was with instagram) within one of our apps. We basically loaded up the login page in a UIWebview and then when we detected the the post login redirect we parsed the oAuth token from the url and called it good.
Good luck
How to get metadata with include_media_info=true via dropbox core api sdk for iOS?
The official Dropbox iOS Core SDK doesn't currently support include_media_info yet, but it is open source so you can modify it to support it. For example, the SDK uses this method to call the HTTP API:
- (void)loadMetadata:(NSString*)path withParams:(NSDictionary *)params
The documentation for the HTTP endpoint itself can be found here.
I haven't implemented and tested this, but at a glance it seems you'd have to implemented a new metadata method that sets include_media_info in the params that it passes to the above method, or just always sets include_media_info if you know your app always needs it. You'd probably also have to update DBMetadata to returned the media info.