IPhone SDK - Add the Add to Home Screen Button to UIWebView

I have an iPhone app that has a UIWebView component. I’m trying to check if I can play the Add to Home Screen button, which is present in the settings of the tab bar in Safari.

Is this possible inside a UIWebView in a native application?

Thanks! Brett

+6
source share
3 answers

[I assume your question is about repeating the action of adding to the main screen, rather than copying the look of the button itself (which is pedantic is what you actually wrote).]

As others have said, this is not possible.

What you can do is programmatically launch Safari from your application and provide the URL of the download page, which is your page.

When your page is loaded, it has some animation and shows the user where the add button to the main screen is located, and ask him to click it after clicking the link displayed on your web page. When users click on a link, it takes them to any page that you want to save on your desktop, and you hope that they follow your instructions.

If you register your application for processing a proprietary URL scheme, users can return to your application from Safari by clicking on the link using the application URL scheme.

The web pages that you download Safari, however, must be deleted pages, you cannot specify Safari on the page in your application or load the application, because Safari cannot read pages from your application sandbox.

+4
source

The short answer is no, you cannot. Apple does not allow you.

Here's a similar question that might help you come up with other features: Javascript for "Add to Home Screen" on iPhone?

If I had to think about working around my head, you could create a javascript popup that instructs them how. He could say something like pressing this button to go to mobile safari, and then tap action → add to the main screen.

Run Javascript using the UIWebView method:

 - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script 

Hope this helps.

0
source

You can use UIActivityViewController with your url as activity elements

 NSArray *activityItems = @[title, url]; 

And then you can exclude actions that you do not want. I think this is the only way now.

0
source

Source: https://habr.com/ru/post/917110/


All Articles