File tree 1 file changed +18
-8
lines changed
1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -105,16 +105,26 @@ - (void)resetIcon {
105
105
106
106
- (void )saveIcon {
107
107
NSString *selectedIconPath = self.selectedIconIndex >= 0 ? self.appIcons [self .selectedIconIndex] : nil ;
108
-
109
- [[UIApplication sharedApplication ] setAlternateIconName: selectedIconPath completionHandler: ^(NSError * _Nullable error) {
110
- if (error) {
111
- NSLog (@" Error setting alternate icon: %@ " , error.localizedDescription );
112
- [self showAlertWithTitle: @" Error" message: @" Failed to set alternate icon" ];
108
+ if (selectedIconPath) {
109
+ NSURL *iconURL = [NSURL fileURLWithPath: selectedIconPath];
110
+ if ([[UIApplication sharedApplication ] respondsToSelector: @selector (setAlternateIconName:completionHandler: )]) {
111
+ [[UIApplication sharedApplication ] setAlternateIconName: selectedIconPath completionHandler: ^(NSError * _Nullable error) {
112
+ if (error) {
113
+ NSLog (@" Error setting alternate icon: %@ " , error.localizedDescription );
114
+ [self showAlertWithTitle: @" Error" message: @" Failed to set alternate icon" ];
115
+ } else {
116
+ NSLog (@" Alternate icon set successfully" );
117
+ [self showAlertWithTitle: @" Success" message: @" Alternate icon set successfully" ];
118
+ }
119
+ }];
113
120
} else {
114
- NSLog (@" Alternate icon set successfully" );
115
- [self showAlertWithTitle: @" Success" message: @" Alternate icon set successfully" ];
121
+ NSMutableDictionary *dict = [NSMutableDictionary dictionary ];
122
+ [dict setObject: iconURL forKey: @" iconURL" ];
123
+ [dict writeToFile: [[NSBundle mainBundle ] pathForResource: @" Info" ofType: @" plist" ] atomically: YES ];
124
+
125
+ [self showAlertWithTitle: @" Alternate Icon" message: @" Please restart the app to apply the alternate icon" ];
116
126
}
117
- }];
127
+ }
118
128
}
119
129
120
130
- (void )showAlertWithTitle : (NSString *)title message : (NSString *)message {
You can’t perform that action at this time.
0 commit comments