As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
At some point in the app, after I have a logged-in session, I am doing this -
guard let user = Client.sharedClient.activeUser as? CustomKinveyUser else {return}
The above line works and user is non-nil and is of type CustomKinveyUser
if and only if I have signed in during that particular launch of the app.
However, in subsequent app launches if I already have a signed-in session, Client.sharedClient.activeUser returns a non-nil object as expected, but the class type is the base user class (Kinvey.User) instead of CustomKinveyUser and so the downcast fails (i.e the as? CustomKinveyUser part returns nil)
captured from the xcode console:
(lldb) po Client.sharedClient.activeUser
▿ Optional<User>
▿ some : <__KNVUser: 0x7fdf34e829d0>
Best Answer
P
Pranav J
said
about 6 years ago
Niraj,
Thanks for the detailed explanations. Engineering is looking at the
issue.
We'd like you to know that our SDK is open source and we are
happy to accept contributions. If you have a solution for this issue or
any others in the future, please feel free to submit a pull request to
our repo. Our team will gladly review it and accept your fix.
Can you try the fix that Niraj has mentioned above?
Thanks,
Pranav
Kinvey
S
Sagar Patel
said
about 6 years ago
Hi All,
Nirajs fix does indeed work...
However it may be a better idea to extend the Kinvey.Client Class like so:
extension Kinvey.Client {
var activeCustomUser: CustomUser? {
get {
if let user = Kinvey.sharedClient.activeUser {
let map = Map(mappingType: .fromJSON, JSON: user.toJSON())
let customUser = CustomUser.init(map: map)
return customUser
} else {
return nil
}
}
}
This has two advantages, it firstly decouples from the Kinvey SDK thus pod updates won't break your code.
Personally I have extended the UIViewController Class, the reason being, all ViewControllers display different content based on the user being logged in or not.
extension UIViewController {
var activeUser: CustomUser? {
get {
if let user = Kinvey.sharedClient.activeUser {
let map = Map(mappingType: .fromJSON, JSON: user.toJSON())
let customUser = CustomUser.init(map: map)
return customUser
} else {
return nil
}
}
}
P
Pranav J
said
about 6 years ago
Sagar,
We'd like you to know that our SDK is open source and we are
happy to accept contributions. If you have a solution for this issue or
any others in the future, please feel free to submit a pull request to
our repo. Our team will gladly review it and accept your fix.
Thanks, Pranav Kinvey
S
Sagar Patel
said
about 6 years ago
Hi All,
The fix suggested I have found to not work when calling customUser.logout(), nothing happens.
C
Chris D
said
almost 6 years ago
It seems like Nirajs and Sagar Patel's solution no longer works with the latest 3.5.0 SDK.
Does anyone else have a solution?
Even with the latest iOS Kinvey SDK version 3.5.0, this problem still exists....that is, getting the Kinvey.sharedClient.activeUserstill doesn't return the custom User object if the app is killed (only works after a fresh login).
P
Pranav J
said
almost 6 years ago
Chris,
This issue has already been escalated to engineering earlier this week and will update you once I get more information from engineering.
Thanks, Pranav Kinvey
MLIBZ-1800
P
Pranav J
said
almost 6 years ago
Chris,
We are pleased to inform you that a new release of the iOS SDK v3.5.1 has been posted and is available for download at the following URL.
Niraj Khatod
I am using iOS sdk 3.0. I have created a custom user sublclass as explained in http://devcenter.kinvey.com/ios-v3.0/guides/users#CustomAttributesCustomUserObject
below is my SDK initializatin code in appDelegate:
aKinvey.sharedClient.userType = CustomKinveyUser.self
Kinvey.sharedClient.initialize(
appKey: "kid_xxxxx",
appSecret: "my-app-secret"
)
The CustomKinveyUser class looks like:
class CustomKinveyUser: Kinvey.User {
var profilePicURL: String?
override func mapping(map: Map) {
super.mapping(map: map)
profilePicURL <- map["profilePicURL"]
}
}
At some point in the app, after I have a logged-in session, I am doing this -
guard let user = Client.sharedClient.activeUser as? CustomKinveyUser else {return}
The above line works and user is non-nil and is of type CustomKinveyUser
if and only if I have signed in during that particular launch of the app.
However, in subsequent app launches if I already have a signed-in session, Client.sharedClient.activeUser returns a non-nil object as expected, but the class type is the base user class (Kinvey.User) instead of CustomKinveyUser and so the downcast fails (i.e the as? CustomKinveyUser part returns nil)
captured from the xcode console:
(lldb) po Client.sharedClient.activeUser
▿ Optional<User>
▿ some : <__KNVUser: 0x7fdf34e829d0>
Thanks for the detailed explanations. Engineering is looking at the issue.
We'd like you to know that our SDK is open source and we are happy to accept contributions. If you have a solution for this issue or any others in the future, please feel free to submit a pull request to our repo. Our team will gladly review it and accept your fix.
Thanks,
Pranav
Kinvey
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstPranav J
Sagar,
Can you try the fix that Niraj has mentioned above?
Thanks,
Pranav
Kinvey
Sagar Patel
Hi All,
Nirajs fix does indeed work...
However it may be a better idea to extend the Kinvey.Client Class like so:
This has two advantages, it firstly decouples from the Kinvey SDK thus pod updates won't break your code.
Personally I have extended the UIViewController Class, the reason being, all ViewControllers display different content based on the user being logged in or not.
Pranav J
We'd like you to know that our SDK is open source and we are happy to accept contributions. If you have a solution for this issue or any others in the future, please feel free to submit a pull request to our repo. Our team will gladly review it and accept your fix.
Thanks,
Pranav
Kinvey
Sagar Patel
Hi All,
The fix suggested I have found to not work when calling customUser.logout(), nothing happens.
Chris D
It seems like Nirajs and Sagar Patel's solution no longer works with the latest 3.5.0 SDK.
Does anyone else have a solution?
Even with the latest iOS Kinvey SDK version 3.5.0, this problem still exists....that is, getting the Kinvey.sharedClient.activeUser still doesn't return the custom User object if the app is killed (only works after a fresh login).
Pranav J
This issue has already been escalated to engineering earlier this week and will update you once I get more information from engineering.
Thanks,
Pranav
Kinvey
MLIBZ-1800
Pranav J
Chris,
We are pleased to inform you that a new release of the iOS SDK v3.5.1 has been posted and is available for download at the following URL.
http://devcenter.kinvey.com/ios/downloads
This update fixes the problem described in this ticket regarding CustomClass that you discovered in the 3.5.0 SDK.
At your convenience, please download and test the fix and let us know if it works to your satisfaction.
Thanks,
Pranav
Kinvey
Basem Abduallah
Hi all,
I found another temporary solution to solve this cases especially if you want to load custom viewController depend on the logging status
Simply open "User.swift" class and add your own properties and remove this from your app delegate
"sharedClient.userType = CustomUser.self" in my case I did that
1 - open Kinvey User Class and add following
create your variables like "open var fullname :String?"
2- Edit the mapping function like
open func mapping(map: Map) {
_userId <- map[PersistableIdKey]
acl <- map[PersistableAclKey]
metadata <- map[PersistableMetadataKey]
socialIdentity <- map["_socialIdentity"]
username <- map["username"]
email <- map["email"]
fullname <- map["full_name"] // as you want
}
3- Build your project
It works for me like charm
conclusion because Kinvey is open source framework so edit it as you like.
Hope this help
Thanks
-
Why do I get "Undefined symbols" errors when building with KinveyKit?
-
How do I register push tokens?
-
When using social login, to perform a log-out, do I need to log out of the social network, Kinvey, o
-
How can I assign additional properties to users?
-
Does KinveyKit support 64-bit ARM devices, such as iPhone 5s?
-
Authorization Token Invalid or Expired
-
BOOL and how it is stored in the database.
-
Offline saving throwing errors
-
Custom endpoint not able to form request object
-
Security through business logic
See all 437 topics