- Home /
Unity IOS - Open a In-App Web Browser
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!
I tried that same question about 2 months ago. I even tried it on SO and got awarded the tumbleweed reward. Good luck.
Answer by lemonyama · Jul 30, 2015 at 12:50 PM
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
}
Answer by Piotrku · Mar 22, 2016 at 04:03 AM
Please check out my plugin, which does exactly what you want to achieve: https://www.assetstore.unity3d.com/en/#!/content/57532
@piotruku i wants to purchase your plugin .. can i use it any game or is there any limit for this ... Can i use it with any bundle identifier..
yeah, you can use it wherever you want (on iOS and Android platforms of course)
Does your plugin allow for capture of a redirect url? Eg. to catch an oAuth 2.0 access code?
Hello, when use in-app-browser on ios? I user in-app-browser on android, but if i switch platform to ios and build project, then in-app-browser not workinkg Pls help other plugins (uniwebview3) also not working...
@Ilshat-dev86 please post your issue at our support forum. Please include exact description of issues you are experiencing („not working” is too vague).
Your answer
Follow this Question
Related Questions
Mecanim for Mobile Devices 2 Answers
Cells for a mobile app stacked vertically, not moving correctly 0 Answers
Vertical mobile input 0 Answers
Input.inputString on iOS - Empty? 0 Answers
Using the Volume Control Buttons On Mobile Devices 0 Answers