Launching Containing App from UIWebView in Custom Keyboard - ios

Since you can only go the normal route for launching a containing app from a Today extension, and not a Custom Keyboard, I've been trying to do the hacky version of launching a UIWebView and launching the containing app through its URL scheme. Mostly been getting help from this post: launch containing app from iOS8 Custom Keyboard, but I'm not allowed to comment on answers since I'm new to stack overflow.
Anyways, doing it now, the UIWebView is popping up but is just showing a blank white square and not launching the URL scheme. Already tried accessing the URL scheme from Safari, and I know that launches the app, so not sure why its not doing anything. Code I have now in the method following when the right key is pushed is:
let urlkey = NSURL(string: "MYAPP://")
let webAppView = UIWebView(frame: CGRectMake(0, 0, 100, 100))
let request = NSURLRequest(URL: urlkey!)
webAppView.loadRequest(request)
self.view.addSubview(webAppView)
Any ideas for why nothing in the view is loading, or other ways to go about launching a containing app from a custom keyboard appreciated. Using XCode 6.3 and Swift.

It is not possible to launch another app through keyboard-extension.
Other extensions like today-widget-extension can use like below.
NSURL *pjURL = [NSURL URLWithString:#"hostingapp://home"];
[self.extensionContext openURL:pjURL completionHandler:nil];
//https://stackoverflow.com/questions/24019820/today-app-extension-widget-tap-to-open-containing-app
but, nothing happens in the keyboard-extension.
//I guess...
If you get success to implement launching app in the keyboard, the keyboard will not be accepted by Apple.
updated 15/09/14 :
openURL not work in Action Extension
I found some people are trying that, so check this.
Some said their app accepted by apple.(I don't know it's true)

Related

Redirect in Safari as soon as you open iOS Swift app

I am developing a simple iOS app with Swift, I would need to know if there is a method to direct Safari to a URL as soon as the app opens, without button clicks.
in the ViewWillAppear methods you can open an URL calling this methods:
if let link = URL(string: "https://yoursite.com") {
UIApplication.shared.open(link)
}

iOS app deep linking: Return to previous app or access current url scheme of current app

I'm developing a custom keyboard for iOS. When I'm e.g. in Safari using my custom keyboard, I have a button in my keyboard to jump to to keyboard containing app. Then in my keyboard app I have the iOS specific "<- Safari" button in the top left corner to jump back to Safari.
Is it possible to programmatically jump back to the source application (in my example Safari)?
Or can I send the original url scheme to my containing app and then open the previous app (could be ANY) by the url scheme?
It must be somehow possible, because the app Scandit Wedge does exactly what I want. I created an empty test app without any url scheme and with the Scandit Wedge keyboard I can go to Scandit app, read barcode and it goes automatically back to the source app.
Here's a video I recorded:
https://www.youtube.com/watch?v=UiHH4NanlkA
To achieve this you have to implement inter-app two way communication using x-callback-url. x-callback is just a "protocol" to format the NSURL to ease the data processing at the receiver end and also allowed the source app to receive the correct callback function. You can explore more this with evernote and this tutorial.

Having a subview inside Unity for native IOS apps

For my iOS app built with unity engine, I have a use case where I would want to direct the user to settings page from within the app itself. I am using objectiveC to create a custom plugin for iOS that directs user to settings page. But it backgrounds the app and brings up the settings page. I would like to be able to achieve this from within the app itself if its possible to show settings in some kind of subview popup in the app? I have seen this somewhere for example where the app brings up a mail subview or a google map subview inside the app itself but not sure if its possible for doing something similar with iOS native settings page?
Currently i am using openURL to simply direct user to settings URL page but I would like this to be embedded in some subview from within the app itself
NSURL *url = [NSURL URLWithString:#"prefs:root=NOTIFICATIONS_ID"];
[[UIApplication sharedApplication] openURL:url];
Any ideas?
It's not possible to show a portion of the Settings app in your own app like you can do with mail or maps. However, you can build your own UI within your app to edit settings.

Performing a task through a website and going back to an iOS app

I'm developing an iOS 7+ app that I need to offer the option of navigating to a certain web page to let the users to fill in a form there, and after that to come back to the app's view where the user was.
Is it possible to programmatically open Safari with a given url? If it is, I suppose that then there is no way to automatically redirect the user to your app from there... right? Is then a UIWebView the only option? Is it possible to navigate back or dismiss the view with the UIWebView without the need of user interaction?
Thanks
You can open links in Safari as detailed in this post How to launch safari and open URL from iOS app
I don't believe you can set a 'callback' and have it return to your app on completion, as you have no control over the user once they have exited your app's sandbox.
Opening the link in UIWebView would provide control, as you can utilize the UIWebView callbacks.

Is it allowed to add a UITabBarItem that opens up Safari?

I want to add a UITabBarItem on the TabBar which when clicked opens up Safari instead of loading its corresponding tab. (Not UIWebView but the app goes to background and opens up Safari instead)
I already know how to do this, but I was wondering if this is allowed by Apple. I know they're OK with using the TabBarItem to trigger other actions such as opening a modal in the app, etc. However I am not sure if it's OK to open a safari.
I am just being cautious because I don't want it to get rejected for this and wait another week.
I don't see a reason why it shouldn't be allowed.
But: it could lead to confusion amongst your users, because they would most likely not expect that touching an item on the TabBar leads to an app switch. I would rather open a webView and offer the additional possibility to open the page in Safari.
There is no harm doing such and it is also allowed by Apple.
But, I would personally suggest to use UIWebView, over Safari navigation. Because it will create unhealthy user experience, where he/she requires to jump around to swith in-between Safari and App. Rather you can open the same link in UIWebView, which will kepp our user in app only.

Resources