Given an IOS Bundle ID how do I display the corresponding App Icon










3















App Icon List Comparison



I am storing information about meal timing in Apple's Health App/DB. When I review Apples Health App for meal information (top screen in the image) the source App Icon is included in the list.



When I attempt to do the same in my App (Bottom Screen in the image) it works fine for my Apps BundleID but I cannot retrieve the App Icon from the Health App supplied BundleID for an alternate source App. I am using the code shown below to try to achieve this. I am not sure what I am doing wrong, perhaps the wrong approach, perhaps missing some setup calls (like opening the Bundle before use). I have seen this used in third-party fitness/nutrition apps so there must be some way for doing this. I would appreciate any help or redirection of my effort. Thanks in advance.



func getAppIcon(_ theBundleID: String) -> UIImage 
guard let iconsDictionary = Bundle.init(identifier: theBundleID)!.infoDictionary?["CFBundleIcons"] as? NSDictionary,
let primaryIconsDictionary = iconsDictionary["CFBundlePrimaryIcon"] as? NSDictionary,
let iconFiles = primaryIconsDictionary["CFBundleIconFiles"] as? [String],
// First will be smallest for the device class, last will be the largest for device class
let firstIcon = iconFiles.first,
let icon = UIImage(named: firstIcon as String) else
return UIImage()

return icon










share|improve this question

















  • 1





    You can't access data outside of your app sandbox. The best you can do is add icons into your app bundle for popular/well-known apps or display a generic icon for other apps.

    – Paulw11
    Nov 15 '18 at 7:07






  • 1





    Be careful. Showing an Apple app icon in your interface can get you thrown off the App Store.

    – matt
    Nov 15 '18 at 7:21











  • @Paulw11 Hey Paul, thanks for your swift (excuse the pun) responses. You are, depressingly, probably right. I have found other responses here in SO that indicate pretty much the same thing. I have tried to find the other apps that I was thinking of that were able to do this and could only locate the Apple health app and they obviously have access that mere mortals do not. Anyway, I will keep poking around a while longer and report back here if I find anything more positive.

    – FatKC
    Nov 16 '18 at 3:31











  • @matt Hi Matt, thanks for the warning!

    – FatKC
    Nov 16 '18 at 3:32















3















App Icon List Comparison



I am storing information about meal timing in Apple's Health App/DB. When I review Apples Health App for meal information (top screen in the image) the source App Icon is included in the list.



When I attempt to do the same in my App (Bottom Screen in the image) it works fine for my Apps BundleID but I cannot retrieve the App Icon from the Health App supplied BundleID for an alternate source App. I am using the code shown below to try to achieve this. I am not sure what I am doing wrong, perhaps the wrong approach, perhaps missing some setup calls (like opening the Bundle before use). I have seen this used in third-party fitness/nutrition apps so there must be some way for doing this. I would appreciate any help or redirection of my effort. Thanks in advance.



func getAppIcon(_ theBundleID: String) -> UIImage 
guard let iconsDictionary = Bundle.init(identifier: theBundleID)!.infoDictionary?["CFBundleIcons"] as? NSDictionary,
let primaryIconsDictionary = iconsDictionary["CFBundlePrimaryIcon"] as? NSDictionary,
let iconFiles = primaryIconsDictionary["CFBundleIconFiles"] as? [String],
// First will be smallest for the device class, last will be the largest for device class
let firstIcon = iconFiles.first,
let icon = UIImage(named: firstIcon as String) else
return UIImage()

return icon










share|improve this question

















  • 1





    You can't access data outside of your app sandbox. The best you can do is add icons into your app bundle for popular/well-known apps or display a generic icon for other apps.

    – Paulw11
    Nov 15 '18 at 7:07






  • 1





    Be careful. Showing an Apple app icon in your interface can get you thrown off the App Store.

    – matt
    Nov 15 '18 at 7:21











  • @Paulw11 Hey Paul, thanks for your swift (excuse the pun) responses. You are, depressingly, probably right. I have found other responses here in SO that indicate pretty much the same thing. I have tried to find the other apps that I was thinking of that were able to do this and could only locate the Apple health app and they obviously have access that mere mortals do not. Anyway, I will keep poking around a while longer and report back here if I find anything more positive.

    – FatKC
    Nov 16 '18 at 3:31











  • @matt Hi Matt, thanks for the warning!

    – FatKC
    Nov 16 '18 at 3:32













3












3








3








App Icon List Comparison



I am storing information about meal timing in Apple's Health App/DB. When I review Apples Health App for meal information (top screen in the image) the source App Icon is included in the list.



When I attempt to do the same in my App (Bottom Screen in the image) it works fine for my Apps BundleID but I cannot retrieve the App Icon from the Health App supplied BundleID for an alternate source App. I am using the code shown below to try to achieve this. I am not sure what I am doing wrong, perhaps the wrong approach, perhaps missing some setup calls (like opening the Bundle before use). I have seen this used in third-party fitness/nutrition apps so there must be some way for doing this. I would appreciate any help or redirection of my effort. Thanks in advance.



func getAppIcon(_ theBundleID: String) -> UIImage 
guard let iconsDictionary = Bundle.init(identifier: theBundleID)!.infoDictionary?["CFBundleIcons"] as? NSDictionary,
let primaryIconsDictionary = iconsDictionary["CFBundlePrimaryIcon"] as? NSDictionary,
let iconFiles = primaryIconsDictionary["CFBundleIconFiles"] as? [String],
// First will be smallest for the device class, last will be the largest for device class
let firstIcon = iconFiles.first,
let icon = UIImage(named: firstIcon as String) else
return UIImage()

return icon










share|improve this question














App Icon List Comparison



I am storing information about meal timing in Apple's Health App/DB. When I review Apples Health App for meal information (top screen in the image) the source App Icon is included in the list.



When I attempt to do the same in my App (Bottom Screen in the image) it works fine for my Apps BundleID but I cannot retrieve the App Icon from the Health App supplied BundleID for an alternate source App. I am using the code shown below to try to achieve this. I am not sure what I am doing wrong, perhaps the wrong approach, perhaps missing some setup calls (like opening the Bundle before use). I have seen this used in third-party fitness/nutrition apps so there must be some way for doing this. I would appreciate any help or redirection of my effort. Thanks in advance.



func getAppIcon(_ theBundleID: String) -> UIImage 
guard let iconsDictionary = Bundle.init(identifier: theBundleID)!.infoDictionary?["CFBundleIcons"] as? NSDictionary,
let primaryIconsDictionary = iconsDictionary["CFBundlePrimaryIcon"] as? NSDictionary,
let iconFiles = primaryIconsDictionary["CFBundleIconFiles"] as? [String],
// First will be smallest for the device class, last will be the largest for device class
let firstIcon = iconFiles.first,
let icon = UIImage(named: firstIcon as String) else
return UIImage()

return icon







ios swift






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 6:59









FatKCFatKC

265




265







  • 1





    You can't access data outside of your app sandbox. The best you can do is add icons into your app bundle for popular/well-known apps or display a generic icon for other apps.

    – Paulw11
    Nov 15 '18 at 7:07






  • 1





    Be careful. Showing an Apple app icon in your interface can get you thrown off the App Store.

    – matt
    Nov 15 '18 at 7:21











  • @Paulw11 Hey Paul, thanks for your swift (excuse the pun) responses. You are, depressingly, probably right. I have found other responses here in SO that indicate pretty much the same thing. I have tried to find the other apps that I was thinking of that were able to do this and could only locate the Apple health app and they obviously have access that mere mortals do not. Anyway, I will keep poking around a while longer and report back here if I find anything more positive.

    – FatKC
    Nov 16 '18 at 3:31











  • @matt Hi Matt, thanks for the warning!

    – FatKC
    Nov 16 '18 at 3:32












  • 1





    You can't access data outside of your app sandbox. The best you can do is add icons into your app bundle for popular/well-known apps or display a generic icon for other apps.

    – Paulw11
    Nov 15 '18 at 7:07






  • 1





    Be careful. Showing an Apple app icon in your interface can get you thrown off the App Store.

    – matt
    Nov 15 '18 at 7:21











  • @Paulw11 Hey Paul, thanks for your swift (excuse the pun) responses. You are, depressingly, probably right. I have found other responses here in SO that indicate pretty much the same thing. I have tried to find the other apps that I was thinking of that were able to do this and could only locate the Apple health app and they obviously have access that mere mortals do not. Anyway, I will keep poking around a while longer and report back here if I find anything more positive.

    – FatKC
    Nov 16 '18 at 3:31











  • @matt Hi Matt, thanks for the warning!

    – FatKC
    Nov 16 '18 at 3:32







1




1





You can't access data outside of your app sandbox. The best you can do is add icons into your app bundle for popular/well-known apps or display a generic icon for other apps.

– Paulw11
Nov 15 '18 at 7:07





You can't access data outside of your app sandbox. The best you can do is add icons into your app bundle for popular/well-known apps or display a generic icon for other apps.

– Paulw11
Nov 15 '18 at 7:07




1




1





Be careful. Showing an Apple app icon in your interface can get you thrown off the App Store.

– matt
Nov 15 '18 at 7:21





Be careful. Showing an Apple app icon in your interface can get you thrown off the App Store.

– matt
Nov 15 '18 at 7:21













@Paulw11 Hey Paul, thanks for your swift (excuse the pun) responses. You are, depressingly, probably right. I have found other responses here in SO that indicate pretty much the same thing. I have tried to find the other apps that I was thinking of that were able to do this and could only locate the Apple health app and they obviously have access that mere mortals do not. Anyway, I will keep poking around a while longer and report back here if I find anything more positive.

– FatKC
Nov 16 '18 at 3:31





@Paulw11 Hey Paul, thanks for your swift (excuse the pun) responses. You are, depressingly, probably right. I have found other responses here in SO that indicate pretty much the same thing. I have tried to find the other apps that I was thinking of that were able to do this and could only locate the Apple health app and they obviously have access that mere mortals do not. Anyway, I will keep poking around a while longer and report back here if I find anything more positive.

– FatKC
Nov 16 '18 at 3:31













@matt Hi Matt, thanks for the warning!

– FatKC
Nov 16 '18 at 3:32





@matt Hi Matt, thanks for the warning!

– FatKC
Nov 16 '18 at 3:32












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314001%2fgiven-an-ios-bundle-id-how-do-i-display-the-corresponding-app-icon%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314001%2fgiven-an-ios-bundle-id-how-do-i-display-the-corresponding-app-icon%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto