Connect to Pusher ChatKit [Swift] - swift

I am attempting to connect to pusher chatkit; however, everytime I attempt the connection I am receiving this response:
"Making attempt 5 of 6 in 16.0s. Error was: Bad response status code received: 401 with error message: services/chatkit_authorizer/authorization/missing_permission: User does not have access to requested resource"
After it makes 6 attempts it then connects, so I am not sure what the missing permission is.
Below is the code I am using to connect.
self.chatManagerDelegate = MyChatManagerDelegate()
chatManager = ChatManager(instanceLocator: Pusher_Chatkit.instanceLocator,
tokenProvider: PCTokenProvider(url: Pusher_Chatkit.tokenProvider),
userID: "user-id")
chatManager.connect(delegate: chatManagerDelegate!) { currentUser, error in
guard error == nil else {
print("Error connecting: \(error!.localizedDescription)")
return
}
print("Successfully connected")

Make sure that you have the cursors:read:get permission enabled for the role that the user is trying to connect with. You can do this using the dashboard, one of our server SDKs, or the API directly.
Without this permission enabled the connection attempt will currently fail as all clients try to establish a subscription to receive read cursor updates, even if you don't use the read cursor functionality anywhere else in your app.

Related

Apple Music API not letting me get User Token - Throwing Unknown Error

I am trying to create a very simple app using Apple's Apple Music API in Swift. To do this, I need to retrieve songs from Apple Music. I am trying to get a user token using this code
SKCloudServiceController().requestUserToken(forDeveloperToken: "[DEV TOKEN HERE]") { (userToken, err) in
if let e = err {
print(e)
}
if let token = userToken {
print(token)
}
}
Right now I am just trying to print the token, but every time I call this function I am met with this error in console
Error Domain=SKErrorDomain Code=0 "An unknown error occurred" UserInfo={NSLocalizedDescription=An unknown error occurred}
I am confident that it is not my Dev Token because that usually throws a 'Cannot Connect to iTunes' error and I have tried substituting random strings for my dev token just to get the same error.
I've looked around but I cannot find an answer to this, has anyone else encountered it or have any idea how to fix it?
Thank you!
P.S I am not too familiar with posting on Stack Overflow so if I made some mistake please let me know so I can correct it!
Same here. It worked before 14.2. Developer Token is valid, I checked Dev Center.

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

Passwordless Email Auth Firebase, Dynamic Links (FDL)

I'm trying to setup password-less email authentication through firebase for my iOS app. I'm using the method send signInLink which require actionCodeSettings and in turn a url. I've discovered that this url has to be a dynamic link created on Firebase. I've gone to the firebase console and white-listed a domain, but when I try to create the dynamic link on the console, I get "An error occurred when creating new dynamic link".
I'm a little confused as to how I'm supposed to construct this dynamic link especially the deep link. I've been through Firebase's documentation, added a dummy App Store ID and App prefix (as I was told by Firebase support), but I can't seem to get a proper diagnosis behind this
If I try sending the sign-in email there is no issue, but when I click on the link I get a 400 error saying "The requested URL was not found on this server".
Can anyone help me out with this?
actionCodeSettings.handleCodeInApp = true
actionCodeSettings.url = URL(string: String(format: "my_dynamic_link", email.text!))
actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!)
actionCodeSettings.setAndroidPackageName("", installIfNotAvailable: false, minimumVersion: "12")
Auth.auth().sendSignInLink(toEmail: email.text!, actionCodeSettings: actionCodeSettings, completion: { error in
if error != nil {
print("Link Error: " + (error?.localizedDescription)!)
let castedError = error as NSError?
let FBError = AuthErrorCode(rawValue: (castedError?.code)!)
switch FBError {
case .invalidEmail?:
print("invalid email")
case .emailAlreadyInUse?:
print("in use")
default:
print("Create User Error: \(error!)")
}
}
else {
print ("No Error")
}
})
You could try following the troubleshooting steps mentioned in the Firecasts video "Getting started with Firebase Dynamic Links on iOS - Pt.1 (Firecasts)" at 7:54 (https://youtu.be/KLBjAg6HvG0?t=474).
I was having the same issue and everything worked fine after:
deleting the app
restarting my phone
reinstalling the app
Currently the bug radar (http://www.openradar.me/radar?id=4999496467480576) is still open.

Realm Object Server - Error: Your request parameters did not validate

I built a small iOS application which uses Realm instead of CoreData. The app does not require a login as it only stores data entered by the user. I'm currently trying to save users data so that if a user deleted the app for example, the data will be there by default the next the app is re-installed.
Here's where I am getting confused. Can I still use Realm Mobile Platform even though the app will not require a login screen. (i.e. data will automatically be saved for users who are logged-in to their iCloud accounts).
Here's what I've done so far:
I configured Realm Object Server on an AWS EC2 instance, and I can login to the realm dashboard through the browser just fine.
I configured the cloudKit stanza in the configuration.yml file as per the authentication instructions.
In my setupRealm() func, I tried the following code but I keep getting a parameters validation error:
SyncUser.logIn(with: cloudKitCredentials,
server: serverURL) { user, error in
if let user = user {
print("in")
}
else if let error = error {
fatalError(String(describing: error))
// Error: "Your request parameters did not validate."
}
This is the error message:
Error Domain=io.realm.sync Code=3
"Your request parameters did not validate."
UserInfo={statusCode=400,
NSLocalizedDescription=Your request parameters did not validate.}:
I suspect that the my iCloud user is not being tied with the object server, but I can't seem to put the pieces together. I'd appreciate any pointers.
The server requires a restart after editing the authentication lines in the configuration.yml.

Differentiate between access denied & login failure

I have a monitoring component which monitors every windows objects in a network. I am using WMI & Powershell for that purpose. I will be extracting the connection exceptions to identify what kind of exceptions are coming for each object. For example...
if (exceptionMessage.ToLower().Contains("access is denied."))
{
// Returns as access denied
}
else if (exceptionMessage.ToLower().Contains("the rpc server is unavailable."))
{
// Returns as host unavailable
}
else if (exceptionMessage.ToLower().Contains("this operation would create an incorrectly structured document."))
{
// Returns the exception
}
else
{
// Returns as Login failure
}
But in most cases, even if I give invalid credentials, i am getting only "Access Denied", not "Login failed".
Can anyone explain why this is happening. How we can differentiate between "Access denied" and "Login failed".
Any helpful information on this would be greatly appreciated.
Thanks
Sebastian
user should already have to get access privillage for whatever you want access.so the user account
have to previously create and give to access authority.if does not add then it will show the
"Access Denined".
User already have account means,after they will enter wrong login information then it will show
"login failed"