When I call startMonitoringLocationPushesWithCompletion, the completion "callback" is never executed.
This is what we have done to prepare for this service:
- We have the
com.apple.developer.location.pushin the entitlements file - Our request to use the location push service has been approved
- We have enabled
Location Push Service ExtensioninCertificates, Identifiers & Profilesof our app ondeveloper.apple.com - We have the push notification and location update capabilities
- The user has granted the app "Always" location access
- We have these purpose strings in our
info.plistalready:NSLocationAlwaysAndWhenInUseUsageDescription,NSLocationAlwaysUsageDescriptionandNSLocationWhenInUseUsageDescription - We have the automatically generated location push service extension
Here is the code that we use to test the service:
#import <React/RCTLog.h>
#import <CoreLocation/CoreLocation.h>
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (@available(iOS 15.0, *)) {
RCTLogInfo(@"Starting monitoring location pushes");
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager startMonitoringLocationPushesWithCompletion:^(NSData * _Nullable token, NSError * _Nullable error) {
RCTLogInfo(@"Completion called");
if (token) {
NSString *tokenString = [NSString stringWithFormat:@"%@", token];
RCTLogInfo(@"Token: %@", tokenString);
}
if (error){
RCTLogError(@"Error: %@", error);
}
RCTLogInfo(@"Completion ends %@ %@", token, error);
}];
RCTLogInfo(@"End monitoring location pushes");
} else {
RCTLogError(@"Incompatible iOS version");
}
return YES;
}
The only logs:
2022-03-29 18:38:02.736615+0100 ***[yyy] [native] Starting monitoring location pushes
2022-03-29 18:38:02.738087+0100 ***[yyy] [native] End monitoring location pushes