Given an IOS Bundle ID how do I display the corresponding App Icon
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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
add a comment |
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
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
add a comment |
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
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
ios swift
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
add a comment |
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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