iOS App: Replace Flash in webview with native player - ios

I'm about to work on my first ever iOS app. For the first version, the main goal is to make the app a webview of my website. This is easy so far by just pointing a webview to the proper url. The part I need help with is replacing a Flash video player in the webview with a native video player.
Basically on the website I have a Flash video player that connects to a streaming video server with RTMP. As of now, the website is required to use Flash video (so converting to HTML5 video is not an option). The iOS app should show the website as is, except find the Flash player and replace it with a native video player so that the video playback still works on the iPhone/iPad.
Does anyone have any advice for accomplishing this?

This can be done. It may not be clean and pretty, but here is a possible approach: You are going to need to parse the HTML prior to displaying it.
First, you need to intercept the load request calls of your UIWebView so that you can check to see if it is calling the URL of the page that has the Flash you need to parse out. To intercept the load request call, use the UIWebViewDelegate method webView:shouldStartLoadWithRequest:navigationType: to read the URL.
If the URL matches the URL you need to remove the Flash from, you are going to run code that loads a HTML string that you will parse into the web view (more on that in a minute) and return NO to the webView:shouldStartLoadWithRequest:navigationType: delegate method. This means that when the user tries to go to the page with the Flash in it, we are going to stop the UIWebView from doing its thing and load the view with our own parsed content.
Once you figure out that you need to parse the HTML, you need to get in into a variable that you can work with. To get the HTML of your page as a string:
NSURL *yourURL = [NSURL URLWithString:#"http://google.com"];
NSError *error;
NSString *htmlString = [NSString stringWithContentsOfURL:yourURL encoding:NSUTF8Encoding error:&error];
Once you have the string, to remove the Flash code from your HTML, see this question:
Comment out a string in HTML before UIWebView can display it
Once you have parsed the HTML and gotten rid of your Flash, you can load it into your web view with [webView loadHTMLString:string baseURL:nil];
Finally, you need to insert a native movie player on top of your web view via code. You'll have to deal with screen rotation and sizing and placement of the native player on top of the web view, but that fun I will leave to you.
That is a lot of raw material, but is should get you going on one on possible solution.

So, what you’re asking is to show a WebView inside the native app, and show some native components inside this WebView. This cannot be done.
You will have to build a completely native app for this. Or use HTML5 inside the WebView.

Related

iOS WKWebView Handle File Download

I am facing the following problem:
In a web interface, file downloads are triggered with an anchor tag, like this:
<a href="/bla/blabla" download>..</a>
While Safari browser can handle this request and open a dialogue to handle the file, WKWebView treats this just as an ordinary link and does nothing with it. I want to be able to get the file handler dialogue that is normally there when using Safari.
Right now there are 2 problems and I do not see an opening there yet:
I can not detect a click on the element as it is treated just as a normal link. And I can not rely on the URL parameters to detect if it is a file since that is not constantly true.
Even if the URL is defined as a one leading to a file, I can not pass it to Safari since it does not share session info and cookies with my app's WKWebView.
Therefore, I would like to know if there is any opening in handling files in iOS WKWebView. Thank you.

Display flash file with URL in UIWebView: Obj C/swift

I have game URL-
https://nogs-gl.nyxinteractive.eu/game/?nogsgameid=70090&nogsoperatorid=268&nogscurrency=eur&nogslang=en_us&nogsmode=demo
URL is running well in my web browser.
I want to display this in my iOS app. Currently, I am doing that so by using native UIWebView but it's displaying the message as
What am I supposed to do for opening the given URL in my application?
iOS does not support Flash. It never has, and it never will. You cannot run flash content on iOS.

Handling ics data in UIWebView

I have an app which uses a UIWebView and cordova/PhoneGap. One section of the app has a 'Download Calendar' feature, which has been giving me a lot of issues on the native iOS side. The basic function of Download Calendar is an ajax call (type: POST) which returns formatted ics data. In mobile safari, this functions perfectly. A table view will slide up from the bottom and give me the option to add the listed events to my phone's calendar. I think this is just how safari normally handles ics files. Now for my issue...
UIWebView doesn't seem to want to behave this way. When I tap "Download Calendar" nothing happens. To get the ics data, I used an NSURLConnection to get the response, and put it in an NSData structure called webData. With _webData, I'm making this call:
[self.webView loadData:_webData
MIMEType:#"text/v-calendar"
textEncodingName:#"utf-8"
baseURL:[NSURL URLWithString:#"calshow://"]];
In my shouldStartLoadWithRequest: method, I'm telling any 'calshow://' urls to open the calendar, but I don't think this gets me anywhere, since I can't pass the NSData along with it. My main question right now is, can my UIWebView mimic how safari handles this ics data? If not, can I do anything useful with this NSData?
BEGIN:VCALENDAR\r\nPRODID:-//bobbin v0.1//NONSGML iCal
Writer//EN\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT...
UPDATE: I was able to get this working in a UIDocumentInteractionController, where it displays the dates and times exactly how safari would handle the data, however, there isn't an "Add All" button or an "Open in Calendar..." option. The UTI is correctly set to com.apple.ical.ics, but I'm not presented with any usable options in the view.
This link may offer a solution. Appears UIDocumentInteractionController works with .ics files, but I haven't verified.

iOS: Open a registered open URL from within the same app

I am running into a situation which I am not sure is possible from technical/design point of view. Please advise.
Here is what I need:
I have an open URL registered for my native iOS app. I expect a request ID to be passed along with it and once hit I open that request.
From within my native iOS app, I need to open a web page in the webview. This page has few buttons in it.
A tap on the button in the webview should open the request inside my app. So, I want to trigger the registered open URL in step #1.
Web page data is dynamic and will change on the fly.
Is this a feasible design. Shall I consider something else.
Any advise/pointers will be appreciated.
This should be possible. Here's a though:
1: Implement the UIWebview delegate method shouldStartLoadWithRequest.
2: when you intercept that your webview is attempting to access the url yourapp://blah-blah-blah you can return NO instead dip into your appdelegate can manually call the function handleOpenURL.
I've seen something similar in the past with supporting oAuth (I believe it was with instagram) within one of our apps. We basically loaded up the login page in a UIWebview and then when we detected the the post login redirect we parsed the oAuth token from the url and called it good.
Good luck

StageWebView issue on ipad

I am using stageWebView for showing webpage in my mobile app but don't know how to move back to my app once it gets loaded. In application descriptor file, I had already registered custom uri scheme (myapp://) for IOS devices and from the loaded page inside stageWebView, I was trying to call following URL myapp://webcam. But nothing had happened. It neither called LOCATION_CHANGE event of StageWebView not called INVOKE_EVENT of nativeapplication.
How can I fix this issue?
Thanks in advance,
Mamta
Custom URIs don't work in StageWebView (adobe help page)
Instead of a custom URI, use a hash tag and listen for Event.COMPLETE events on the StageWebView.
Webcam
instead of
Webcam
You'll get a Event.COMPLETE event when they click the link and can then check the StageWebView.location for a location hash.

Resources