Traduciendo cacao a toque de cacao -

I've been working on the SNRLastFMEngine over the past couple of hours, making it iOS friendly but have come to a standstill. My problem is in one single function that appears to use functions only available in cocoa applications for Mac OS.

The function is below:

- (void)_registerCustomURLSchemeHandler
    // Register for Apple Events
    NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
    [em setEventHandler:self andSelector:@selector(getURL:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
    // Set Sonora as the default handler
    NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
    LSSetDefaultHandlerForURLScheme((CFStringRef)kCustomURLScheme, (CFStringRef)bundleID);

dónde kCustomURLScheme is pre-defined NSString

which is then handled by a function: - (void)getURL:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent

I thought about adding an NSNotification observer to handle the event, but haven't had any luck (it doesn't recognise the event class or event ID, and I'm don't know what to do to account for LSSetDefaultHandlerForURLScheme). I don't have any experience with Mac OS applications and I'm sure that I am missing the bigger picture. I'd very much appreciate help/guidance from anyone with knowledge of both languages.

preguntado el 09 de marzo de 12 a las 16:03

1 Respuestas

In iOS, You can't register a URL scheme with the system dynamically at runtime.

You tell the iOS that your app can handle a URL scheme by listing it in your Info.plist file with the CFBundleURLTypes property. (Which may appear in the Xcode display of the file as "URL Types").

This does mean your list of supported schemes is pre-declared when you ship your app and it can't change unless you submit a newer version of the app. Attempting to change the Info.plist file won't work as it would break the signature of the file and iOS would refuse to run it.

respondido 10 mar '12, 16:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.