Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4506] iOS: Crashes when calling Ti.Contacts.requestAuthorization

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNot Our Bug
Resolution Date2016-09-25T15:42:12.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterMike Neill
AssigneeShak Hossain
Created2016-09-25T13:12:24.000+0000
Updated2016-09-25T15:42:13.000+0000

Description

In my application I am using the TI.Contacts framework for pulling contacts from the device. This has been working correctly, but when I updated to Titanium 5.5.0 this line started to crash. The odd thing is I do not get a stack trace or error in the debugger at all. The application simply terminates without any information regarding the crash. Has this been deprecated and I just missed it?

Comments

  1. Mike Neill 2016-09-25

    I also updated my code to reflect exactly what is in your documentation. This is what I have. Any thoughts as to what is wrong? Is there a framework I need to import? if (Ti.Contacts.hasContactsPermissions()) { // do some work } else { Ti.Contacts.requestContactsPermissions(function(e) { // do some work }); }
  2. Hans Knöchel 2016-09-25

    Hey Mike, iOS 10 requires the user to add usage-description keys to the plist when accessing certain platform API's. In your case, you need the following key in your plist-section of the tiapp.xml:
       <key>NSContactsUsageDescription</key>
       <string>Can we use to your contacts?</string>
       
    This is behavior we can't prevent, since iOS will crash the app intentionally. So as soon as you add the key and clean-rebuild your app, everything should be fine. Also check our [5.5.0 blog](https://www.appcelerator.com/blog/2016/09/ga-release-for-titanium-sdk-5-5-0-appcelerator-cli-5-5-0-appcelerator-studio-4-7-1/) for details on the iOS 9 > iOS 10 migration if you want. Thanks!

JSON Source