From 807115da2e4a6a703c0529f03da8f335223eb89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Corre=CC=82a?= Date: Tue, 20 Oct 2020 13:42:08 +0100 Subject: [PATCH 1/3] fix: changed dispatch_sync to dispatch_async issue: https://outsystemsrd.atlassian.net/browse/RMET-306 --- src/ios/CDVContacts.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ios/CDVContacts.m b/src/ios/CDVContacts.m index 6b230332..b2061f56 100644 --- a/src/ios/CDVContacts.m +++ b/src/ios/CDVContacts.m @@ -597,7 +597,7 @@ - (void)createAddressBook:(CDVAddressBookWorkerBlock)workerBlock // NSLog(@"addressBook access: %lu", status); ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { // callback can occur in background, address book must be accessed on thread it was created on - dispatch_sync(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_main_queue(), ^{ if (error) { workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]); } else if (!granted) { From 6af2a5c8b97d4a4d633acde2adb23519ea4dcca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Corre=CC=82a?= Date: Tue, 20 Oct 2020 15:02:23 +0100 Subject: [PATCH 2/3] chore(release): raise version to 3.0.1-OS3 --- package.json | 2 +- plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ed5b111a..39d05327 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-contacts", - "version": "3.0.1-OS2", + "version": "3.0.1-OS3", "description": "Cordova Contacts Plugin", "types": "./types/index.d.ts", "cordova": { diff --git a/plugin.xml b/plugin.xml index f5e9b6c3..647ce972 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" id="cordova-plugin-contacts" - version="3.0.1-OS2"> + version="3.0.1-OS3"> Contacts Cordova Contacts Plugin From c90dcc5e89fc7792a6ef4663491dc721c263ddeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Corre=CC=82a?= Date: Fri, 23 Oct 2020 11:33:33 +0100 Subject: [PATCH 3/3] fix: ABAddressBookRef created on main thread issue: https://outsystemsrd.atlassian.net/browse/RMET-306 --- src/ios/CDVContacts.m | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ios/CDVContacts.m b/src/ios/CDVContacts.m index b2061f56..108006e3 100644 --- a/src/ios/CDVContacts.m +++ b/src/ios/CDVContacts.m @@ -589,13 +589,13 @@ - (void)createAddressBook:(CDVAddressBookWorkerBlock)workerBlock // TODO: this probably should be reworked - seems like the workerBlock can just create and release its own AddressBook, // and also this important warning from (http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/BasicObjects.html): // "Important: Instances of ABAddressBookRef cannot be used by multiple threads. Each thread must make its own instance." - ABAddressBookRef addressBook; - - CFErrorRef error = nil; - // CFIndex status = ABAddressBookGetAuthorizationStatus(); - addressBook = ABAddressBookCreateWithOptions(NULL, &error); - // NSLog(@"addressBook access: %lu", status); - ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { + dispatch_async(dispatch_get_main_queue(), ^{ + ABAddressBookRef addressBook; + CFErrorRef error = nil; + // CFIndex status = ABAddressBookGetAuthorizationStatus(); + addressBook = ABAddressBookCreateWithOptions(NULL, &error); + // NSLog(@"addressBook access: %lu", status); + ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { // callback can occur in background, address book must be accessed on thread it was created on dispatch_async(dispatch_get_main_queue(), ^{ if (error) { @@ -608,6 +608,8 @@ - (void)createAddressBook:(CDVAddressBookWorkerBlock)workerBlock } }); }); + }); + } @end