-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
Current User is not kept in sync between App and Extension #1648
Comments
Thanks for opening this issue!
|
Have you looked at? #1220 |
Thanks @cbaker6, yes I have seen that issue and it is not related unfortunately. In his instance, queries would fail every time because he missed a configuration step. In this issue, the configuration is correct and queries are actually successful. It is only when the user changes that the extension does not update and queries fail (since the token is now invalid). In other words, the main app's |
For anyone else experiencing this issue, I don't really have a direct workaround, but for now I am avoiding relying the shared |
I have just encountered this issue as well. I believe it is caused by the fact that The extension needs a way to forcibly forget and reload the still investigating how to workaround this with current SDK. |
Investigation: Both Because data and keychain are shared between the main app and extension, this is not a problem for cold app start or cold extension start, when Parse loads proper and fresh data from disk/keychain. But when I have prototyped a solution that works for me, but may not be ideal. In my extensions I simply forget the current user whenever the extension is called, and force a reload. Since extensions have little time to waste, this was the quickest method I came up with. Another more generic solution may be comparing the filesystem timestamp to see if reload is needed, which would then work both ways. But for now, I have added a method The code for now lives here: mman@dc3307e ideas? |
Maybe a solution would be to store the current user and installation in keychain like the session token, then have both the app and extension access it? If the session token is already stored there, the necessary basic keychain logic may already be there? We may just need to add a simple migration mechanism that migrates from file to keychain. |
It does not matter much where the user or installation or session token are stored. What matters is when they should be reloaded and how to detect/communicate that from the main app to the extension or the other way. The key issue here is that when you sign out in the main app, the extension still has a current user and session token in memory and will use it until it realizes that session token is actually invalid or current user refresh fails. The logic to get current user / current installation at the moment simply returns the object that is in memory, and if it is not there, it will load it. What I have done is just added a method to “forget” the object so that it is refetched forcibly, proper systematic fix will somehow check the validity of the in memory object against the permanent storage (disk or keychain) and will reload if needed… |
Keychain may provide advantages. We could always read the keychain value (instead of occasionally loading it from file) and synch the keychain across app and extension, see the Apple docs. So whenever the extension queries the user, it directly uses the keychain value which is always in-sync with the app that may have modified its value. |
@mtrezza Yeah, always storing/fetching from either keychain or disk could be a solution. The However for example Another option I was thinking about was to store push tokens for watch app and live activity as separate fields in So not an easy way forward as far as I can see, because we probably want to unify the support for shared |
New Issue Checklist
Issue Description
An app extension such as a widget should be able to access the current logged in user in order to make queries. There are good instructions about configuring your app and extension to allow this. However, when the logged-in user changes in the app, the extension's version of this does not update accordingly. I also believe that a user change from the extension is similarly not reflected in the main app.
Steps to reproduce
Please refer to the attached example project, and the included
Parse Widget Test Notes.txt
. The tests steps themselves are reproduced below:Test 1
Expected: the current logged-in user is displayed.
Actual: the current user is still nil.
Test 2 (continue from test 1)
Expected: Current user should be nil.
Actual: The current user is still set to the previous value, and an error message is displayed. (The error is correct since the session token was revoked when the user logged out, only the widget's version of the current user didn't update.)
ParseWidgetUserTest.zip
The text was updated successfully, but these errors were encountered: