iOS Terminated due to signal 9 on allowing permission [duplicate]
Asked Answered
N

2

10

I am making an iOS app and I am new in iOS world. In this app, I want to access user contacts. Everything is going good and working well. But I experienced a amazing behavior which I have not seen in Android since I am android developer.

In iOS to access user contacts I am using Contacts Framework. I think it is relatively more easy and fast then anyother else in the iOS. However, I did not able to completely take advantage of that. Let me tell you what I did and what Problem did I faced.

What I have done I cask for permission on ViewController and User is prompt with Dialog asking for contacts permission. If user allow permission, everything goes well, but when user dont allow the permission here comes the trouble.

Accessing User contacts are more necessary since My app's whole working and basic business idea is upon user contacts. Now to handle this, when user Do not allow permission I am showing another dialog telling him that He must allow permission so that App can continue, So far so good.

Now I am taking user to settings where he can allow the permission or he can simply go again back. Now checkout 2 cases

CASE 1: When User come on Settings screen and go back again without allowing permission When I take user to Settings screen and instead of allowing permission he gets back to my app I try to show him same dialog again to enable permission in every case. This is going good. I mean for testing purpose I repeat same procedure manytimes, I mean I do not allow my self Contacts permission, It takes me to setting scree, from settings screen I get back to my app and again I am able to see same dialog that took me to settings scree. THIS IS FINE

CASE 2: When User is taken to settings screen and he permits the permission: Here when user allows the permission I get message in the log that is "Message from debugger: Terminated due to signal 9". And when I get back to my app, it starts over again. Looks like my app gets re-open or crashed being in background.

Important: For this I examined my memory or task anything that is being performed in background, but there is nothing going on in background. My memory size before crashing is 54.78 mb. And I do not think so it is worth worying.

Any one have idea what is going on??

Nataline answered 27/11, 2018 at 6:1 Comment(0)
P
18

Your app is not crashing its just forced to restart by iOS with new privacy settings. iOS will SIGKILL the app. (it's default behaviour of iOS). You can checkout - WWDC 2012 Session Videos: Privacy Support in iOS and OS X for more info on this.

This does not hold true for Location permissions.

Pechora answered 27/11, 2018 at 6:12 Comment(4)
great, but this will annoy user, because if he allows permission and he wants to get back to app, then how to take him to same View Controller?Nataline
@SharartiKAKI you can restore app's state. follow this tutorial on how to achieve this - raywenderlich.com/…Pechora
So for clarity.. If testing on a device whilst developing this crash disconnects from the debugger and doesn't restart the app but on a live release the app would restart?Latvina
@Nataline That's one of the iOS sandboxing design pitfalls. I believe that will be fixed ever, but till now, it's not a big deal to care about unless you're expecting users not to juggle privacy settings too often.Hahnke
G
5

It is expected behaviour. iOS terminates the app when user changes permission for Contacts, Camera, Microphone and Photos (and possibly some others).

Garment answered 27/11, 2018 at 6:10 Comment(2)
In one place I was getting Location permission, but on clicking back I was getting back to same View Controller, but in this case, if it is default behavior then How to getback to same view controller, or else it will annoy userNataline
Toggling "Allow Tracking" kills the app too now after implementing App Tracking Transparency Framework.Haricot

© 2022 - 2024 — McMap. All rights reserved.