Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

launch containing app from iOS8 Custom Keyboard

I want to launch my containing app.

I tried using URL schemes.

The URL scheme launched the app from other places - so the problem is not there.

Looks like this object is nil:

   self.extensionContext

thus i can't run this method:

[self.extensionContext openURL:url completionHandler:nil];

Can I launch my app? Do URL Schemes work in a custom keyboard?

thanks!

like image 428
nurnachman Avatar asked Jun 30 '14 17:06

nurnachman


People also ask

What app lets you customize your keyboard?

Microsoft-owned SwiftKey is adding some more ways to personalize your keyboard on iOS and Android with its latest update.


2 Answers

Try this code

    UIResponder* responder = self;
    while ((responder = [responder nextResponder]) != nil)
    {
        NSLog(@"responder = %@", responder);
        if([responder respondsToSelector:@selector(openURL:)] == YES)
        {
            [responder performSelector:@selector(openURL:) withObject:[NSURL URLWithString:urlString]];
        }
    }
like image 152
DongHyun Jang Avatar answered Sep 18 '22 11:09

DongHyun Jang


To answer MY OWN question:

In an iOS8 custom keyboard, the extensionContext object is nil, thus I can't use it to launch the containing app.

The workaround I came up with is:

  1. create a url scheme for your app
  2. add a UIWebView to your inputView
  3. load the url scheme for your containing app in the webview

I'm not sure if Apple will allow this to happen, but it works now.

like image 40
nurnachman Avatar answered Sep 20 '22 11:09

nurnachman