Skip to content

Commit

Permalink
fix: callback argument and correct background task handling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
markneh committed Nov 14, 2020
1 parent fb47d87 commit 796a5c5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ios/RNESimManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ @implementation RNESimManager
request.matchingID = config[@"matchingId"];
request.confirmationCode = config[@"confirmationCode"];

__block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[plan addPlanWith:request
completionHandler:^(CTCellularPlanProvisioningAddPlanResult result) {
resolve(@(CTCellularPlanProvisioningAddPlanResultFail));
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier];
}];
// The user may send your app to the background prior to finishing the eSIM installation. To ensure your app has an opportunity to execute the completion handler and get the installation result, perform the eSIM installation as a background task. To do so, call beginBackgroundTask(expirationHandler:) prior to calling addPlan(with:completionHandler:), then call endBackgroundTask(_:) inside the completion handler.
UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}];

[plan addPlanWith:request completionHandler:^(CTCellularPlanProvisioningAddPlanResult result) {
resolve(@(result));
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier];
}];
}

Expand Down

0 comments on commit 796a5c5

Please sign in to comment.