How to Get the Current Application Icon in iOS

How to get the current application icon in ios

Works for Swift 4.1 and extending it for Bundle.

extension Bundle {
public var icon: UIImage? {
if let icons = infoDictionary?["CFBundleIcons"] as? [String: Any],
let primaryIcon = icons["CFBundlePrimaryIcon"] as? [String: Any],
let iconFiles = primaryIcon["CFBundleIconFiles"] as? [String],
let lastIcon = iconFiles.last {
return UIImage(named: lastIcon)
}
return nil
}
}

To use in an app, call Bundle.main.icon.

How to get IOS current alternate icon name?

Get the name of the icon being displayed for the app

If you want to know which icon is being displayed, just read alternateIconName on UIApplication shared instance:

let currentIcon = UIApplication.shared.alternateIconName

How to get UIImage of AppIcon?

The problem is that the AppIcon from the asset catalog is not placed in the the catalog after compiling. Instated it it copied into your apps bundle, just like before.

The name conversion used when copying the icon to the app bundle is AppIcon<size>.png, where the size is for example 40x40 or 72x72

You can get your apps icons by specifying the size of the app icon you want:

UIImage *appIcon = [UIImage imageNamed:@"AppIcon40x40"];

iOS get app icon from app name

Yes, you need to check out the iTunes API.

Check out their example on Yelp:

https://itunes.apple.com/search?term=yelp&country=us&entity=software

The artwork images are found in two sizes under the keys artworkUrl60 & artworkUrl512.

Get other application icon image in my Application

apple has an JSON Service for that, where you get a lot of meta data for every application

This is the URL for the Facebook App
http://itunes.apple.com/lookup?id=284882215

and this a the URL for the Facebook and Twitter App combined:
http://itunes.apple.com/lookup?id=284882215,333903271

in the JSON you will find URLs of the app icons in attributes artworkUrl60, artworkUrl512 and artworkUrl100

"artworkUrl100":"http://a1170.phobos.apple.com/us/r30/Purple4/v4/37/7e/9e/377e9e31-388e-8d10-e414-f478a2f18d29/mzl.pacepjmm.png"

unfortunately those app icons are squared and don't have the rounded corners, you will get app icon how the developer uploaded it.

UPDATE: get data for other countries

if you want to get the data for different countries you can just add the country code in between e.g.

  • for Germany: http://itunes.apple.com/de/lookup?id=284882215
  • for France: http://itunes.apple.com/fr/lookup?id=284882215

Xcode 10 app icon not showing

On 6/19/18 Apple released Xcode 10. beta 2. Upgrading solved the problem I was having with icons not appearing. So, a bug in Xcode 10.0 I guess.



Related Topics



Leave a reply



Submit