Posts

Post not yet marked as solved
0 Replies
1.2k Views
This is how I request contacts framework access permission -(void)askUserToAccessContacts {   @try   {     if([CNContactStore class])     {       //iOS 9 or later       CNEntityType entityType = CNEntityTypeContacts;       if( [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusNotDetermined)       {         CNContactStore * contactStore = [[CNContactStore alloc] init];         [contactStore requestAccessForEntityType:entityType completionHandler:^(BOOL granted, NSError * _Nullable error) {           if(granted){             DDLogVerbose(@"Permission granted for Contacts access...");           }         }];       }       else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized)       {         DDLogVerbose(@"Permission granted for Contacts access !!!");       }       else       {         DDLogVerbose(@"Permission not granted for Contacts access !!!");       }     }         } @catch (NSException *exception) {           [[WriteLogger getWriteLogger] writeLog:@"AppDelegate" sourceClass:NSStringFromClass([self class]) methodName:NSStringFromSelector(_cmd) exception:exception exceptionDict:nil];   } } What could possibly cause the app to crash? By the way, this crash is not occurring all the time, it happens randomly when I install the app and launch it for the first time. Incident Identifier: 33DC6088-0DC6-40A1-91E5-F7A76E3154EB Hardware Model: iPhone12,8 Version: 21.10.0 (0.5.2) AppStoreTools: 13C90b AppVariant: 1:iPhone12,8:15 Beta: YES Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Date/Time: 2022-01-10 11:43:38.9707 +0530 Launch Time: 2022-01-10 11:43:17.9333 +0530 OS Version: iPhone OS 15.1 (19B74) Release Type: User Baseband Version: 3.00.00 Report Version: 104 Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Kernel Triage: VM - pmap_enter failed with resource shortage VM - pmap_enter failed with resource shortage VM - pmap_enter failed with resource shortage VM - pmap_enter failed with resource shortage VM - pmap_enter failed with resource shortage Thread 0 name: Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001b73d0504 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x00000001b73d0b9c mach_msg + 76 (mach_msg.c:119) 2 libdispatch.dylib 0x000000018019127c _dispatch_mach_send_and_wait_for_reply + 520 (mach.c:815) 3 libdispatch.dylib 0x000000018019162c dispatch_mach_send_with_result_and_wait_for_reply + 56 (mach.c:2019) 4 libxpc.dylib 0x00000001f083eb9c xpc_connection_send_message_with_reply_sync + 240 (connection.c:974) 5 TCC 0x00000001e78bb0c0 tccd_send_message + 940 (TCC.c:490) 6 TCC 0x00000001e78c0e08 __TCCAccessRequest_block_invoke.213 + 876 (TCC.c:591) 7 libdispatch.dylib 0x0000000180176660 _dispatch_client_callout + 20 (object.m:560) 8 libdispatch.dylib 0x00000001801858b4 _dispatch_lane_barrier_sync_invoke_and_complete + 56 (queue.c:1016) 9 libsystem_trace.dylib 0x000000019ac86668 _os_activity_initiate_impl + 64 (activity.c:131) 10 TCC 0x00000001e78bc4e0 TCCAccessRequest + 476 (TCC.c:1019) 11 TCC 0x00000001e78ba8b8 TCCAccessRestricted + 228 (TCC.c:1682) 12 ContactsFoundation 0x000000018ce4a6ec -[CNTCCVersion2 isAuthorizationRestricted] + 96 (CNTCCVersion2.m:79) 13 ContactsFoundation 0x000000018ce034a4 -[CNAuthorizationContext isAccessRestricted] + 52 (CNAuthorizationContext.m:90) 14 Contacts 0x0000000185c42b04 +[CNAuthorization isAccessRestrictedForEntityType:] + 72 (CNAuthorization.m:26) 15 Contacts 0x0000000185c5ba30 +[CNAuthorization authorizationStatusForEntityType:] + 40 (CNAuthorization.m:66) 16 ios_app 0x00000001024bc724 -[MainAppDelegate askUserToAccessContacts] + 84 (MainAppDelegate.m:1338) 17 ios_app 0x00000001024b61b8 -[MainAppDelegate application:didFinishLaunchingWithOptions:] + 1520 (MainAppDelegate.m:228) log.crash
Posted
by mohamed.t.
Last updated
.
Post not yet marked as solved
0 Replies
390 Views
Hi,Currently I cannot clear a local notification in app (example: A reminder) which i scheduled from Notification Service Extension (NSE).i've tired clearing using the following APIs,NSArray *ids = @[@"Notify_from_app",@"Notify_from_extension"]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center removeAllDeliveredNotifications]; [center removePendingNotificationRequestsWithIdentifiers:ids];The above code works fine, when i try to clear a notification in NSE, which is scheduled from the same NSE. (if i try to clear from app, i can't)FYI, i'm able to clear all the notifications using the following code. (but my goal is to clear the notification using identifiers, a specific notification)UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center removeAllDeliveredNotifications]; [center removeAllPendingNotificationRequests];As per apple's documentation, the currentNotficationCenter object supports app extensions as well, that's why I'm able to schedule a local notifications from there.May be the currentNotificationCenter object for the app is not equal to the currentNotificationCenter object of NSE.This makes more sense because both have a separate container. (That's why we are not able to directly access the app's container from NSE.)Can i make a copy of the object in coredata and retrieve it in app to clear the notification?This dosen't feel like a good practice.I'm looking for a proper solution to clear the reminders, Please help me out.
Posted
by mohamed.t.
Last updated
.