Skip to content

Commit

Permalink
[TIMOB-26655] fix(ios): fix application shortcuts parity (#10539)
Browse files Browse the repository at this point in the history
* fix(ios): properly remove dynamic shortcuts

* fix(ios): use itemtype for shortcuts
  • Loading branch information
hansemannn authored and lokeshchdhry committed Jan 23, 2019
1 parent 7589752 commit bd46b84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 0 additions & 4 deletions iphone/Classes/TiAppiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,7 @@ - (void)didReceiveApplicationShortcutNotification:(NSNotification *)info
{
NSMutableDictionary *event = [[NSMutableDictionary alloc] initWithDictionary:@{
@"title" : [[info userInfo] valueForKey:@"title"],
#ifdef USE_TI_UIAPPLICATIONSHORTCUTS
@"identifier" : [[info userInfo] valueForKey:@"type"]
#else
@"itemtype" : [[info userInfo] valueForKey:@"type"]
#endif
}];

if ([[info userInfo] valueForKey:@"subtitle"] != nil) {
Expand Down
12 changes: 7 additions & 5 deletions iphone/Classes/TiUIApplicationShortcutsProxy.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2018 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2018-present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -142,13 +142,15 @@ - (void)removeDynamicShortcut:(id)identifier
}

NSMutableArray *shortcuts = (NSMutableArray *)[UIApplication sharedApplication].shortcutItems;
NSMutableIndexSet *shortcutsIndicesToDelete = [[NSMutableIndexSet alloc] init];

for (UIApplicationShortcutItem *item in shortcuts) {
if ([item.type isEqualToString:key]) {
[shortcuts removeObject:item];
[shortcuts enumerateObjectsUsingBlock:^(UIApplicationShortcutItem *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) {
if ([obj.type isEqualToString:key]) {
[shortcutsIndicesToDelete addIndex:idx];
}
}
}];

[shortcuts removeObjectsAtIndexes:shortcutsIndicesToDelete];
[UIApplication sharedApplication].shortcutItems = shortcuts;
}

Expand Down
12 changes: 7 additions & 5 deletions iphone/Classes/TiUIiOSApplicationShortcutsProxy.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2015-2018 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2015-present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -142,13 +142,15 @@ - (void)removeDynamicShortcut:(id)itemtype
}

NSMutableArray *shortcuts = (NSMutableArray *)[UIApplication sharedApplication].shortcutItems;
NSMutableIndexSet *shortcutsIndicesToDelete = [[NSMutableIndexSet alloc] init];

for (UIApplicationShortcutItem *item in shortcuts) {
if ([item.type isEqualToString:key]) {
[shortcuts removeObject:item];
[shortcuts enumerateObjectsUsingBlock:^(UIApplicationShortcutItem *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) {
if ([obj.type isEqualToString:key]) {
[shortcutsIndicesToDelete addIndex:idx];
}
}
}];

[shortcuts removeObjectsAtIndexes:shortcutsIndicesToDelete];
[UIApplication sharedApplication].shortcutItems = shortcuts;
}

Expand Down

0 comments on commit bd46b84

Please sign in to comment.