Firebase Phone Authentication for mac catalyst - swift

Context
I am in the process to implement Mac Catalyst in my iOS project. Everything is alright so far except the Google Firebase support.
I am authenticating the user with their phone number. Firebase does this in a two step process. First the device receives a silent push notification & then they are asked to enter their OTP.
The first time I tried, a window opened in safari. It just checked if I am a robot or not. Every other time I tried the window didn't come back.
All this is working with iOS. It just doesn't work on my mac.
Problem
I am getting the following warning:
[Firebase/InstanceID][I-IID003014] Running InstanceID on a simulator doesn't have APNS. Use prod profile by default.
Code
Internet.signIn(with: code) { (error) in
// This line aka the closure is never executed
if error != nil{
alert("Something went wrong", "Try resending the SMS")
return
}
alert("Verified", "Let's continue with entering further user information now") {
self.performSegue(withIdentifier: "userWasVerifiedSegue", sender: self)
}
}
Approaches
I edited my scheme & changed it to "release".
Tried to add a new mac certificate on developer.apple but it doesn't allow me to enter the bundle id.

Related

Firebase Authentication using facebook and google signin not working when internet is turned off and turned back on

I have a strange issue with firebase authentication. SigninCredential callback never gets called when I turn off and turn back on the internet. Only after a few hours(probably after 4 hours) callback gets triggered
val mCredential = FacebookAuthProvider.getCredential(mAccesstoken!!.token)
mFirebaseAuth.signInWithCredential(mCredential)
.addOnCompleteListener(this) { it ->
if (it.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success")
getCurrentUser(mFirebaseAuth.currentUser)
} else {
// If sign in fails, display a message to the user.// unable to retrieve details of the user
Log.w(
TAG,
"signInWithCredential:failure:: FirebaseAuthentication failed even though accesstoken present",
it.exception
)
Toast.makeText(
baseContext, "Authentication failed.",
Toast.LENGTH_SHORT
).show()
}
}
If I do a fresh install of the app and perform a sign in it works properly provided that the internet is turned on while I try to login into the app
First check for internet connection before executing the above code.
I figured out the issue. I added an active internet condition before performing a login that fixed sign-in problem. check the internet available on the device then only perform the login
I did face another issue that is addOnCompleteListener never gets called because I was waiting on the main thread instead I used executor to perform the task on a background thread

How to access calendar in MacOS screensaver?

Is it possible to access calendar events in screen saver? I am able to request permission in the application. But some API is not prompting in the case of the screensaver.
I didn't find any documentation around it.
I used the following code to requesting calendar events:
func requestPermissionForCalendar()
{
var eventStore = EKEventStore()
eventStore.requestAccess(to: EKEntityType.event) { granted, error in
if granted{
print("Permission granted")
}else{
print("The app is not permitted to access reminders, make sure to grant permission in the settings and try again")
}
}
}
Couple of things, first, a screen saver is completely passive in macOS. Any prompt for anything will be disregarded when it's running fullscreen, as a screensaver.
In general, the proper way to do this with a screensaver is to ask for permission in the configurationSheet (the screen saver options). The user will get prompted there, and can allow or deny you. I do use this for example to request the user location.
Once allowed in System Preferences, your screensaver when running in screensaver mode will get access. I suggest you test your code first in the configuration sheet as this is much easier.
Additional note, ScreenSavers on macOS since Catalina are sandboxed by an application extension provided by Apple, and that extension has a limited list of entitlements (see a list here https://github.com/glouel/ScreenSaverMinimal).
I'm not particularly familiar with EKEventStore, but if it requires a specific entitlement to make it work, you'll be stuck as you can't add any entitlement yourself, everything depends on legacyScreenSaver.appex.

Handle the state of IKEv2 Personal VPN with Swift

I've implemented the possibility of opening VPN connection with IKEv2. The connection works great after I close (kill) the app. However, I want to get the current connection status after I launch the app again. How can I do that?
Unfortunately this returns invalid status when I try to call:
NEVPNManager.shared().connection.status
but I see (and it's correct and it's true) Personal VPN in active state here:
Could you provide how to get actual status of my Personal VPN?
I've resolved this case with this implementation specially for IKEv2
// special case for IKEv2
NEVPNManager.shared().loadFromPreferences { error in
if error != nil {
//
} else {
print(NEVPNManager.shared().connection.status)
}
}
I've added this into my connection manager and now the app handles correctly the status of Personal VPN after relaunch of the app

Uber API OAuth on watchOS 6.2 using ASWebAuthenticationSession

I'm trying to authenticate with Uber's API using watchOS 6.2's new OAuth capability ASWebAuthenticationSession:
ASWebAuthenticationSession(url: uberUrl, callbackURLScheme: scheme) { (URL?, Error?) -> in {
print(callbackUrl, error)
if let url = callbackUrl {
let components = NSURLComponents(string: (url.absoluteString))
if let t = components?.queryItems?.filter({$0.name == "code"}).first?.value {
self.token = t
}
}
}
When I run it, an adorable little web browser comes up on the Watch and prompts for a "E-mail or Mobile Number", after entering my e-mail, clicking on "Next" pops up a text entry window which then suddenly disappears, leaving me back at e-mail entry. The subsequent clicks on "Next" brings up a text entry window which only allows me to edit the e-mail address. Password is never an option. I never got the closure to complete, not even with en error.
If I scroll down to "Login with Google", then Google's login page loads, and lets me enter e-mail and password, and the completion block executes (I get a nil token presumably because my Uber account is not a Google one).
I suspect an issue with Uber's login webpage, but can't verify that other than observing that Google's seems to work. Also, I can find no documentation on the callbackURLScheme parameter with respect to watchOS. I create a scheme in the plist as one might with an iOS app, but can't confirm this is the correct procedure. Nonetheless, it doesn't change the fact that the password field will not come up on Uber's oath login page.
Searching StackOverflow for watchOS and ASWebAuthenticationSession produces no results at this point.
Is anyone else trying to do this right now? Has anyone had success? Am I missing something important, or is this simply an error on Uber's part?

Authlogic and iPhone app login

This has been a head-banger for me. I have looked at all of the similar questions on SO and none have proved satisfactory. Here's my go at it.
I have a perfectly fine rails 3 app setup with Authlogic.
I have been using Objective Resource (http://iphoneonrails.com/) to connect my iPhone app and my Rails app, and it has been working fine.
Now is the time to add authentication, and I cannot figure it out.
I have a UserSession class in my iPhone project with a username and password field. When the app launches, I present a login screen with username and password fields. Upon clicking a button, the iPhone app attempts to create the UserSession.
I took my code for doing that from http://www.corprew.org/blog/2010/01/27/authlogic-and-objectiveresource/
us.username = usernameField.text;
us.password = passwordField.text;
NSError * err = nil;
if(![us saveRemoteWithResponse:&err])
{
NSLog(#"%d", err);
NSLog(#"whoops, error");
}
When I run that code, the Log shows "0" and "whoops, error" meaning that the UserSession did not save. This occurs for both correct and incorrect logins.
Additionally, I have placed token comments in saveRemote ("I'm in saveRemote" etc.) and those never appear in my log.
Any ideas here?
If you want me to post anymore code, let me know. I will be up all night with this one.
Question resolved.
Don't use ObjectiveResource :-)
Switched to ASIHTTP and it's working fine for my needs right now.