My question is also same that others asked before.
I found that once you set the Icon for the Application we can't change the Application icon dynamically. Yes I agreed. If so we used Dynamic icons Apple Don't accept. But I accept there is some rules and regulation in apple.
So Here is my question : How to change the app icon dynamically. I am not going to put my Application in AppStore.
Everybody is telling it is not possible. I am not worrying about apples Rules. But yeh, worrying about the answer.
Anybody, Just guide me to Do this and don't tell me 'You Cant'.
Thanks in Advance.
Tap on the icon under Home Screen Name and Icon. You'll have the choice of either taking a photo, choosing a photo, or choosing a file. Assuming you've already saved an image in Photo, tap on Choose Photo and select the photo you want to use.
In the Shortcuts app on your iOS or iPadOS device, tap on the shortcut you want to modify. Tap the Icon next to the shortcut name, then do any of the following: Change the shortcut's color: Tap a color swatch. Change the shortcut's glyph (icon): Tap an icon.
Use the i button to open the menu, then tap Add to Home Screen. Tap the app icon and use the popup menu to select the custom icon you want to use from the Files or Photos app on your iPhone. Name your shortcut after the app, then tap Add to add it to your Home screen.
There is a method called setAlternateIconName: which is introduced in iOS 10.3, through which you can change the app's icon, however these icons should be predefined. It means that the icons should be added to the app's bundle and referenced in the info.plist
.
A typical info.plist looks like:
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>alternate_icon_name</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>alternate_icon_file</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>default_icon_file</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
</dict>
Implement the code like:
Objective C:
[[UIApplication sharedApplication] setAlternateIconName:@"alternate_icon_name" completionHandler:^(NSError * _Nullable error) {
NSLog(@"Error...");
}];
Swift 3:
if UIApplication.shared.supportsAlternateIcons
{
UIApplication.shared.setAlternateIconName("alternate_icon_name", completionHandler: { (error) in
print(error ?? "")
})
}
You cannot change the icon file dynamically, because the icon file name is stored on the application plist.
.
You cannot change the application plist dynamically, because it is stored on the application bundle which is readonly.
So your requirement is not possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With