I'm pass the userInfo NSDictionary thusly:
[[WKExtension sharedExtension] scheduleBackgroundRefreshWithPreferredDate:[NSDate dateWithTimeIntervalSinceNow:10]
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"timer", @"reason", nil]
scheduledCompletion:^(NSError * _Nullable error) { ... }
But, when the task is received in, task.userInfo is nil:
- (void)handleBackgroundTasks:(NSSet<WKRefreshBackgroundTask *> *)backgroundTasks {
for (WKRefreshBackgroundTask * task in backgroundTasks) {
WKApplicationRefreshBackgroundTask *backgroundTask = (WKApplicationRefreshBackgroundTask*)task;
if (task.userInfo) {
NSDictionary *userInfo = (NSDictionary *)task.userInfo;
NSString *reason = [userInfo objectForKey:@"reason"];
NSLog(@"reason: %@", reason);
} else {
NSLog(@"no userInfo %@", task.debugDescription);
}
What am I missing here?
Thx, Pete