Handle the state of IKEv2 Personal VPN with Swift - 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

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

Firebase Phone Authentication for mac catalyst

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.

Firebase Connectivity Test Shows Disconnected At Start Even When Connected. How Do I Change This?

I am trying to make sure Firebase has a connection before continuing to load the app. I'm using the code from Firebase's own code sample. I have placed it in the ViewDidLoad function on my home view controller:
let connectedRef = Database.database().reference(withPath: ".info/connected")
connectedRef.observe(.value, with: { snapshot in
if let connected = snapshot.value as? Bool, connected {
print("Connected")
} else {
print("Not connected")
// show alert here
}
})
The problem is that the above code always shows "Not Connected" before then showing "Connected". This is a problem because when the app is not connected, it's supposed to show an alert, and the alert will then fire every time the user opens the app.
Is this expected behavior? If so, is there a way around it?
How do I check for Firebase connectivity without Firebase returning that it's not connected first every time?
The behavior you're observing is expected. The Firebase SDK can't establish its connection immediately upon startup. There is always going to be some latency between launch and whenever a connection is first available.
Also, I don't think this strategy is a good idea, because mobile connections can be intermittent and flakey. Firebase can not possibly ensure that your app will retain a good connection even after it's first established. Your app will be easier to use if you assume that it doesn't have a connection all the time. Users have come to expect some level of offline usage, and Realtime Database supports that to some degree with offline data persistence.

Facebook login WinJS Store app issues

I tried following this blog post
Which explains how to setup up facebook login on a WinJS app.
I got it all working, got the app ids set and the authentication dialog is showing the correct app name and authentication stuff, however when the app redirects the app receives this error (after closing the dialog: "The specified protocol is unknown") and the dialog shows the error message: "We can't connect to the service you need right now. Check your network connection or try this again later".
the error stack:
"WinRTError: The specified protocol is unknown.\r\n\n at getResultsOfAsyncOp (Function code:338:5)\n at op.completed (Function code:427:21)
Actual calling code:
var loginURL = "https://www.facebook.com/dialog/oauth?client_id=[snip]&display=popup&scope=user_about_me&response_type=token&redirect_uri=ms-app://s-[snip]/"
Windows.Security.Authentication.Web.WebAuthenticationBroker.authenticateAsync(
Windows.Security.Authentication.Web.WebAuthenticationOptions.none,
new Windows.Foundation.Uri(loginURL))
.then(function success(result) {
}, function error(error) {
});
Hopefully anyone here has any idea why this error message is thrown.
We managed to solve the issue.
The sid from the store was different from the sid of the app during local debugging. By changing the appmanifest -> packaging -> publisher certificate to a local certificate with the CN provided in the store settings the sid is updated to be equal to the one in the store.
et voila, it works.

Location Manager causes "server did not accept client registration" warning

I am new to iPhone. When I am dealing with location manager I got the first message to access my location
Allow and Don't Allow if I press allow then it works fine.
But I press Don't Allow then it gives me the warning which I have displayed below :
Function,"void CLClientHandleDaemonDataRegistration(__CLClient*, mach_port_t, const CLDaemonCommToClientRegistration*, const __CFDictionary*)",server did not accept client registration 1
Does anyone have a solution for that?
There is no solution, if the user does not allow your app to use the location service there is no way to enforce it.
You can check if you may use the location service:
BOOL result = [CLLocationManager locationServicesEnabled];
if (result) {
dbgPrint(#"Location services enabeld");
} else {
dbgPrint(#"Location services disabeld");
}