-
-
Notifications
You must be signed in to change notification settings - Fork 69
feat: add migration from Obj-C SDK to Swift SDK #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for opening this pull request!
|
Codecov Report
@@ Coverage Diff @@
## main #391 +/- ##
==========================================
- Coverage 89.17% 89.10% -0.07%
==========================================
Files 156 156
Lines 14553 14778 +225
==========================================
+ Hits 12977 13168 +191
- Misses 1576 1610 +34
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
What is the rationale behind this? Why isn't it updating the existing installation? Technically the app isn't newly installed, it's updated which wouldn't create a new installation in other Parse SDKs.
Could you explain? |
The server doesn’t let an app login with the same session token and same installation using “become” method. The installationId has to be different when leveraging the same sessionToken. The server is designed that way.
I’ve stated the SDKs are completely different, #391 (comment) in which they are, classes/structs, the way they encode/decode, etc. The Swift SDK knows how to speak to the server, not the Objective-C SDK or any other SDK. |
Why can't the Swift SDK migrate an existing ObjC SDK session token without using |
The Swift SDK can get the
I've answered this in the comment above. The developer will want to access
|
New Pull Request Checklist
Issue Description
Currently there's no way to migrate from the Objective-C SDK to the Swift SDK. This enforces developers who convert to have to ask users to log into applications again after migration. More discussion in here.
Related issue: #n/a
Approach
Use the session token (assuming it's still valid) from an already logged in user in the Objective-C SDK Keychain to become/login into the Swift SDK. This allows a seamless migration/login without interrupting the application flow and does not modify the original Objective-C Keychain or the original session token. There is no need to have the Parse Objective-C SDK as a framework in your project as the Swift SDK doesn't need it to access the keychain since the keychain belongs to the respective app and can be access via the
bundleId. The methods introduced to allow this are:ParseUser
/** Logs in a `ParseUser` *asynchronously* using the session token from the Parse Objective-C SDK Keychain. Returns an instance of the successfully logged in `ParseUser`. The Parse Objective-C SDK Keychain is not modified in any way when calling this method; allowing developers to revert their applications back to the older SDK if desired. - parameter options: A set of header options sent to the server. Defaults to an empty set. - parameter callbackQueue: The queue to return to after completion. Default value of .main. - parameter completion: The block to execute when completed. It should have the following argument signature: `(Result<Self, ParseError>)`. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. - warning: When initializing the Swift SDK, `migratingFromObjcSDK` should be set to **false** when calling this method. */ public func loginUsingObjCKeychain(options: API.Options = [], callbackQueue: DispatchQueue = .main, completion: @escaping (Result<Self, ParseError>) -> Void) /** Logs in a `ParseUser` *asynchronously* using the session token from the Parse Objective-C SDK Keychain. Returns an instance of the successfully logged in `ParseUser`. The Parse Objective-C SDK Keychain is not modified in any way when calling this method; allowing developers to revert their applications back to the older SDK if desired. - parameter options: A set of header options sent to the server. Defaults to an empty set. - returns: Returns the logged in `ParseUser`. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. - warning: When initializing the Swift SDK, `migratingFromObjcSDK` should be set to **false** when calling this method. */ @discardableResult func loginUsingObjCKeychain(options: API.Options = []) async throws -> Self /** Logs in a `ParseUser` *asynchronously* using the session token from the Parse Objective-C SDK Keychain. Publishes an instance of the successfully logged in `ParseUser`. The Parse Objective-C SDK Keychain is not modified in any way when calling this method; allowing developers to revert their applications back to the older SDK if desired. - parameter options: A set of header options sent to the server. Defaults to an empty set. - returns: A publisher that eventually produces a single value and then finishes or fails. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. - warning: When initializing the Swift SDK, `migratingFromObjcSDK` should be set to **false** when calling this method. */ func loginUsingObjCKeychainPublisher(options: API.Options = []) -> Future<Self, ParseError>ParseInstallation
/** Migrates the `ParseInstallation` *asynchronously* from the Objective-C SDK Keychain. - parameter copyEntireInstallation: When **true**, copies the entire `ParseInstallation` from the Objective-C SDK Keychain to the Swift SDK. When **false**, only the `channels` and `deviceToken` are copied from the Objective-C SDK Keychain; resulting in a new `ParseInstallation` for original `sessionToken`. Defaults to **true**. - parameter options: A set of header options sent to the server. Defaults to an empty set. - parameter callbackQueue: The queue to return to after completion. Default value of .main. - parameter completion: The block to execute. It should have the following argument signature: `(Result<Self, ParseError>)`. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. */ func migrateFromObjCKeychain(copyEntireInstallation: Bool = true, options: API.Options = [], callbackQueue: DispatchQueue = .main, completion: @escaping (Result<Self, ParseError>) -> Void) /** Deletes the Objective-C Keychain along with the Objective-C `ParseInstallation` from the Parse Server *asynchronously* and executes the given callback block. - parameter options: A set of header options sent to the server. Defaults to an empty set. - parameter callbackQueue: The queue to return to after completion. Default value of .main. - parameter completion: The block to execute when completed. It should have the following argument signature: `(Result<Void, ParseError>)`. - warning: It is recommended to only use this method after a succesfful migration. Calling this method will destroy the entire Objective-C Keychain and `ParseInstallation` on the Parse Server. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. */ func deleteObjCKeychain(options: API.Options = [], callbackQueue: DispatchQueue = .main, completion: @escaping (Result<Void, ParseError>) -> Void) /** Migrates the `ParseInstallation` *asynchronously* from the Objective-C SDK Keychain. - parameter copyEntireInstallation: When **true**, copies the entire `ParseInstallation` from the Objective-C SDK Keychain to the Swift SDK. When **false**, only the `channels` and `deviceToken` are copied from the Objective-C SDK Keychain; resulting in a new `ParseInstallation` for original `sessionToken`. Defaults to **true**. - parameter options: A set of header options sent to the server. Defaults to an empty set. - returns: Returns saved `ParseInstallation`. - throws: An error of type `ParseError`. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. */ @discardableResult func migrateFromObjCKeychain(copyEntireInstallation: Bool = true, deleteObjectiveCKeychain: Bool = false, options: API.Options = []) async throws -> Self /** Deletes the Objective-C Keychain along with the Objective-C `ParseInstallation` from the Parse Server *asynchronously*. - parameter options: A set of header options sent to the server. Defaults to an empty set. - returns: Returns saved `ParseInstallation`. - throws: An error of type `ParseError`. - warning: It is recommended to only use this method after a succesfful migration. Calling this method will destroy the entire Objective-C Keychain and `ParseInstallation` on the Parse Server. */ func deleteObjCKeychain(options: API.Options = []) async throws /** Migrates the `ParseInstallation` *asynchronously* from the Objective-C SDK Keychain and publishes when complete. - parameter copyEntireInstallation: When **true**, copies the entire `ParseInstallation` from the Objective-C SDK Keychain to the Swift SDK. When **false**, only the `channels` and `deviceToken` are copied from the Objective-C SDK Keychain; resulting in a new `ParseInstallation` for original `sessionToken`. Defaults to **true**. - parameter options: A set of header options sent to the server. Defaults to an empty set. - returns: A publisher that eventually produces a single value and then finishes or fails. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. */ func migrateFromObjCKeychainPublisher(copyEntireInstallation: Bool = true, options: API.Options = []) -> Future<Self, ParseError> /** Deletes the Objective-C Keychain along with the Objective-C `ParseInstallation` from the Parse Server *asynchronously* and publishes when complete. - parameter options: A set of header options sent to the server. Defaults to an empty set. - returns: A publisher that eventually produces a single value and then finishes or fails. - warning: It is recommended to only use this method after a succesfful migration. Calling this method will destroy the entire Objective-C Keychain and `ParseInstallation` on the Parse Server. */ func deleteObjCKeychainPublisher(options: API.Options = []) -> Future<Void, ParseError>Note that logging in via the linked methods is the proper way to migrate to the Swift SDK as the SDK's themselves are entirely different and the Swift SDK should hydrate the
_Userand_InstallationParseObject's from the server instead of relying on the Objective-C SDK.Developers should also ensure the latest
PFUserandPFInstallationis saved to their Parse Server before migrating a user using these new methods. After initializing the SDK, migration should look something like:TODOs before merging