Skip to content

Commit

Permalink
fix(ios): properly map user activity for cold starts
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn authored and ewanharris committed Aug 5, 2021
1 parent eb72b73 commit f0ee118
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,36 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
UILocalNotification *_localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
NSNumber *launchedLocation = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey];
UIApplicationShortcutItem *shortcut = [launchOptions objectForKey:UIApplicationLaunchOptionsShortcutItemKey];
NSDictionary *userActivityDictionary = launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];

// Map user activity if exists
if (userActivityDictionary != nil) {
NSUserActivity *userActivity = userActivityDictionary[@"UIApplicationLaunchOptionsUserActivityKey"];

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{ @"activityType" : [userActivity activityType] }];

if ([TiUtils isIOSVersionOrGreater:@"9.0"] && [[userActivity activityType] isEqualToString:CSSearchableItemActionType]) {
if ([userActivity userInfo] != nil) {
[dict setObject:[[userActivity userInfo] objectForKey:CSSearchableItemActivityIdentifier] forKey:@"searchableItemActivityIdentifier"];
}
}

if ([userActivity title] != nil) {
[dict setObject:[userActivity title] forKey:@"title"];
}

if ([userActivity webpageURL] != nil) {
[dict setObject:[[userActivity webpageURL] absoluteString] forKey:@"webpageURL"];
}

if ([userActivity userInfo] != nil) {
[dict setObject:[userActivity userInfo] forKey:@"userInfo"];
}

// Update launchOptions so that we send only expected values rather than NSUserActivity
[launchOptions setObject:@{ @"UIApplicationLaunchOptionsUserActivityKey": dict }
forKey:UIApplicationLaunchOptionsUserActivityDictionaryKey];
}

// Map background location key
if (launchedLocation != nil) {
Expand Down

0 comments on commit f0ee118

Please sign in to comment.