1

Ive been trying to figure this out now for over a week and for some reason, no matter what i do, the newsstand icon is not updating via code.

I have read through the Apple developer documentation and tripple checked my image dimensions and they are all correct. I even went and created a new class just for updating the newsstand icon.

Anyway, here is my code:

#import "NewsstandIcon.h"
#import <NewsstandKit/NewsstandKit.h>
@implementation NewsstandIcon

-(void)setIcon:(NSString *)withURL
{
    // TEMPORARY OVERRIDE
    withURL = @"http://www.imgtag.me/735x1024";

    _downloadedData = [[NSMutableData alloc] init];
    [_downloadedData setLength: 0];

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:withURL]];
    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    NSLog(@"[ICON DOWNLOAD] Starting download");
}

// DOWNLOAD METHODS
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response {
    if ([response statusCode] == 404)
    {
        NSLog(@"[ICON DOWNLOAD] Failed - Error 404 - File not found");
        [connection cancel];
    }
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    NSLog(@"[ICON DOWNLOAD] Received Data");
    [_downloadedData appendData:data];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    NSLog(@"[ICON DOWNLOAD] Completed. Length %d", [_downloadedData length]);
    [[UIApplication sharedApplication] setNewsstandIconImage: [[UIImage alloc] initWithData: _downloadedData]];

    NSLog(@"[ICON DOWNLOAD] Setting Icon");
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    NSLog(@"[ICON DOWNLOAD] Failed - %@", [error description]);
}
@end

And this outputs:

2014-03-08 16:53:24.308 magazine[3590:70b] [ICON DOWNLOAD] Received Data
2014-03-08 16:53:24.308 magazine[3590:70b] [ICON DOWNLOAD] Completed. Length 12833
2014-03-08 16:53:25.892 magazine[3590:70b] [ICON DOWNLOAD] Setting Icon

I also had the downloaded image write to the local file system. I then browsed to the file and the image was fully intact and readable.

As you can see in the code, i have temporarily overwritten the withURL parameter of the setIcon method. I have tried this with many images and none of them work. You can see the file size in my output.

When i call setNewsstandIcon i get no warnings in my output and the icon just stays as the default icon.

Any help would be greatly appreciated!

Thanks.

David
  • 11
  • 1

1 Answers1

0

If your icon doesn't follow the specifications it will result in a nil icon. take a look at this: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/NewsstandIcons.html#//apple_ref/doc/uid/TP40006556-CH28-SW1

note: remember to set a uiimage with scale 2 for retina

user2387149
  • 1,219
  • 16
  • 28