iOS 10.3 - How to change app icon programmatically
Yes, iOS 10.3 finally gives developers the ability to change their app’s icon programmatically.
It is possible to change appIcon from iOS 10.3. For that you need to set supportsAlternateIcon
to Yes
in info.plist
.
Both primary and secondary icons should be added in CFBundleIcons
key of your app's Info.plist
file.
//Info.plist
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>Icon1</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>alternater1</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>Icon2</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>alternater2</string>
</array>
</dict>
</dict>
</dict>
To change App Icon following UIApplication method needs to be called:
Objective C:
[[UIApplication sharedApplication] setAlternateIconName:@"alternater2" completionHandler:^(NSError * _Nullable error) {
NSLog(@"Error...");
}];
Swift 3:
if UIApplication.shared.supportsAlternateIcons{
UIApplication.shared.setAlternateIconName("alternater2", completionHandler: { (error) in
print(error ?? "")
})
}
For more detailed tutorial, See:
Apple Document: setAlternateIconName(_:completionHandler:)
How to change your app icon dynamically with setAlternateIconName()
Can I change app icon programmatically
No, the icon is specified in the application bundle, which you must not change. If you change it, your app signature will become invalid (not the same checksum) and thus your app won't run anymore.
Dynamically alter App Icon on iOS and Android
https://medium.com/flutter-community/programatically-change-ios-app-icon-in-flutter-c9e84bc541a2
Maybe this would help. Here's a plugin too.
https://pub.dev/packages/flutter_dynamic_icon
Related Topics
iOS Uiimagepickercontroller: Any Way of Getting the Date of the Chosen Picture
Dynamically Passing Closure with Keypaths to a Sorting Function
Modeling Sub-Collections in Mongodb Realm Sync
Game Exits from Pause State After Resuming It from Background in Swift
Create Alert Function in All View Controllers - Swift
Storyboard Localization in Swift 4.0
Saving an Image to Photos Library Using Swift 2.0
Making the Map Zoom to User Location and Annotation (Swift 2)
Fbsdk (New Facebook Sdk 4.0) Implementation Is Not Working for Login with Facebook
How to Create an Alert in a Swift File Model That Works for Various View Controller
Audio Information of Current Track iOS Swift
Modifing One Variable from Another View Controller Swift
Impelementation of Rtcdatachannel of Webrtc in iOS
A Simple Code to Detect Any Beacon in Swift