I am making an app for iOS. I have a couple links, that open up safari browser and leaves my app. I want to make it so the app opens a browser extension but does not leave the app. An example of an app that has been doing this is Facebook Mobile, when you open a link, it loads it with the in-app browser.
I hope you understnad what i mean. I guess I am not the best at explaining, but I hope you can help me.
Thanks!
Your Unity app will have to talk to your main app delegate (UnityAppController.mm) and then you just use Objective C to create an add a UIWebView in your main window to open up the URL.
For the interface from Unity to iOS you will need to define the following in your .cs:
[DllImport ("__Internal")]
private static extern void _Hello (string service);
public static void Hello(string message)
{
// Call plugin only when running on real device
if (Application.platform != RuntimePlatform.OSXEditor)
_Hello(message);
}
Then in your objective C Xcode:
extern "C" {
void _Hello (const char* message)
{
NSLog(@"Hello");
NSString *msg = [NSString stringWithFormat: @"%s", message];
[GetAppController() hello:msg];
}
}
In your Objective C main app delegate class proper you can then have:
-(void)hello:(NSString*)message {
NSLog(@"hello: %@",message);
// or just open a new UIWebView here and attach it to the window
}
Please check out my plugin, which does exactly what you want to achieve: