Skip to content
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

What to use as an alternative to the deprecated onActivityResult method? #1144

Closed
3 tasks done
Code-B1 opened this issue Nov 18, 2021 · 4 comments
Closed
3 tasks done
Labels
type:question Support or code-level question

Comments

@Code-B1
Copy link

Code-B1 commented Nov 18, 2021

New Issue Checklist

Issue Description

I have noticed that when implementing the Facebook login that we are still having to override OnActivityResult() however, this has since been deprecated (it appears as if it still works for now however, I assume not for much longer).

I was wondering if there was a new login method available that we can use ? which avoids overriding this method ? or am I possibly using the incorrect method ? (I am currently using ParseFacebookUtils.logInWithReadPermissionsInBackground as per the documentation)

I wonder if you may be able to assist ? or advise if this method is still safe to use moving forward.

Steps to reproduce

Use ParseFacebookUtils.logInWithReadPermissionsInBackground to log into Facebook and override OnActivityResult()

Actual Outcome

I notice when I override the OnActivityResult() that there is a strikethrough this method (though it does appear to work)

Expected Outcome

To not be using any deprecated methods to log into Facebook

Parse Android SDK

  • SDK version: 2.0.4
@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 18, 2021

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

@azlekov
Copy link
Contributor

azlekov commented Nov 18, 2021

Hey @Code-B1 thanks for opening this. Indeed starting from AndroidX Fragment 1.3 they deprecated the Fragment::onActivityResult in flavour of the new Activity Result APIs.

From what I understood the problem is not in the ParseFacebookUtils method (as there's no deprecations there) but in your Activity/Fragment. In this case you should update your code and start using the activity result APIs. A quick research gives a very nice StackOverflow topic where you can find how to do it.

I have created an issue on the documentation repo. If you're interested you can create a PR to help others not get confused. 😊🤞

Good luck,
Assen

@azlekov azlekov added state:wont-fix Won’t be fixed with a clearly stated reason type:docs Only change in the docs or README and removed state:wont-fix Won’t be fixed with a clearly stated reason labels Nov 18, 2021
@mtrezza mtrezza added type:question Support or code-level question and removed type:docs Only change in the docs or README labels Nov 18, 2021
@mtrezza
Copy link
Member

mtrezza commented Nov 18, 2021

I'm closing this; we could have transferred this issue to the docs repo, but since there is a new issue there, I reclassified this as a support question that requires no further action.

@mtrezza mtrezza closed this as completed Nov 18, 2021
@mtrezza mtrezza changed the title As OnActivityResult() is deprecated, will there be another way to login Facebook without overriding this deprecated method ? What to use as an alternative to the deprecated onActivityResult method? Nov 18, 2021
@Code-B1
Copy link
Author

Code-B1 commented Nov 19, 2021

@L3K0V Thank you for the prompt response, I had found this article also when trying to research this however, I was unable to adopt this to work for the facebook login, (I apologise, as this is likely due to me being very new to Kotlin) however I cannot seem to find a way to get this to fire in the correct order.

The old method utilizes the onActivityResult when ParseFacebookUtils.logInWithReadPermissionsInBackground is run, however, the StackOverflow suggestion requires passing an activity to the launcher (rather than a method). When I pass the activity containing my login activity it is unable to complete as it needs ParseFacebookUtils.onActivityResult method to be run as part of the login activity which is before the activity is finished (if that makes sense).

I assume a lot of my confusion is down to my lack of knowledge in Kotlin, as I cannot seem to work out an alternative way to get the data returned from ParseFacebookUtils.logInWithReadPermissionsInBackground into the registerForActivityResult as I assume the logic from the when statement would now have to be moved into the registerForActivityResult to occur after this has ran.

Unfortunately, this means I won't be able to help with a PR :( but I will definitely be looking forward to the updated documentation when it becomes available. Until then I shall keep pursuing trying to get this working :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

3 participants