2013-10-12 9 views
12

मैं अपने ऐप में सभी मूल पता पुस्तिका संपर्क आयात कर रहा हूं। वर्तमान में, ऐप के लॉन्च पर 'संपर्कों तक पहुंच की अनुमति' की अनुमति मांगने के लिए अलर्टव्यू किया जाता है।संपर्कों तक पहुंच की अनुमति देने के लिए अनुमति के लिए पूछें आईओएस

मैं इसे कैसे बदलूं ताकि ऐप में कहीं और अनुमति मांगी जा सके? एक बटन के क्लिक पर, बस Instagram की तरह?

इस तस्वीर देखें:

enter image description here

+0

जांचें [प्रोग्रामेटिक रूप से संपर्कों तक पहुंच का अनुरोध करें] (http://stackoverflow.com/questions/12648244/programmatically-request-access-to-contacts) –

+0

आईओएस 9 और ऊपर: http://stackoverflow.com/a/ 3 9 374 9 16/569789 – Zaraki

उत्तर

22

आप प्रलेखन HERE पढ़ सकते हैं। यहाँ ट्यूटोरियल है कि आप आप HERE और HERE पा सकते हैं कि देखने के लिए पसंद कर सकते हैं की एक और जोड़ी हैं

//First of all import the AddRessBookUI 
    #import <AddressBookUI/AddressBookUI.h> 

    // Request to authorise the app to use addressbook 
    ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(nil, nil); 

    if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) { 
    ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) { 
     if (granted) { 
      // If the app is authorized to access the first time then add the contact 
      [self _addContactToAddressBook]; 
     } else { 
      // Show an alert here if user denies access telling that the contact cannot be added because you didn't allow it to access the contacts 
     } 
    }); 
    } 
    else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) { 
    // If the user user has earlier provided the access, then add the contact 
    [self _addContactToAddressBook]; 
    } 
    else { 
    // If the user user has NOT earlier provided the access, create an alert to tell the user to go to Settings app and allow access 
    } 

:

आपके प्रारंभ करने के लिए कुछ कोड है।

आशा है कि इससे मदद मिलती है!

अद्यतन: आप पहली बार आपके ऐप्लिकेशन को लॉन्च पता लगाने के लिए didFinishLaunchingWithOptions उपयोग करने के लिए:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) 
    { 
     // The app has already launched once 
    } 
    else 
    { 
     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"]; 
     [[NSUserDefaults standardUserDefaults] synchronize]; 
     // This is the first time the app is launched 
    } 
} 
+0

कूल, मैं ऐप के लॉन्च पर एक्सेस के लिए पूछने वाले ऐप को कैसे रोकूं? – Hassan

+0

@ हसन मेरे ऐप लॉन्च होने पर पहली बार पता लगाने के तरीके पर मेरा अपडेट जांचें। अन्य भाग में, आप संपर्क पहुंच के लिए नहीं पूछने के लिए कुछ कोड लिख सकते हैं। – AJ112

+0

वास्तव में मेरी मदद की! धन्यवाद दोस्तों –

0

ऐप्लिकेशन की अनुमति के लिए पूछ रहा है जब आप संपर्कों पुनर्प्राप्त प्रयास करें।

लॉन्च करने के बाद नहीं, बस बटन स्पर्श के बाद पुनः प्रयास करें।

+0

क्या कोई तरीका है जो अनुमति मांगते समय हिट करता है? – Hassan

संबंधित मुद्दे

 संबंधित मुद्दे