iOS Widget creation - To make a Webservice call and populate date like graph - ios

I'm new in iOS widget implementation. Just want to check my requirement is applicable for widget creation.
I want to make a web service call and get the data to populate the values like a graph on iOS Widget.
For example : STOCKS app functionality I wanna achieve.
How can i communicate my app and widget. Is it possible to make a service call on TodayViewController.m class.
I went through couple of forums but not getting any solution.
http://www.appcoda.com/app-extension-programming-today/
https://code.tutsplus.com/tutorials/ios-8-creating-a-today-widget--cms-22379
Please let me know your ideas.
Thanks in advance.

Yes it is possible to make network call (I've done a twitter widget and a RSS widget doing so).
Only restriction you can have is the memory. If you are displaying images in a tableview inside your widget, it can be tricky and crash. Apple allows developpers to use a very small amount of memory so keep that in mind.
For instance in my RSS widget, I have a tableview with three rows and one image inside each row and it's very short in memory (I have memory warnings).
That said, if you want to communicate informations you have received with your widget to your app, it's also possible. I use NSUserDefaults to do so, and I synced it between the widget and the app. If you want to use that, don't forget to create a share space between your app and your widget ;)

Related

Making UI elements programmatically in iOS using Xcode in Objective-C

I am trying to parse json data and convert it to form in iOS. I am successfully able to parse data and display it, however, i want to fix the UI and make it look more like an iOS form, perhaps using tableviews, etc.
How do I approach this? should I just use a tableviewController or use a tableview? (the fields are dynamically added, so I have no idea what type and how many fields I will have, until I make a call to the API and fetch the data from the json that I get)
Are there any easy to use libraries in iOS that I can use?
That's not how UI design works on iOS. For the specific example that you mentioned of a tableViewController getting fed from an API... You'll create a tableViewController and you will design a demo cell.
Then you will fetch the results from your API, parse it. And you will iterate over the results returned by the API, inside that iteration you will programatically create the table cells (thus ensuring that you are creating as many tables as you need).
Nevertheless this is a extremely vague question, and besides briefly explaining how this whole thing works on general terms, there is not much more I can do without you posting the code you have so far.
Allow me to refer you to this tutorial by NSCookBook that although old is gold when it comes to these things.
Regards,

Add Call Extension to Search Ads based on API call

I am making click to call based ad which you might see in the above example image. What I want to achieve is that I want to show that number dynamically, meaning that when the call representative is available it shows in the ad but when the representative is not available then the ad wouldn't show the click to call button.
To clear this more: I want to make an API call to the server which will tell me if any representative is available or not.
I am using JavaScript for my front-end and back-end, so let me know if I can do it using that or any other suggestions are welcome too.
What I have done so far:
As per my research I can not this, but I may be wrong and that's why I am posting a question here. Thanks in advance.
No this is not possible.
If you have clear working hours for callcenters then you can schedule ad with and without Call Extension ads based on that.
Reference : Create an ad schedule

iOS 8 Today Extension: Is it possible to add editable text field?

I am trying to create a simple Today Extension. I was able to add a label wherein the value can be updated via the main app. Now, I am exploring the possibility to update the value in main app via the extension. However, when I tried to add a textfield, I cannot input anything.
Is this a limitation of the extension? If not, can you please guide me how to accomplish this? Thank you very much!
Unfortunately, it is a limitation.
It says in Apple's extension programming guide:
Because user interaction with Today widgets is quick and limited, you should design a simple, streamlined UI that highlights the information users are interested in. In general, it’s a good idea to limit the number of interactive items in a widget. In particular, note that iOS widgets don’t support keyboard entry.
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Today.html#//apple_ref/doc/uid/TP40014214-CH11-SW1

Sharing HTML5 localstorage among multiple UIWebViews

I have a ViewController which has multiple UIWebViews. I am using localstorage.setItem to store some variables. But the problem is that these variables are accessible only within the UIWebViews in which has been set. If i am trying to get( localstorage.getitem) the variable of other UIWebViews it's giving null value .
WebView1=====>>>>localStorage.setItem("var1","val");
WebView2=====>>>>alert(localstorage.getItem("var1")); ===>>is null
Sorry, but that's just how the framework is designed: every UIWebView is it's own instance, isolated from other instances in the same app (just like there is no built-in pop-up or tab functionality).
If there is absolute no other way around it, you could make the web views Cordova WebView's and programatically arrange for some way to transfer data between them via the native layer (there's also alternatives, like WebViewJavascriptBridge that accomplishes the same thing).
Maybe you could even get by just by injecting the data needed using stringByEvaluatingJavaScriptFromString into a known data structure beforehand. But having the Javascript in a UIWebView call the native side is a well known difficult-to-do thing that can only be solved by using bridging solutions like i mentioned in the second paragraph.

Is it possible to load interactive elements into an iOS app?

Does anyone have any ideas how I could package an external interactive slide that could be dynamically loaded by an iOS app? Is it at all possible?
e.g. Imagine having a presentation app on an iPad. There is a set of interactive slides held on the web somewhere, let's say they contain draggable elements.
Can I load one of these slide objects into the app and interact with it? If so, what format would the slide object be?
Thanks,
Mark
Technically it's possible to dynamically load bundles (NSBundle) components in an app. These bundles could even contain executable code, though AppStore guidelines prohibit use of dynamically loaded NSBundles in this way for security reasons.
Additionally you could just use a UIWebView to display some 'slides' on a webpage, though it will be very hard to make the app behave as if it's the same as the native slides - perhaps even impossible (due to how rendering of webpages work compared to native controls, for example).
Ok so lets say you have these "external interactive slides" on a web server somehow. Since you are not saying they are of a certain type (like powerpoint or such) I will just assume that these slides are of some rare format that is probably not supported by any existing apps or the Safari browser.
Then the answer to your question would be: Write your own iOS-app that can read, present and edit these slides. What format are they? Well it doesn't matter. Write an app that can download the slide data from the data and parse it, and present it on the phone.
Then let the user interact with it, and perhaps make the app upload the changes to the server.
You can do anything you like in your app, there are no limits. You just have to write the code for it. If there was some kind of standardised format, lets say you wanted your app to show powerpoint presentations, then you would have 3 choices. Use someone else´s app, or write your own app with a parser for the powerpoint files or make your own app that use some code that someone else wrote to do it (a third part library that you include in your app)
In your specific case, I can not tell if there are any third part librarys to interact with your slides, but my guess is that you will need to do most of it on your own. You could start with looking at how the web services that interact with the slides online works, and if you can interact with them from an iOS-app that you make yourself.
There is nothing stopping you from creating an app, read the slide data into the app, present it in any way you like, let the user change it, save it in your app, or upload the changes to a server. It's all up to you =)
Good luck!

Resources