I am pretty new to Xcode and app development.
I have a platform that has a homepage with a login form and the designated Login/Join page(s).
My webview app is built to open the main URL where the homepage is located, e.g domain.com.
How can I set up to show the login page when the app is open instead of the main URL, e.g. domain.com/signin
I assume I should be able to set it up in the Xcode. Also, if this change is made in the Xcode will it sync with my App Dev Account?
Thank you in advance!!
Assuming you are using a WKWebView you can load a new page as so:
var webView = WKWebView()
if let loginUrl = URL(string: "domain.com/signin") {
webView.load(URLRequest(url: url))
}
A couple resources for you to learn more about WebKit:
https://medium.com/swift-productions/create-a-web-view-xcode-12-swift-5-3-9806d41cc9b
https://www.hackingwithswift.com/read/4/2/creating-a-simple-browser-with-wkwebview
Related
I would like to redirect to the app-store to a specific app, using its ID upon receiving a button tap. I have tried all the answers here on stack overview however none worked for me, they are most likely outdated such as these:
Open AppStore through button, Launching App Store from App in Swift, How to link to apps on the app store
I tried the following URLs, however I get false via UIApplication.shared.canOpenURL(:_):
"itms-apps://apple.com/app/{appId}"
"itms-apps://itunes.apple.com/developer/{appId}"
"itms-apps://apps.apple.com/cz/app/{developer}/{appId}"
How to currently go about redirecting to App-Store? Can this still be done via URL, or do we have to use the StoreKit exclusively?
Thanks in advance
if let url = URL(string: "itms-apps://apple.com/app/id\(appid)"),
UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
My application launches Google Chrome with the below code:
let url = URL(string: "googlechrome://xxx.xxx.xxx.xxx")
UIApplication.shared.open(url!)
But Chrome creates a new tab each time at launching.
I want to launch that URL at the same tab.
It seems that in the past there was a "create-new-tab" option to control whether to create tabs.
https://github.com/googlearchive/OpenInChrome/tree/785a1092ee3f954eab09bd2e6abdc46a7b2bc190
Currently, a new tab is created by default.
Does anyone know a good way?
I am trying to implement Facebook App Links using the Mobile Hosted API. Everything goes smoothly but when I test the App Link URL the app doesn't open even if installed and the URL redirects to the App Store. The custom URL for my app is set properly as when I type the custom scheme inside Safari it does open the app. It seems that something is off but can't tell why.
Here is some data:
The url that I test in the browser is:
http://fb.me/780961121977733
This is the registered data with the Mobile Hosted API:
{
id = 780961121977733;
ios =(
{
"app_name" = GoPhrazy;
"app_store_id" = 903559056;
url = "gophrazy://playerPuzzle/leo3/1420663071896";
}
);
}
The custom url scheme is registered in the info.plist as:
gophrazy://
I thought maybe the app_name case would affect it but I tested that to all lower with no effect.
Anyone has any tips on this?
Thanks
Url scheme in the info.plist MUST be always defined without leading ://
I'm quite new to swift & IOS development.
Is it possible to create an app in swift that will run a website inside of the app?
If so could someone point me in the right direction?
Thanks in advance.
You need to add UIWebView component or WKWebView component - tutorial can be found here: http://www.kinderas.com/technology/2014/6/7/getting-started-with-wkwebview-using-swift-in-ios-8
It is possible but it is going to be rejected by Apple in all probability unless you provide some more functionality, i.e., don't JUST wrap a website in an app and submit it.
Having said that, all you need to do is use an instance of UIWebView in your app and set the URL to load your website in viewDidLoad function
So your viewDidLoad function would look something like this:
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://www.apple.com")
var request = NSURLRequest(URL: url)
self.webView.loadRequest(request)
}
Is there any way to test if an iOS can handle a custom URL scheme? I have an app that registered a custom url scheme to be able to open the app from a hyperlink in mobile safari. How ever, I'd like to tell the user they need to go to the appstore to download the app if they dont have it installed.
Is there a clever way to test a URL and catch when it fails and the reason for it to fail?
This is the best I can come up with, but it's only tested in iOS 5:
If your link in mobile safari is link text,
change it to: link text,
then at the top of the /launchapp page, put a hidden iframe with the desired URL: <iframe src="myapp://path" style="display:none"></iframe>. In the body of the page, put your message about needing to go to the appstore to download the app.
If the user has the app:
They will not see the launchapp page, they will be directed seemlessly to the app url.
If the user does not have the app:
They will get a nasty alert about 'The URL could not be loaded', click OK, then they will be looking at your 'you need to download the app' page.
Update - March 2013
Check out this comment on a related SO answer. Apparently, if your app isn't already installed, you can seamlessly redirect to your app in the App Store using an approach like this (not tested):
// setup fallback (redirect to App Store)
var start = (new Date()).valueOf();
setTimeout(function() {
var end = (new Date()).valueOf();
// prevent App Store redirect upon returning to safari from myapp
if (end - start > 1000) return;
// get a seamless redirect if you use itms://... instead of http://itunes.com/...
window.location = 'itms://my/app/URI';
}, 25);
// Attempt to load my custom url scheme
window.location = 'myapp://my/path'