SKProductsRequest before screen shows - swift

I have a simple question: How do I load the SKProducts before the screen loads?
I want to do this because they start to load in viewWillAppear but that isn't enough and it takes 1-3 seconds or even more depending on the internet speed for the IAPs to properly load and if the user presses any button to buy an IAP the app crashes because they haven't loaded.
So how to I make sure that they are loaded when the screen shows up?
NOTE: It's not the initial screen. It's a separate one which shows up when the user presses a button.

I didn't find a complete fix for this but I disabled the buttons until the app contacts the AppStore. Not perfect because users wait a few seconds and app crashes if you press the buttons right after they are enabled but it's an improvement and I'm fine with that.

Related

Going back from Calendar to my app

Im my app, I have this code at a given time:
UIApplication.sharedApplication().openURL(NSURL(string: "calshow://")!)
which takes you to the calendar of the device. How could I get back to the scene where that line is executed?
Thank you.
EDIT:
Pressing home (option+shift+h, since the frame is not shown in my iOS Simulator) takes you to home, not the app, as it should be.
A quote from this:
Unlike other platforms such as Android, iPhone does not create a stack of actions (back stacking on Android). What this means is that if you do decide to launch another application, your application will not resume when the user exits from the application you opened.
If user want to get back to your app, they should press home (option+shift+H) twice, and select the your application from the list.
iOS9 introduced a new "Back-To-App" button at top-left corner, which allow you get back to your application. You should see this button after the calendar is showed from your app.

iphone lock button and the running app

this may be a simple one, but I don't know the answer.....
For testing whether my location-based app receives updates in background, I usually run the app and then press the Home button to put the app in background. However, I am curious whether pressing the Lock button (at the top) will put the app in background or not.
Regards.
Yes. Hitting the lock button does background the application. However when you unlock it, the application is then brought back to the foreground. Should be able to test this within your App Delegate and simple log statements.

Using a splash screen instead of a loading screen - a violation of Apple's HIG?

I have a splash image that I want to display when the app is launching. I use it as a launch image - I want it to be displayed until the program is launched (rename the picture to Default.png).
In apple's HIG they say one should "avoid" using a splash screen as a launch image.
I know it's not recommended and that users often don't like them, but will it make Apple reject my application? If so, how can I display a splash screen so it'll be displayed as soon as the app goes on, but not violate those rules? because I have seen applications with splash screens as launch images.
Thx in advance!
It's not that Apple will reject your App just coz you have a splash screen. But it's advisable to not have a splash screen as the user has to wait. Better not make the user wait...
Flipboard which was the Apple App of the year in 2010 has an image splash screen. As the user enjoys the images, data is downloaded in the background so that as soon as the user flips the page, the next screen is all ready & up to date. But they have made it in such a tasty fashion that the user hardly feels as if he's been made to wait. So it all depends on your design...
If you plan to simply use the Default.png mechanics to display your splash image, there is no problem.
The issue arises when you would like to prolong the display of such image only for the sake of it. This is what the HIG are against: that the user is made to wait without any real benefit. It is also to be noticed that with the advent of multitasking (iOS 4), the effect of showing a splash screen is reduced, since most of the times the app is not closed, so you see no splash screen at all when you go back to it.
On the other hand, it is understood that if you need to do some setup task in your app that take time and you have to do that at startup, then the user will have to wait. It is important, though, that he/she be notified of the wait and why it is for. This could mean, e.g., displaying a label on top of your image saying: "Loading..." or "Preparing data..." or whatever your user might better understand as part of the functionality of the program.
As to how to do it, there is no other way, AFAIK, than starting your app with a view that is exactly the same as Default.png (a simple UIImageView would do). That means, that in you appDidFinishLaunching delegate method, you create the view and attach it to the window; then, when you have done with your app preparation, you switch to your real view.
This would give you also the chance to add the label or whatever other kind of messaging to the user.

Push Notification Alert opens app when unlocking an iPhone

I see a very weird behavior and I am trying to understand if it is designed that way or simply not handled correctly from my app.
My app sends push notifications in the form of UIAlertViews.
When the device is not locked the UIAlertViews appear with two buttons and if the user taps on the right button my app is launched.
What I have noticed is that if the device is black screened to save power and the user taps on the home button and there is a push notification alert from my app with only the OK button waiting for him there, if he slides to unlock the device he automatically enters my app.
Is that a normal behavior or a bug of some sorts? I thought that only UIAlertViews with two buttons allow the user to launch the app.
If a push-notification-message gets sent to a locked phone, it stays there for about five minutes. When the user slides to unlock, the app that sent the notification is opened.
This is default behavior, look at how the SMS-app and Calendar-app does the same.
For me (OS 4.1), normal behaviour is for a push notification to unblank the screen and show an alert with no buttons; the slider says "slide to VERB". If the phone goes back to sleep and is woken again (either by waiting or by hitting the sleep switch), it then says "slide to unlock" and unlocking doesn't launch the app.
I don't see an "OK" button (perhaps it's an OS 4.2 feature; if so, don't discuss it here).
Either way, the user only has three choices:
Don't unlock the phone
Unlock the phone and ignore the notification
Unlock the phone and launch the app
Making the user unlock before choosing what to do about the notification adds an unnecessary step, and letting the user tap the VERB button without unlocking the phone is a bit silly. The common case is that the user will want to immediately view the notification (and reply to the text or whatever). The uncommon case is that the user will want to ignore the notification (so press OK and then unlock, or sleep/wake and then unlock, or unlock and immediately close the app). If the notifications are a nuisance, then the user will simply disable them for the particular app.

iPhone - Multiple instances of an application running?

When i start my app for the first time after installing it and exit before the splash screen disappears, from then on launching from the multitasking menu it comes up with a black screen. If I click on it from the home screen it loads fine but every time I try from the multitasking menu it is a black screen until I terminate it. If I add the UIApplcationExitOnSuspend property to the properties list the black screen continually appears until i restart the device. Any help is appreciated.
Thanks Sj
A couple things:
You probably don't want to suspend your app prior to the splash screen disappearing. applicationDidFinishLaunching is running code (you know, like adding a window to the app) while the splash screen is showing. If you suspend it early, it doesn't have a chance. This may not be the case after the first time install but if I were you, I'd give it the time it needs to do initial install instead of interrupting it.
Another less likely scenario: Are you doing this while the debug is still running? I've only had an issue similar to this (black screen after suspend) if I leave debug running and then suspend the app to the background. As soon as you bring it back out of the background, you get a black screen, so in that case it's a bug. If you hit the stop sign button in XCode to kill the app, it worked fine after that.. but you have to kill it before suspending it.
My guess is your likely cause is #1. Give the app more time to do the initial load. After that, it should be fine. For whatever reason, the first time installing/loading is always the slowest.