Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Ti.Contacts.requestAuthorization callback always returns success :-(

$
0
0

Hi,

following the code from the official documentation:

var performAddressBookFunction = function(){...};
var addressBookDisallowed = function(){...};
if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED){
    performAddressBookFunction();
} else if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN){
    Ti.Contacts.requestAuthorization(function(e){
        if (e.success) {
            performAddressBookFunction();
        } else {
            addressBookDisallowed();
        }
    });
} else {
    addressBookDisallowed();
}
I have tested on iPhone 4 (iOS 6.1.3) and iPhone 5 (iOS 6.1.4) and the callback (regardless of allow or decline) always returns:
code = 0;
success = 1;
So there is no way to get the authorization status directly from the requestAuthorization callback.

As a workaround this works for me:

...
    Ti.Contacts.requestAuthorization(function(e){
       if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED) {
          performAddressBookFunction();
        } else {
            addressBookDisallowed();
        }
    });
...
Anyone else has this problem?

Tested with SDK 3.1.0.GA

Best Danny


Viewing all articles
Browse latest Browse all 8068

Trending Articles