I have the same issue with IOS 15.4.1!! any update on this
Post
Replies
Boosts
Views
Activity
I found the solution
you need to move
API_AVAILABLE(ios(12.0))
CTCellularPlanProvisioning *plan;
API_AVAILABLE(ios(12.0))
CTCellularPlanProvisioningRequest *request;
at class level
API_AVAILABLE(ios(12.0))
CTCellularPlanProvisioning *plan;
API_AVAILABLE(ios(12.0))
CTCellularPlanProvisioningRequest *request;
RCT_EXPORT_METHOD(setupEsim:(NSDictionary *)config
promiseWithResolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
if (@available(iOS 12.0, *)) {
plan = [[CTCellularPlanProvisioning alloc] init];
if (plan.supportsCellularPlan == NO) {
NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:2 userInfo:nil];
reject(@"1", @"The device doesn't support a cellular plan", error);
} else {
NSArray *arrayOfComponents = [config[@"confirmationCode"] componentsSeparatedByString:@"$"];
request = [[CTCellularPlanProvisioningRequest alloc] init];
request.OID = config[@"oid"];
request.EID = config[@"eid"];
request.ICCID = config[@"iccid"];
request.address = arrayOfComponents[1];
request.matchingID = arrayOfComponents[2];
request.confirmationCode = config[@"confirmationCode"];
UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}];
[plan addPlanWith:request completionHandler:^(CTCellularPlanProvisioningAddPlanResult result) {
if (result==CTCellularPlanProvisioningAddPlanResultFail){
NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:1 userInfo:nil];
reject(@"2", @"CTCellularPlanProvisioningAddPlanResultFail - Can't add an Esim subscription", error);
}else if (result==CTCellularPlanProvisioningAddPlanResultUnknown){
NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:1 userInfo:nil];
reject(@"3", @"CTCellularPlanProvisioningAddPlanResultUnknown - Can't setup eSim due to unknown error", error);
}else{
//CTCellularPlanProvisioningAddPlanResultSuccess
resolve(@(true));
}
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier];
}];
}
} else {
NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:1 userInfo:nil];
reject(@"0", @"This functionality is not supported before iOS 12.0", error);
}
}