Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternate Icon in iOS 10.3: avoid notification dialog for icon change

Tags:

ios

ios10.3

I'm using this new feature and when the change is made with an active application, a notification dialog is displayed saying that icon has been modified. How to disable this dialog ?

like image 923
fvisticot Avatar asked Apr 11 '17 21:04

fvisticot


People also ask

How do you change the one second everyday app icon?

To find it, scroll up until you see Today and keep scrolling up in a Journal project until the icons' screen shows up. From there, you can select any icon that's available to you. The more snippets you add, the more icons you'll unlock!

How do I manually change app icons?

To change an icon to one you downloaded, tap and hold an empty area of the screen again, select Themes, tap Icons, tap the menu, and then select My Stuff. Choose Icons, select the icons you want to use, and tap Apply.


1 Answers

If you don't mind making use of private method, you can try the following code.

- (void)lc_setAlternateIconName:(NSString*)iconName
{
    //anti apple private method call analyse
    if ([[UIApplication sharedApplication] respondsToSelector:@selector(supportsAlternateIcons)] && 
        [[UIApplication sharedApplication] supportsAlternateIcons])
    {
        NSMutableString *selectorString = [[NSMutableString alloc] initWithCapacity:40];
        [selectorString appendString:@"_setAlternate"];
        [selectorString appendString:@"IconName:"];
        [selectorString appendString:@"completionHandler:"];

        SEL selector = NSSelectorFromString(selectorString);
        IMP imp = [[UIApplication sharedApplication] methodForSelector:selector];
        void (*func)(id, SEL, id, id) = (void *)imp;
        if (func)
        {
            func([UIApplication sharedApplication], selector, iconName, ^(NSError * _Nullable error) {});
        }
    }
}
like image 153
Robert Avatar answered Oct 17 '22 14:10

Robert