Request for access to photo library prompt stays in the background - ios

My request for photo library permissions prompt is supposed to pop up as soon as the app is launched. I have set up my info.plist with the library permission.
I have tried both adding/removing the requestAuthorization(_:) function in my AppDelegate.swift in various lifecycle functions.
Current output: The app launches and stays on the launchscreen. When i click on the home button the app minimizes and the permissions prompt appears(as though it was lingering in the background). On allowing permission everything launches as expected.
Desired output: The app launches and the photo library permissions prompt appears on top(as it should). On click of which everything runs as usual.
I can attach pictures if this is not descriptive enough. Also there is no pertaining code as i have removed the requestAuthorization(_:) function(cuz not required). Any tip would go a long way as I have been fiddling with this for days now trying to get this fixed. Thank you!

Your request call should be in the view controller (i.e. viewDidAppear), not the AppDelegate. Having the call in the app delegate is probably causing it to fire at an inappropriate time.

Related

Killing an iOS app programmatically

I have an app when a specific action fires I close the app and ask the user to reopen it again.
The problem is when the app executes exit(0) the app stays in the apps stack (when I click the home button twice). I want it to be killed completely so that viewDidLoad() will be executed again when the app opens.
You cannot terminate an app on it's own.
From Apple's Human User Guidelines...
Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to
interpret this as a crash. However, if external circumstances prevent
your application from functioning as intended, you need to tell your
users about the situation and explain what they can do about it.
Depending on how severe the application malfunction is, you have two
choices.
Display an attractive screen that describes the problem and suggests a
correction. A screen provides feedback that reassures users that
there’s nothing wrong with your application. It puts users in control,
letting them decide whether they want to take corrective action and
continue using your application or press the Home button and open a
different application
If only some of your application's features are not working, display
either a screen or an alert when people activate the feature. Display
the alert only when people try to access the feature that isn’t
functioning.
Have a look at this answer: https://stackoverflow.com/a/8491688/742298

Start app and navigate to the view previously displayed

I have an app (iOS, Swift) which is usually started in the morning by the user. The user will press a couple of buttons, enter some text, move to other views (using a navigation controller) and so on. When everything is filled out the right way, the user will put the iPhone into standby mode. As far as the app life cycle is concerned, it will enter the background state. When the user opens the app again, he will still be on the same page, with the same parameter, ... Everything is fine.
In case of a suspended app (due to a lack of resources or other stuff), the app will start again from the beginning and not from the view where the user has navigated to before. In such a case, what's the best way to navigate to the specific view the user was when bringing the phone into the standby mode and keep respectively build up the whole navigation stack as it was before the suspension?
You can use Apple state restoration and preservation technique for this purpose. Here you can find an example provided by Apple.
Hope this will help.

Should touchID be displayed if app minimized

Im implementing touch ID to "unlock" my app, and im not sure if ive run into an apple bug or something i need to handle myself. If i tap the Home button and minimize my app before evaluatePolicy can load the Touch ID prompt, it appears over the home screen.
![not enough reputation to display screenshot, so heres a link]https://www.dropbox.com/s/zrhc60lx87ze7mt/IMG_0016.PNG
Successful/failure/cancel evaluation of this policy does nothing, but when i re-enter the app and cancel it again, touchID seems to be disabled forever until i restart the phone.
Anyone else running into this issue or have an ideas?
P.S. Theres an open radar where errSecUserCanceled is never returned from a cancel button tap, so right now i fall into my errSecAuthFailed case, which could also be the cause.
Answer is no. It should not be be displayed, when minimized.
The problem is IMHO that the code segment is being called again from your app when it goes to the background. For example loadView , didLoad and so on.
Try moving the code, that calls the authentication somewhere else in the program (different method).
For example, if your code uses a textView to enter password, you can implement the authentication within keyboardWillShow or similar.
Hope it helps.

Can the startup/splash screen be changed depending upon the state of the application upon startup?

My app has a registration screen that is only presented once, and after registration is completed it is never shown again.
If my startup screen is a screenshot of the app then I would need to provide two screenshots and for the correct one to be initially displayed when the app launches.
Is this possible?
No, it is not currently possible. You cannot access the Default.png (or whatever you've named it instead) from your app to update it.
If it were me, I would set the startup screen to the one that is appropriate long term. You could also theoretically update your registration screen to be a bit closer to the look and feel of the main app screen, so it isn't so far off visually.

iOS restore state issue

I recently upgraded my old iPhone app and the new state restore iOS 3/4 feature has introduced a problem. I don't know the name of this restore state feature - what is it called?
Here is my problem scenario:
I navigate into a detail screen on my app. I click a button to navigate to an address and it launches google maps as expected. Then I launch my app again. It briefly shows the last screen I was on, but immediately launches the google map again.
What I want is to simply restore the detail screen that I was last on.
Any hints?
thanks
It is called multitasking, and it is built in automatically when you build under iOS 4.0+. Without you posting any code, it is tough so say, but why don't you put a breakpoint at the line that redirects to Google Maps and see what is calling it. Then you can backtrack to see why it is being called on the reopening of the app.

Resources