so i want this feature in my app where if user press Beta Access it will bring thrm to a viewcontroller saying you need to enter a user name and password. This username and password is stored in the app itself and there is only 1. If the username and password is correct , it will go to the another viewcontroller where features that havent been released yet are at. any tutorials out there or how can i do this?
im kind of new and have an idea but don't know how to create it
I'd start here if you are new: https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/
Then some Ray Wenderlich turorials will also help.
This totally helped my question... I never said I’m new.. I said I kind of know some Swift , plus I did the link ages ago.. Would love if there is a way to do this
The easiest way to do a login screen is to use a modal segue from wherever you are at the time, and you can add this to your storyboard. (You'll need a login view controller to segue to, which will manage the login process.)
After that, your app can segue to a view controller that offers extra features, but how you do that will depend on your overall app design. Is it navigation controller based? Tab bar based? Split view based? There's no single or best answer here.
What will you use to manage your users? Local, or an online service such as firebase.
I said this in the OP "This username and password is stored in the app itself and there is only 1."
My app is based off a Navigation Controller.
Are the credentials stored as variables?
They can be. But most likely yes.
Do you want the users to log in every time they want beta access? Because if so I would simply have three view controllers;
1. The login page
2. The page without beta access
3. The page with beta access
Then, on the login page, I would add two text fields and a login button.
let username = "user1"
let password = "password123"
class ViewController: UIViewController {
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBAction func logInPressed(_ sender: UIButton) {
if usernameTextField.text == username && passwordTextField.text == password {
self.performSegue(withIdentifier: "logInPageToBetaAccessViewController", sender: self)
} else {
print("Access Denied")
self.performSegue(withIdentifier: "logInPageToViewControllerWithoutBetaAccess", sender: self)
}
}
From then on if they don't have access you can create an alert saying they cant access the beta.
Yes i do want the users to log in everytime they want to beta test.
I would want my view controllers like this
Menu Viewcontroller
Button to other page
Button to other page
Beta Access.
When i press Beta Access it goes to another ViewController and prompts a username and password. If the user has access to the username and password , they type in Textfield 1 : MyUsername Textfield 2: MyPass123 . If the username and password is correct it goes to a page where you can access the beta features. If incorrect it just stays at the Beta Access Page with the text fields and you can go back to the home screen with most of the options.
class ViewController: UIViewController {
@IBOutlet weak var webView: WKWebView!
@IBOutlet weak var Username: UITextField!
@IBOutlet weak var Password: UITextField!
@IBAction func LoginButton(_ sender: Any) {
}
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "link"
let request = URLRequest(url: url!)
webView.load(request)
/
/
/
}Thats my ViewController Class in ViewController.swift ..
But when i add
if usernameTextField.text == username && passwordTextField.text == password {
self.performSegue(withIdentifier: "logInPageToBetaAccessViewController", sender: self)
} else {
print("Access Denied")
self.performSegue(withIdentifier: "logInPageToViewControllerWithoutBetaAccess", sender: self)
}Every code in the ViewController.swift breaks..
All you would have to change is add a button to the menu with performs a segue to the beta login page and a segue from the login page to the beta page if access is granted.
To go back to the main page;
self.navigationController?.popToViewController(MENUNAME, animated: true)
This is so confusing! Sorry 😝
Xcode will throw errors because the name of your text fields and segues are different to my sample ones.
change userNameTextField to Username
and passwordTextFieldToPassword
You also need to make sure that the segue names are the same as mine or change mine to what yours are
Im confused by this part 😟
self.performSegue(withIdentifier: "logInPageToBetaAccessViewController", sender: self)
} else {
print("Access Denied")
self.performSegue(withIdentifier: "logInPageToViewControllerWithoutBetaAccess", sender: self)Can you explain and what i have to do? Sorry 😟