can SKStoreProductViewController loadProductWithParameters run in background? - ios

every one knows that skstoreproductviewcontroller's loadproductwithparamters method need to ask app informations from web,so it load very slow,is there any method to run loadproductwithparameters in background to show the app information fast?

The information will naturally load in the background and the intention is that you call loadProductWithParameters:completionBlock: before you actually want to display the view (and you can use the completion block to either show the view or to tag the item as being available to show).

Related

SKStoreReviewController.requestReview() stop to work in debug mode

I have an app that I call the method SKStoreReviewController.requestReview () after 10 times that the user performs some action. The prompt stoped to appear even the debug show me that the method requesrReview is being called.
What's can be happening?
From the Apple docs:
Although you should call this method when it makes sense in the user
experience flow of your app, the actual display of a rating/review
request view is governed by App Store policy. Because this method may
or may not present an alert, it's not appropriate to call it in
response to a button tap or other user action.
The popup will only display sometimes, and it's dictated by the SKStoreReviewController as to when this will be, so you can't guarantee it will ever be displayed.

IOS initial view controller based on condition retrieved from database

An iOS app I'm creating shows a setup screen upon first launch which requires data to be written to the database.
Upon launch, I need to access this value form the database.
If it is set, launch main view controller
Else show setup view controller.
As far as I'm aware theres two ways I can do this, programmatically setting it from the AppDelegate or using an initial View Controller as a splash screen and performing the look up and segue there.
What would be the best way to approach this? Is it wrong to do a database lookup in didFinishLaunchingWithOptions?
Using a splash screen is probably the better option as it provides better scope for modification in the future and allows you to update the user on progress. It is fine for the app delegate to run logic to determine how the app starts but you should endeavour to keep the app delegate minimal and focussed.
I very much doubt that you would get this approved (if your goal is the App Store). Your app delegate needs to create a window, and set a rootViewController to that window before it returns YES in appFinishLaunching:
You simply do not have enough time to check with a server before creating the first viewController and you'll be creating poor interface if you try. I suggest the first ViewController will need to be informing the user that it is checking with the server with an activityIndicator or something. The best :)

How to frequently update today widget in notification center?

I am finding that my Notification Center widget does not reload very often. Because of this, out of date data being presented. I have not been able to find a way to get the widget to refresh every time I open the Today view. I have seen apps such as NBA Gametime that are able to update every time I pull down to see the widget.
How can I get this functionality in my app?
Based on my own experimentation and also reports in this SO thread, it appears that the TodayViewController.viewDidLoad() function gets called every time the Today/Notifications area gets opened. More specifically, #Karl Monaghan reported in a comment that the iOS 8.1 release notes have the following to say:
The schedule and intended use of widgetPerformUpdateWithCompletionHandler: is intended as a convenient home for all data/model update logic. If implemented, the system will call at opportune times for the widget to update its state, both when Notification Center is visible, as well as in the background. An implementation is required to enable background updates. It’s expected that the widget will perform the work to update asynchronously and off the main thread as much as possible.
So, to answer your question:
I don't think we'll ever really know how often the widgetPerformUpdateWithCompletionHandler method gets called, and I think Apple prefers it that way
The viewDidLoad function does get called every time the widget is displayed, so it's possible that you could put a call to the update function inside of that method. Or you could just put whatever updates you need to be shown in the widget inside of that function, although I don't know what kind of impact that will have on app performance.
Hope this helps.
Update
I've also found that either one of initWithCoder or initWithNibName seems to get called every time the widget is displayed on the screen, so it's possible that you could put calls to update your widget in those files, but if I recall correctly the view is not actually instantiated at this time so it's better NOT to put your code to update your widget in these functions.
In your widgetPerformUpdateWithCompletionHandler you need to to let your widget know that it needs to update. Apple Docs
-(void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
// Perform any setup necessary in order to update the view.
// If an error is encoutered, use NCUpdateResultFailed
// If there's no update required, use NCUpdateResultNoData
// If there's an update, use NCUpdateResultNewData
completionHandler(NCUpdateResultNewData);
}

Does delegate have function which is executed every time app comes from background

I have application with lot of view controllers and on every time when app comes from background I have to make some request to server and reinitialise some global variables. At the moment I am doing this by repeating code in every view controller in didViewLoad but I wonder is there way to this in delegate to avoid repeating on 10 places ? ( I check didFinishLuanchingWithOptions in delegate but it is called only first time not when app comes from background ).
I think you want to look at these two:
applicationDidBecomeActive
And
applicationWillEnterForeground
Check out the documentation for more details.

Function execution if next view is loaded

I am new to Parse and iOS app development, so please pardon my question if the answer is obvious.
Does a function execution continue if the next view in a view hierarchy (nav controller) is loaded?
I currently have a view where the user takes a picture, which is then displayed on screen. I want to begin the upload and packaging of this image immediately, to save time. So my question really deals with the [saveInBackground] and [getObjectInBackground] functions. If the user taps the button to go to the next view, before the upload is completed, will the functions stop their execution or continue until it completes?
Thanks
Siddharth
As long as you use the function saveInBackground, your photo will be saved even if switching views. If you used saveEventually then the photo would be saved whenever it can (if there is no internet it will upload it when internet becomes available).

Resources