Posts

Post not yet marked as solved
4 Replies
3.5k Views
Hi, I'm trying to test the new BackgroundTasks framework.* Xcode 11.0 beta 3* On the simulator, the submit task raises an error* On my iPhone 7 beta 2, task doesn't be triggeredHere is the steps :- I checked the "Background Processing" check box in capabilities- I added com.example.refresh in the Info.plist<key>BGTaskSchedulerPermittedIdentifiers</key> <array> <string>com.example.refresh</string> </array>- I put the following code in the application didFinishLaunchingWithOptions :// Background tasks testing if (@available(iOS 13.0, *)) { [[BGTaskScheduler sharedScheduler] registerForTaskWithIdentifier:@"com.example.refresh" usingQueue:nil launchHandler:^(__kindof BGTask * _Nonnull task) { UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = [NSDate date]; notification.alertBody = @"YEAH"; [[UIApplication sharedApplication] presentLocalNotificationNow:notification]; [task setTaskCompletedWithSuccess:YES]; }]; [[BGTaskScheduler sharedScheduler] cancelAllTaskRequests]; BGProcessingTaskRequest *bgTaskRequest = [[BGProcessingTaskRequest alloc] initWithIdentifier:@"com.example.refresh"]; NSDate *d = [NSDate date]; int nbMin = 5; [bgTaskRequest setEarliestBeginDate:[d dateByAddingTimeInterval:(nbMin*60)]]; [bgTaskRequest setRequiresNetworkConnectivity:NO]; [bgTaskRequest setRequiresExternalPower:NO]; NSError *e; [[BGTaskScheduler sharedScheduler] submitTaskRequest:bgTaskRequest error:&e]; NSLog(@"ERROR TASK : %@", e); NSLog(@"Task planified at %@", [d dateByAddingTimeInterval:(nbMin*60)]); } else { // Fallback on earlier versions }The notification is never triggered.
Posted
by blobbby.
Last updated
.
Post not yet marked as solved
0 Replies
646 Views
Hello,My app is using background location (not significant, I mean startUpdatingLocation).When the user kill the application (swipe up app in multitask os) or the phone reboot, the app does not restart.In iOS 12 when the user moves enough, the app restarts and run again in background.In iOS 13, the system doesn't deliver location update until the app is restarted manually.Unforeseen aspect, going into Sytem settings / Confidentiality / Turn off global location and switch it back on will deliver location update even on iOS 13.Is this behaviour desired by Apple ?
Posted
by blobbby.
Last updated
.