iosobjective-curl-schemeibooks

Open a book in iBooks reader


I'm trying to open an iBook via my iPhone app using this code :

- (void)goToiBookStore {
    NSURL *url = [NSURL URLWithString:@"itms-books://itunes.apple.com/us/book/le-secret-du-poids/id711921224"];
    //NSURL *url = [NSURL URLWithString:@"itms-bookss://itunes.apple.com/us/book/le-secret-du-poids/id711921224"]; // Also tried
    //NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/book/le-secret-du-poids/id711921224?l=fr&ls=1"]; // Also tried

    // On teste si iBook installed
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        [[UIApplication sharedApplication] openURL:url];
    }
    else {
        [[[UIAlertView alloc] initWithTitle:@"iBooks" message:NSLocalizedString(@"installer ibooks lab", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"annuler", nil) otherButtonTitles:NSLocalizedString(@"installer", nil), nil] show];
    }
}

But, the URL does not send me to the iBook in iBooks but to the download page, is it normal ?

http://img4.hostingpics.net/thumbs/mini_953506photo.png


Solution

  • You can open iBooks, or open the store for that product, but not open a book directly.

    If you want to open iBooks:

    NSString *stringURL = @"ibooks://";
    NSURL *url = [NSURL URLWithString:stringURL];
    [[UIApplication sharedApplication] openURL:url];
    

    UPDATE 2019: You can open iBooks to a specific book now by including the assetid of the book you want to open. Example:

    ibooks://assetid/1396541327
    

    Details available on the Apple.com website - https://support.apple.com/en-us/HT202929