firebase forgot password usage - ios

Hi I'm starting to become a regular on here but if any can help me with the following. I want to test to see if a user is using a reset password and have the following:
if FIREBASE_REF.authData.providerData["isTemporaryPassword"] == true {
// run some code
}
but xcode is saying expression expected, if anyone knows the correct syntax I would appreciate it.
Thanks

Think I have now got it sort and the solution is as follows for anyone else who is struggling with this:
let handle = FIREBASE_REF.authData.providerData["isTemporaryPassword"] as? Bool
if (handle == true) {
// run code here.
}

Related

migrating project to comply with google sign in requirements for iOS

I'm trying to get a google sign in button to work with my iOS app, but I'm getting this error here:
Cannot find 'presentingViewController' in scope
This is the code segment:
func handleSignInButton() {
GIDSignIn.sharedInstance.signIn(
with: signInConfig,
presenting: presentingViewController // this is the line with the error,
callback: GIDSignInCallback? = nil) { user, error in
guard let signInUser = user else {
// Inspect error
return
}
// If sign in succeeded, display the app's main content View.
}
}
I've been told I need to migrate the way I am signing in and I found this here:
https://developers.google.com/identity/sign-in/ios/quick-migration-guide
but I'm confused about this part here:
Manually connect GIDSignInButton to a method that calls signInWithConfiguration:presentingViewController:callback: using an IBAction or similar.
Can someone show me how to do this properly? I'm a iOS novice :)
Thanks!

Callback issue with getSteam iOS sdk

I think something wrong with the iOS SDK of getStream. I m not getting any callback on following , unfollowing and checking if user is following someone.For all these three case callback is not coming.
Even in the sample app given by stream is not working for these case.
Below is the code from ProfileViewController from sample app.
Rest of the sample app working fine.
Url of the sample is : https://github.com/GetStream/swift-activity-feed
User.current?.isFollow(toTarget: flatFeedPresenter.flatFeed.feedId) { [weak self] in
button.isEnabled = true
if let error = $2 {
self?.showErrorAlert(error)
} else {
button.isSelected = $0
}
}
It was a bug, inside isFollow the user flat feed is deallocating after the request. Please check the new version v.1.0.11.

UserDefaults.standard.string() returns nil

I "inherited" an iOS Xcode Project in Swift. I've never programmed in Swift or used Xcode before. I copied the project from one user account to another and checked it into a git repo.
Now I'm araid this (the copying, permissions ?) might be the cause for the App not being able to read its settings properly. Because UserDefaults.standard.string(forKey: "pref_Foo") returns nil although in the Settings.Bundle's Root.plist there's clearly a pref_Foo identifier.
The App has worked before, so I don't see where this suddenly comes from.
Since I'm not too familiar with XCode all I did up til now was debug into the Application to see that UserDefaults.standard.string(forKey: "pref_Foo") is nil.
How could I approach this problem?
Thank you!
EDIT: This is part of my code in ViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
loadSettings()
...
}
func loadSettings()
{
if(UserDefaults.standard.object(forKey: "pref_Foo") == nil)
{
printf("Error")
}
}
You should use below code with validation, first delete app and install again. then use, you will get success.
var UserStatus:String {
get{
return UserDefaults.standard.object(forKey: "pref_Foo") as? String ?? "0"
}
set(status){
UserDefaults.standard.set(status, forKey: "pref_Foo")
UserDefaults.standard.synchronize()
}
}
Use of code is as below.
if (UserStatus == "pref_Foo"){
self.logoutSuccess()
} else {
self.loginSuccess()
}
Update or set value is so simple in one line code as given below.
UserStatus = "pref_Foo"

How do you pass a test with XCUITest? iOS Swift

So I have this XCTestCase, it runs a simple function and I'm satisfied with the results, but every time the function ends, it displays "TEST FAILED" and shut down the app.
One more thing, I tried to change the continueAfterFailure boolean to true and yet it still shut down the app after failure...
I couldn't find a solution yet, hope someone can help me :)
Thanks
Update:
Here's the code:
func loginSuccess (element: XCUIElement) {
//Entering invalid input to the text field
//App has validator a that doesn't let the input in
element.typeText("!##$%^")
XCTAssertTrue((element.value as? String == ""), "Test Passed!")
if element.value as? String == "" {
print ("Test Passed!") //This line works every run
} else {
XCTFail("Invalid text can be inserted") //Managed to force fail and succeded, but not pass.
}
}
You have things reversed. XCTAssertTrue evaluates that an expression is true and logs the provided message and fails the test if the expression is false.

Updating to Xcode 7 Beta 5 & Swift 2 produced multiple errors

I updated Xcode to the new Xcode 7 beta 5. In doing so, it converted to Swift 2, but then created even more errors. Right now, I am completely stuck, and don't know what to do, because although all my errors are gone, my app will not work correctly.
My problem is this:
if(self.myOutput3 as? NSObject == true) {
print("IT IS TRUE")
PFUser.logInWithUsernameInBackground(self.myOutput1 as! String, password: "xxx") { (user: PFUser?, error: NSError?) -> Void in
if error == nil {
print("It Worked!")
// self.presentViewController(destViewController, animated: true, completion: nil)
let instillation = PFInstallation.currentInstallation()
instillation["user"] = PFUser.currentUser()
instillation.saveInBackgroundWithBlock(nil)
self.performSegueWithIdentifier("toTimeline", sender: self)
} else {
// self.enterButton.enabled = false
self.errorAlert()
print("Couldn't log in...")
}
}
} else {
print("IT IS FALSE")
self.performSegueWithIdentifier("continueTheSignIn", sender: self)
// self.move()
}
The program will perform the toTimeline segue, but not the continueTheSignIn . I don't see any logical reason that this is not working. Could anyone point me in the right direction?
Also, I am having an error in my messages feature.
cell.textView!.linkTextAttributes = [NSForegroundColorAttributeName:cell.textView!.textColor]
This is giving me the error "Cannot assign a value of type '[String : UIColor?]' to a value of type '[String: AnyObject]!'
I was not previously getting this error in Swift / Xcode 6.4, so I don't know how to fix it.
Additionally, once I bypass this to get into my app to see if my other features are working, most of my UITableViews are not displaying any information. One is, however the rest load the correct amount of rows, but display nothing. What could this be? Also, no Parse pictures are being displayed correctly either. These are even more concerning than the other problems...
Here is the picture after I deleted and re added the segue under a diff. name.
Parse wont support the beta version . it needs a full version . I have contacted them based on a similar issue . They said they will update the parse to work with xcode7 once the full version of xcode7 is released.

Resources