Skip to content
TechoElite

TechoElite

Explore Software and Gaming, Stay Updated on Latest Gear, Embrace Smart Homes, Dive into the Social Scene, and Uncover Mobile Insights

Primary Menu
  • Home
  • Software And Gaming
    • Call of Duty
  • Latest Gear And AV
  • Smart Homes
  • Social Scene And Mobiles
    • Freshest Facts
  • Home
  • Software And Gaming
  • Alternative App For Safari

Alternative App For Safari

Kathleen Burrell May 8, 2022 3 min read
2714

Alternative App For Safari

As a web application developer, I sometimes need to test my web services in a desktop browser other than Safari. It is possible that you have been locked out of your Facebook account because Safari cannot be directed to open the correct URL for your app. In this case, you have to use another “trusted” browser such as Firefox or Chrome. What would happen if you are working on a development environment without these browsers? It becomes impossible to test your app.

To solve this, I wrote an alternative web browser by using Apple’s Safari Developement Kit (SDK) and the javascript interface called JSInterface which is officially released by Apple. You can download/fork it on my github page at https://github.com/nishiohiroshi/SJSSafariBrowser

How to refresh safari on iPhone

Step1: Add a WebView to the window. var webview = new WebView(); this.contentView = webview; webview.addEventListener(“load”, function () { // Hide Safari toolbar and address bar. webview.scrollViewStyle = “”; getURL(“index_plain_page_iphone.html”); webview.popoverHide(); }); this.window = new UIWindow(UIScreen.mainScreen().bounds); var mainViewController = this; // Load index page in the view controller’s window loadWindow(this, mainViewController);

Step2: Write javascript functions to control the web view. var webView = document.getElementById(“webview”).getSafari();

Step3: Listening to the events from Javascript. window.addEventListener(“message”, function(event) { if (event.data.type && event.data.type == “safari-browser-execute”) { var jsString = event.data.eval; webView.executeJavaScript(jsString); } });

How to use the app on your iPhone or iPad

  1. Build and run SJSSafariBrowser on your device (goto “Build Phases” and add the usual code signing). I used iOS 4.2 for development purposes, but it should work on other versions too(if not please let me know)
  2. Open Safari and go to the address: localhost:9000
  3. Add a new “WebView Override” network activity in the app and go to the address: localhost:8081
  4. You can select items from the menu, type text in the url bar, share something on Facebook etc…I’m planning to add more events for controlling your iPhone/iPad apps in the future.
  5. Go back to your app in Xcode and run it in iPhone Simulator (cmd+R) or on your device (if connected).
  6. If you get this error, go to “Build Settings” of SJSSafariBrowser project pane, find “Other Linker Flags” section then add “-ObjC” to the list.
  7. Reload to reload Safari (cmd+R) or by bringing up the web view menu and choose “Reload”. You should see your page just as you see it in Safari’s address bar.
  8. If everything goes well, select any items from other apps on your device then go back to Xcode and run your app (cmd+R). (Make sure you are using Xcode 4.2 or above)

The pros and cons of using an alternative browser for Safari

Pros:

  1. No need to build and install another browser.
  2. Allows you to use the same ViewController code.
  3. It can be used for debugging purposes (e.g.: WKWebView).
  4. You can write unit tests for your app using XCUnit, an open source framework for unit testing.
  5. You can debug on Safari and JavaScript Console simultaneously using Xcode.
  6. Supports HTML5 based MVC design pattern (e.g.: backbone, angularJs etc…)

Cons:

  1. No history list or back button on the toolbar of the web view.
  2. Javascript console doesn’t work correctly (e.g.: window.location = “page_name” doesn’t work).
  3. Javascript APIs don’t work as you might expect (some do and some don’t ).
  4. The web view doesn’t share cookies like Safari does (You have to copy your cookies file manually).
  5. No gesture event support for ‘pinch’ and ‘rotation gesture’.
  6. JSInterface doesn’t support ‘new Function’ and some other features.
  7. You need to manually set the user agent string of your web view (You can use “SJSUserAgentUtil/user_agent_string.js” for this). If you have any questions/bugs related to the app, please let me know.

Conclusion

This article presents wser, an alternative webview app for Safari on iOS. It allows you to use the same ViewController code on your project. The app does not support all of JavascriptInterface feature list but will hopefully improve in future. You can find more details about its usage at http://www.wiaderko.com/wser-an-alternative-webview-with-javascriptinterface/ and the source code at https://github.com/wiaderko/wser. Issues can be posted to https://github.com/wiaderko/wser/issues

Continue Reading

Previous: Advantages of Using Facetime
Next: Applications That Are For Apple Only

Trending Now

1

July 2, 2025
Training Your Team on Zendesk: A No-Fluff Guide to Real-Life Implementation 2

Training Your Team on Zendesk: A No-Fluff Guide to Real-Life Implementation

June 27, 2025
Myths and Facts: Common Stereotypes About Online Betting 3

Myths and Facts: Common Stereotypes About Online Betting

June 26, 2025
The Perfect Games to Play Online for Money 4

The Perfect Games to Play Online for Money

June 26, 2025
5

June 26, 2025
Secrets to Online Roulette 6

Secrets to Online Roulette

June 25, 2025

Related Stories

The Perfect Games to Play Online for Money
7 min read

The Perfect Games to Play Online for Money

June 26, 2025 52
Leading 5 Mystery Box Sites to Level Up Your Game! Image3
6 min read

Leading 5 Mystery Box Sites to Level Up Your Game!

April 23, 2025 330
The Future of Business: Integrating Data Insights into Corporate Strategy Image1
5 min read

The Future of Business: Integrating Data Insights into Corporate Strategy

March 19, 2025 493
Tech-Driven Compliance: How Online Casinos Adapt to Gambling Restrictions Image3
5 min read

Tech-Driven Compliance: How Online Casinos Adapt to Gambling Restrictions

March 19, 2025 480
Why We Love Risk: The Neuroscience of Gambling Addiction vs. Healthy Play Image2
3 min read

Why We Love Risk: The Neuroscience of Gambling Addiction vs. Healthy Play

February 27, 2025 560
9 min read

January 28, 2025 710

more you may love

Wazamba Casino Details on Revieweek.com 1

Wazamba Casino Details on Revieweek.com

March 24, 2023
Apple iPhone iOS Customization Options apple foxconn lens technology luxshare precision 2

Apple iPhone iOS Customization Options

September 30, 2022
10 Airdrop Apps to Get You Freebies & Discounts apptopia twitterkantrowitz bigtechnology 3

10 Airdrop Apps to Get You Freebies & Discounts

September 22, 2022
Install HBO Max on Smart TV 4

Install HBO Max on Smart TV

August 17, 2022
Samsung Smart TV using APK 5

Samsung Smart TV using APK

August 17, 2022
6075 Tomalin Boulevard
Solan, TX 63457
  • Privacy Policy
  • T&C
  • About
  • Contact Us
  • Freshest Facts
© 2023 TechoElite.com, All Rights Reserved.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT